Closed dani-filipovic closed 3 months ago
Hi @dani-filipovic, the double call you see related to fallback translations, used by default if an entry is not found in your main file to avoid leaving you with an untranslated key. I guess we can make the fallback an optional parameter, to avoid fetching it if not needed.
Fixed with version 0.36.2, you can set fallbackFile
to null to avoid the double call
I am using the NetworkFileTranslationLoader with these settings:
localizationsDelegates: [ FlutterI18nDelegate( translationLoader: NetworkFileTranslationLoader( baseUri: Uri.https('...', '/app/strings'), useCountryCode: false, decodeStrategies: [ JsonDecodeStrategy(), ], forcedLocale: Locale(widget.selectedLanguage.isocode), ), ), GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate ],
The main App widget receives a selectedLanguage as an argument and passes it to the forcedLocale argument. Even though the forcedLocale parameter is passed, the fallbackLocale is still being fetched.
There are a few issues here:
await FlutterI18n.refresh(context, Locale(updateLanguage.isocode));
. This will fetch the appropriate file, e.g. fr.json, but again fetch en.json, too.Since we have quite large translation files, this is adding more than 2 seconds of network traffic to our app immediately after opening it.