Files
food-ai/client/lib/core/locale/language_provider.dart
dbastrikin 0567d90784 feat: implement client-side localization infrastructure
- Add languageProvider (StateProvider<String>, default 'ru') with
  supportedLanguages map matching backend locale.Supported
- Wire Accept-Language header into AuthInterceptor via languageGetter
  callback; all API requests now carry the current language
- Sync language from user profile preferences into languageProvider
  on every ProfileNotifier load/update
- Add language field to UpdateProfileRequest, serialized as
  preferences.language in PUT /profile
- Profile screen: НАСТРОЙКИ section displays current language;
  edit sheet adds DropdownButtonFormField for language selection

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-27 23:34:51 +02:00

24 lines
693 B
Dart

import 'package:flutter_riverpod/flutter_riverpod.dart';
/// Supported ISO 639-1 language codes with their native names.
/// Must match the backend locale.Supported map.
const supportedLanguages = <String, String>{
'en': 'English',
'ru': 'Русский',
'es': 'Español',
'de': 'Deutsch',
'fr': 'Français',
'it': 'Italiano',
'pt': 'Português',
'zh': '中文',
'ja': '日本語',
'ko': '한국어',
'ar': 'العربية',
'hi': 'हिन्दी',
};
/// Current app language (ISO 639-1 code).
/// Synced from user.preferences['language'] after the profile loads or is updated.
/// Defaults to 'ru'.
final languageProvider = StateProvider<String>((_) => 'ru');