loadJSON method

Future<void> loadJSON()

Load the bundled JSON data for the current locale.

Called automatically by the constructor. Can be awaited if the caller needs to ensure data is ready before proceeding.

Implementation

Future<void> loadJSON() async {
  await _loadAssetManifest();

  // Always load root.json first as it contains locale-independent data (e.g. astro)
  await _loadFile(_rootPath);

  // normalizeLocale maps C/POSIX/empty to en-US.
  String curlocale = normalizeLocale(currentLocale);
  if (!isValidLocale(curlocale)) {
    logger.warn('Invalid locale: $curlocale, falling back to en-US');
    curlocale = 'en-US';
  }
  await _loadLocaleData(curlocale);
  _lastLoadedLocale = curlocale;

  initILib();
  logger.info('Notifying listeners after JSON loading');
  notifyListeners();
}