webpack-contrib / i18n-webpack-plugin

[DEPRECATED] Embed localization into your bundle
MIT License
318 stars 74 forks source link

Support fallback language when using tokens #13

Open sorahn opened 8 years ago

sorahn commented 8 years ago

We have some fairly long strings on our site, so we were going to opt for using tokens like this __("my_string_key"), the json like this:

// en.json
{
  "my_string_key": "English String"
}

// de.json
{
  "my_string_key": "Deutsche Zeichenfolge"
}

However, I was wondering if its still possible to have the this plugin set up a default.

Currently if you use languages = {en: null, de} this works by assuming that the english strings are in the code, and it falls back to using that. We would be looking for a way to specify what language to display if the german strings are missing.

Thanks.

102 commented 8 years ago

@sorahn have you managed to find the answer?

sorahn commented 8 years ago

@102 Not in webpack. We ended up using http://i18next.com/ which gave us full control over how we get updates, and which languages are baked in and what order of fallbacks they go through