Issue #44: Language now correctly falls back to English instead of German for unsupported locales (e.g., French system language before this update). Added localeListResolutionCallback to MaterialApp that: - Respects user's explicit locale choice - Falls back to matching system locale if available - Defaults to English when no match found Added complete French (fr) translation: - All 200+ strings translated - Proper French accents (é, è, ê, à, etc.) - Added to settings language picker Updated: - lib/main.dart: localeListResolutionCallback for fallback logic - lib/l10n/app_fr.arb: New French translation file - lib/l10n/app_en.arb: Added "french" string - lib/l10n/app_de.arb: Added "french" string (Französisch) - lib/l10n/app_es.arb: Added "french" string (Francés) - lib/providers/locale_provider.dart: Added French display name - lib/screens/settings_screen.dart: Added French option Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
45 lines
1.0 KiB
Dart
45 lines
1.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../services/settings_service.dart';
|
|
|
|
class LocaleProvider extends ChangeNotifier {
|
|
Locale? _locale; // null = system default
|
|
|
|
LocaleProvider() {
|
|
_loadLocale();
|
|
}
|
|
|
|
Locale? get locale => _locale;
|
|
|
|
Future<void> _loadLocale() async {
|
|
final savedLocale = await SettingsService.getLocale();
|
|
if (savedLocale != null) {
|
|
_locale = Locale(savedLocale);
|
|
}
|
|
notifyListeners();
|
|
}
|
|
|
|
Future<void> setLocale(Locale? locale) async {
|
|
_locale = locale;
|
|
await SettingsService.saveLocale(locale?.languageCode);
|
|
notifyListeners();
|
|
}
|
|
|
|
/// Returns the display name for a locale
|
|
static String getDisplayName(String? languageCode, BuildContext context) {
|
|
switch (languageCode) {
|
|
case 'en':
|
|
return 'English';
|
|
case 'de':
|
|
return 'Deutsch';
|
|
case 'es':
|
|
return 'Español';
|
|
case 'fr':
|
|
return 'Français';
|
|
case null:
|
|
return 'System';
|
|
default:
|
|
return languageCode;
|
|
}
|
|
}
|
|
}
|