loadBaseTranslations method

Future<void> loadBaseTranslations(
  1. Map<String, String> baseTranslations
)

Loads base translations for the initial language.

Implementation

Future<void> loadBaseTranslations(
  Map<String, String> baseTranslations,
) async {
  await _init();

  // Check if base translations have changed
  final currentBaseJson = jsonEncode(baseTranslations);
  final cachedBaseJson = _prefs.getString('base_translations');

  if (cachedBaseJson != currentBaseJson) {
    _baseVersion++;
    await _prefs.setInt('base_version', _baseVersion);
    await _prefs.setString('base_translations', currentBaseJson);
    _cache[initialLanguage.code] = Map.from(baseTranslations);
    await _saveToCache(initialLanguage.code, baseTranslations);
    notifyListeners();
  }
  if (_currentLanguage != initialLanguage &&
      _needsRefresh(_currentLanguage.code)) {
    await _refreshCurrentLanguage();
  }
}