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:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user