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>
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:flutter/services.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../core/auth/auth_provider.dart';
|
||||
import '../../core/locale/language_provider.dart';
|
||||
import '../../core/theme/app_colors.dart';
|
||||
import '../../shared/models/user.dart';
|
||||
import 'profile_provider.dart';
|
||||
@@ -114,6 +115,18 @@ class _ProfileBody extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Settings
|
||||
_SectionLabel('НАСТРОЙКИ'),
|
||||
const SizedBox(height: 6),
|
||||
_InfoCard(children: [
|
||||
_InfoRow(
|
||||
'Язык',
|
||||
supportedLanguages[user.preferences['language'] as String? ?? 'ru'] ??
|
||||
'Русский',
|
||||
),
|
||||
]),
|
||||
const SizedBox(height: 32),
|
||||
|
||||
_LogoutButton(),
|
||||
@@ -327,6 +340,7 @@ class _EditProfileSheetState extends ConsumerState<EditProfileSheet> {
|
||||
String? _gender;
|
||||
String? _goal;
|
||||
String? _activity;
|
||||
String? _language;
|
||||
bool _saving = false;
|
||||
|
||||
@override
|
||||
@@ -341,6 +355,7 @@ class _EditProfileSheetState extends ConsumerState<EditProfileSheet> {
|
||||
_gender = u.gender;
|
||||
_goal = u.goal;
|
||||
_activity = u.activity;
|
||||
_language = u.preferences['language'] as String? ?? 'ru';
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -367,6 +382,7 @@ class _EditProfileSheetState extends ConsumerState<EditProfileSheet> {
|
||||
gender: _gender,
|
||||
goal: _goal,
|
||||
activity: _activity,
|
||||
language: _language,
|
||||
);
|
||||
|
||||
final ok = await ref.read(profileProvider.notifier).update(req);
|
||||
@@ -555,6 +571,21 @@ class _EditProfileSheetState extends ConsumerState<EditProfileSheet> {
|
||||
onSelectionChanged: (s) => setState(
|
||||
() => _activity = s.isEmpty ? null : s.first),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Language
|
||||
DropdownButtonFormField<String>(
|
||||
value: _language,
|
||||
decoration:
|
||||
const InputDecoration(labelText: 'Язык интерфейса'),
|
||||
items: supportedLanguages.entries
|
||||
.map((e) => DropdownMenuItem(
|
||||
value: e.key,
|
||||
child: Text(e.value),
|
||||
))
|
||||
.toList(),
|
||||
onChanged: (v) => setState(() => _language = v),
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
|
||||
// Save
|
||||
|
||||
Reference in New Issue
Block a user