Jesway / flutter_translate

Flutter Translate is a fully featured localization / internationalization (i18n) library for Flutter.
MIT License
401 stars 118 forks source link

allow locales to be outside of the rootBundle #58

Closed volmus closed 3 years ago

volmus commented 3 years ago

Hi!

Actually it is not possible to have your locales outside of the rootBundle. This is needed in cases where you download your locales over network and can't have them in the rootBundle.

greetz

volmus commented 3 years ago

@bratan ?

bratan commented 3 years ago

@volmus - The currently supported way to load locales is through the bundle.

volmus commented 3 years ago

Yeah and I created a PR to support more ways.

bratan commented 3 years ago

Can you give me an example on how this would be used exactly.

volmus commented 3 years ago

Yea, sure. As you can see in my commit, I analyse the given path to the locale. If the path starts with a slash ("/"), it is an absolute path, which should be resolved by the filesystem. If it does not start with a slash, the path is relative to the application and therefore should be resolved by the rootBundle.

OK, so, the rootBundle is read only. If you want to update your dictionarys, you have to publish a new version of your app. My change allows to download updated dictionarys, place them somewhere on the device and use it beginning with the next app start.

bratan commented 3 years ago

The logic of the rootBundle could change anytime and filtering paths starting with a slash is not a good idea anyways (windows?).

If alternative localization loading is required (ex. retrieving the JSON data from an API, or downloading files as you suggest), an interface can be implemented and everyone could provide their own loader and pass it to the delegate.

simplenotezy commented 1 year ago

Would be super cool to be able to service translation files over the network, like many other translation libraries have. It's a tough process having to release a new update, simply to change a few translations