-
-
Notifications
You must be signed in to change notification settings - Fork 363
Open
Description
Lets say user has device locale fr-FR which is not in the supported locales.
runApp(
EasyLocalization(
supportedLocales: const [
Locale('de'),
Locale('en'),
Locale('es'),
Locale('pl'),
Locale('ru'),
Locale('tr'),
],
path: 'assets/translations',
fallbackLocale: const Locale('en', 'US'),
startLocale: const Locale('fr', 'FR'),
useFallbackTranslations: true,
useOnlyLangCode: true,
useFallbackTranslationsForEmptyResources: true,
child: const App(),
),
);
expected behaviour is to use en, US
however it throws an error instead.


and here is the code:
abstract class AssetLoader {
const AssetLoader();
Future<Map<String, dynamic>?> load(String path, Locale locale);
}
///
/// default used is RootBundleAssetLoader which uses flutter's assetloader
///
class RootBundleAssetLoader extends AssetLoader {
const RootBundleAssetLoader();
String getLocalePath(String basePath, Locale locale) {
return '$basePath/${locale.toStringWithSeparator(separator: "-")}.json';
}
@override
Future<Map<String, dynamic>?> load(String path, Locale locale) async {
var localePath = getLocalePath(path, locale);
EasyLocalization.logger.debug('Load asset from $path');
return json.decode(await rootBundle.loadString(localePath));
}
}
There is no mechanism in place to check the supported locales first before checking assets folder
Metadata
Metadata
Assignees
Labels
No labels