loadLocale method
Asynchronously loads the catalog for targetLocale using a registered loader.
Sets isLoading to true while the loader future is resolving.
Returns true if a catalog was loaded successfully or was already present.
final success = await BloomI18n.instance.loadLocale('ja-JP');
if (success) {
BloomI18n.instance.setLocale('ja-JP');
}
Implementation
Future<bool> loadLocale(String targetLocale) async {
if (_catalogs.containsKey(targetLocale)) return true;
final loader = _loaders[targetLocale] ?? _findLoaderNormalized(targetLocale);
if (loader == null) return false;
isLoading.value = true;
try {
final catalog = await loader();
addCatalog(catalog);
return true;
} finally {
isLoading.value = false;
}
}