feat(i18n): add capture prompt translations and locale init

- integrate flutter_localizations and delegates in MaterialApp
- use language-only supportedLocales; add resolution callback
- initialize I18n on app start and when switching language
- localize capture screen prompt via I18n.t
- schedule map centering via postFrame to avoid race conditions
- add flutter_localizations to pubspec
This commit is contained in:
2025-09-26 10:45:29 +08:00
parent 4496986d9b
commit ee9a9200b6
8 changed files with 45 additions and 8 deletions

View File

@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'i18n.dart';
/// Provider for managing app locale and language switching
class LocaleProvider extends ChangeNotifier {
@@ -20,6 +21,7 @@ class LocaleProvider extends ChangeNotifier {
_prefs = await SharedPreferences.getInstance();
final savedLanguage = _prefs.getString(_languageKey) ?? _defaultLanguage;
_locale = Locale(savedLanguage);
await I18n.init(_locale);
notifyListeners();
}
@@ -29,6 +31,7 @@ class LocaleProvider extends ChangeNotifier {
_locale = locale;
await _prefs.setString(_languageKey, locale.languageCode);
await I18n.init(locale);
notifyListeners();
}