ngx-translate / core

The internationalization (i18n) library for Angular
MIT License
4.51k stars 575 forks source link

Is it or will it be possible to have language files for each dialect? #1119

Open daveboulden opened 5 years ago

daveboulden commented 5 years ago

Currently the language resources files are one per language, e.g. en.json, fr.json etc.

I would like to be able to split and name the language files by dialect, e.g. en-GB.json, en-US.json etc.

I have built an app that dynamically switches locales and loads the language files on demand (using examples found in other GitHub issues and examples online) and synchronizes those change events to the i18n features in Telerik Angular components. I wanted to switch other internationalisation options upon change of language and dialect so that when selecting en-GB, not only does it use the British spellings of certain words that differ from US English, but also that the correct date formats are utilised as they differ between the US and the UK

I would like to see the ability to switch between language and dialect options, not just the primary language, e.g.:

    this.translate.use('en-GB');

Is this ever going to be a likely possibility for ngx-translate?

ocombe commented 5 years ago

You can use whatever name you want, so this means that you can use en-GB and en-US without any issue. It's complicated if you want to set LOCALE_ID as well for the date pipe and such because it's a provider, which means that you can't change it once the pipe has been loaded, unless you manually call the pipe (or the formatDate function) and bind the result in your template.

daveboulden commented 5 years ago

Aaah, I see, I think I've become a little mislead as I'm using BabelEdit to manage the translation files for my app. It only allows one file per major language and having seen no examples of using dialects for ngx-translate, I incorrectly assumed that was a restriction with the library. I will raise the question with Code+Web and see why they have that restriction.

fkirc commented 3 years ago

I wrote the new tool attranslate as an alternative to BabelEdit: https://github.com/fkirc/attranslate attranslate is designed to make it trivial to synchronize multiple regions or dialects.