fix new version applocalization

This commit is contained in:
2025-08-31 18:24:49 +02:00
parent 2f74f5ed78
commit 6169483839
169 changed files with 2384 additions and 45 deletions

View File

@@ -0,0 +1,41 @@
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
class LocaleProvider with ChangeNotifier {
static const _localeKey = 'locale_code';
Locale _locale = const Locale('en');
Locale get locale => _locale;
LocaleProvider() {
_loadLocale();
}
Future<void> _loadLocale() async {
final prefs = await SharedPreferences.getInstance();
final code = prefs.getString(_localeKey);
if (code != null && L10n.all.contains(Locale(code))) {
_locale = Locale(code);
notifyListeners();
}
}
void setLocale(Locale locale) async {
if (!L10n.all.contains(locale)) return;
_locale = locale;
notifyListeners();
final prefs = await SharedPreferences.getInstance();
await prefs.setString(_localeKey, locale.languageCode);
}
}
class L10n {
static final all = [
const Locale('en'),
const Locale('fr'),
const Locale('de')
];
}