jeresig / i18n-node-2

Lightweight simple translation module for node.js / express.js with dynamic json storage. Uses common __('...') syntax in app and templates.
MIT License
507 stars 79 forks source link

Support language fallbacks #104

Open rankun203 opened 7 years ago

rankun203 commented 7 years ago

Looking for a way to fallback en-* to en.

We have en language translated, but we don't have language files of en-US, en-CA etc.

[DOESN'T WORK] Right now we can only define all locales like this:

locales: ['en', 'en-us', 'en-gb', 'en-au', 'en-ca', 'en-nz', 'en-ie', 'en-za', 'en-jm', 'en-bz', 'en-tt']

Then have the base function to slice all locales base: locale => locale.slice(0, 2).

However this isn't ideal, it would be better to support fallbacks officially.

rankun203 commented 7 years ago

Actually last try doesn't work at all.

Now we are using soft links (en-*.json -> en.json).

BirgitPohl commented 7 years ago

I have a use case for a fallback from de to en. And yes, in both cases I want to support de and en not being specific about a certain area.

rankun203 commented 7 years ago

UPDATE: Soft links are also not working.

gjuchault commented 7 years ago

As I don't really have much time for this project, I'd say PR welcome :)