Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for fallbackLanguage #181

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add support for fallbackLanguage #181

wants to merge 1 commit into from

Conversation

thp
Copy link

@thp thp commented Apr 15, 2015

This is useful for situations where ID-based translations
are used and where a fallback to another language is desirable.

Example:

  • Source strings are ID-based, e.g. LABEL_SOMETHING
  • Strings are translated to English: e.g. "Something"
  • Strings are translated to German, but missing some translations

Setting:

gettextContext.setCurrentLanguage('de');
gettextContext.setFallbackLanguage('en');

Should then return the English string if the German string is not
available (e.g. LABEL_SOMETHING returns "Something" in German).

This is useful for situations where ID-based translations
are used and where a fallback to another language is desirable.

Example:

* Source strings are ID-based, e.g. `LABEL_SOMETHING`
* Strings are translated to English: e.g. "Something"
* Strings are translated to German, but missing some translations

Setting:

```
gettextContext.setCurrentLanguage('de');
gettextContext.setFallbackLanguage('en');
```

Should then return the English string if the German string is not
available (e.g. `LABEL_SOMETHING` returns "Something" in German).
@rubenv
Copy link
Owner

rubenv commented Apr 15, 2015

I'm not sure I want to encourage ID-based translations. One of the main reasons I built this library is because ID-based translation systems are just a pain in the ass (and wrong).

If you want to do ID-based translations, I suggest you look into a framework that is built for it (e.g. angular a translate).

@thp
Copy link
Author

thp commented Apr 15, 2015

Ok, maybe ID-based translations was the wrong argument for this feature addition. Assume the source strings are "Engineering English" and there is a "US English" translation and a "German" translation, and instead of falling back to the source strings, a missing string in the "German" translation should fall back to the "US English" translation:

  • Source string: "Home page" (=Engineering English)
  • US English translation: "Homepage" (the i18n Engineer fixed spacing)
  • German translation: missing

Now, with currentLanguage = "de" and fallbackLanguage = "en", this would show "Homepage" instead of the (unfixed) "Home page".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants