Jesway / flutter_translate

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

How can I specify asset file with country code (like `en-US`, `en-UK`)? #11

Closed trietbui85 closed 5 years ago

trietbui85 commented 5 years ago

I notice some localization library for Flutter supports naming like languageCode-countryCode (for example en-US, en-UK) but this library doesn't. Can you add support for it?

bratan commented 5 years ago

The library supports it, but you need to specify the format as languageCode_countryCode (underline instead of dash)

For example: en_US, en_GB, es_ES

It will also automatically fallback to languageCode for the filename.

So for example if you define the supported locales this way:

supportedLocales: ['en_US', 'en_GB', 'es_ES'])

It will search for the filenames en_US.json, en_GB.json ... and if not found, it will fallback to en.json

I will have to update the documentation as there are some more features not yet documented properly.

trietbui85 commented 5 years ago

@bratan Thanks for your answer. It's great to know that feature is already supported yet.