Closed tbragaf closed 8 years ago
Yep, use String.locale
to manually set the localization language.
After setting String.locale = "pt";
, l10n.js will give Português translations. Likewise, setting it to "en"
will make l10n.js give you English localizations.
Actually, I see your issue is that you want a global storage for strings not bound to a language. I'm going to implement that right now.
@tbragaf You can now store default strings under ""
. For example:
{
"": {
"foo": "default"
},
"en": {
"foo": "English"
},
"en-US": {
"foo": "English (US)"
},
"pt": {
"foo": "Português"
}
}
"foo".toLocalString() === "default"
if the user doesn't match any of the supported locales.
Note that you can also set String.defaultLocale
to set any language as the default (e.g. String.defaultLocale = "en"
), and then that language will behave like the new ""
default I just introduced.
@eligrey Thank you very much!
Hi all!
First of all, tthis is not an issue, but rather a question. But since I couldn't find an answer, here goes: Is it possible to programatically translate a resource?
In the current app I am developing, we give the user the option to change the current locale. However it seems easy at first, we need to warn the user about the language being changed (not in its current locale, but rather in the option's locale).
Something like
<locale>: <locale_warning>
Best regards, tbragaf