Closed alnah005 closed 3 years ago
Just looked at the code and it seems like this would be possible by overriding the translate
method in flutter_i18n.dart
and adding a CustomNetworkFileTranslationLoader
that has the option to append to baseUri. Another option is to completely overwrite the translationLoader
of _retrieveCurrentInstance
and then calling load. Please reply here if there's a more concrete way.
You are using Uri.https, which also support an encoded path as second parameter: https://api.flutter.dev/flutter/dart-core/Uri/Uri.https.html
Did you tried that?
You are using Uri.https, which also support an encoded path as second parameter: https://api.flutter.dev/flutter/dart-core/Uri/Uri.https.html
Did you tried that?
That worked, but for a single route. My main problem is whether it's possible to use the same NetworkFileTranslationLoader
for multiple routes.
What do you mean by routes?
A single instance of NetworkFileTranslationLoader
is used for each language that your app support.
Let's say for example I have two "en.json" files, one in example.com/page1
and one in example.com/page2
or maybe one with example.com/page?num=1
and example.com/page?num=2
. How would I use one NeworkFileTranslationLoader
in those cases?
With only the NeworkFileTranslationLoader
you can't do it.
You should use the NamespaceFileTranslationLoader
and combine its load with the NeworkFileTranslationLoader
.
Currently isn't supported, but you can create your own loader and open a PR to integrate it in this repo :)
Is it possible to add to the NetworkFileTranslationLoader baseUri? e.g. from
then somehow
Which would call
www.baylse-services.com/i18nget/
to get the translation fileen.json
.I'm just wondering if there's a way to avoid creating a flutterI18nDelegate for each route that contains
en.json