Chamud Pathirana
Chamud Pathirana

Reputation: 1

flutter_i18n silence errors

I am using flutter_i18n package with a json filw with translations.But it keeps printing errors in the console and makes it hard for me to debug

Another exception was thrown: Warning: This application's locale, ja, is not supported by all of its localization delegates.

Error while trying to load an asset: Flutter Web engine failed to fetch "assets/assets/flutter_i18n/ja.yaml". HTTP request succeeded, but the server responded with HTTP status
404.
Error while trying to load an asset: Flutter Web engine failed to fetch "assets/assets/flutter_i18n/ja.xml". HTTP request succeeded, but the server responded with HTTP status   
404.
Error while trying to load an asset: Flutter Web engine failed to fetch "assets/assets/flutter_i18n/ja.toml". HTTP request succeeded, but the server responded with HTTP status  
404.
Error while trying to load an asset: Flutter Web engine failed to fetch "assets/assets/flutter_i18n/en.yaml". HTTP request succeeded, but the server responded with HTTP status  
404.
Error while trying to load an asset: Flutter Web engine failed to fetch "assets/assets/flutter_i18n/en.xml". HTTP request succeeded, but the server responded with HTTP status   

Localization is working perfectly. But these errors are making it difficult for me to debug and I feel like localization is slightly delayed since it is checking for these yaml, toml, xml files. How can I prevent the programme from looking for these file, or at least how to silence these errors completely?

return MaterialApp(
            localizationsDelegates: [
              FlutterI18nDelegate(
                translationLoader: FileTranslationLoader(),
                missingTranslationHandler: (key, locale) {
                  if (kDebugMode) {
                    print("Missing translation for '$key' in '$locale'");
                  }
                },
              ),
              GlobalMaterialLocalizations.delegate,
              GlobalWidgetsLocalizations.delegate,
            ],
            supportedLocales: const [
              Locale('en'),
              Locale('ja'),
            ],
            locale: Provider.of<LocaleProvider>(context).locale,
.
.
);

I tried adding try catch blocks, reading the documentation and forums but I couldnt find any solution yet. Please help!

Upvotes: 0

Views: 38

Answers (0)

Related Questions