load method

Future<bool> load()

Load the JSON file for the current locale

Implementation

Future<bool> load() async {
  try {
    String jsonString = await rootBundle.loadString(
      'assets/l10n/${locale.languageCode}.json',
    );
    _localizedStrings = _flattenMap(json.decode(jsonString));
    return true;
  } catch (e) {
    try {
      // Fallback to English if locale file not found
      String jsonString = await rootBundle.loadString('assets/l10n/en.json');
      _localizedStrings = _flattenMap(json.decode(jsonString));
      return true;
    } catch (e) {
      debugPrint('Error loading localization: $e');
      return false;
    }
  }
}