Comments (5)
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.
from l10n.js.
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.
from l10n.js.
@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.
from l10n.js.
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.
from l10n.js.
@eligrey Thank you very much!
from l10n.js.
Related Issues (17)
- IE chokes on indexOf HOT 2
- Russian l10n for demo HOT 4
- Canadian English localisation [sic]
- Cannot call method 'valueOf' error HOT 3
- IOS Translation HOT 2
- Loading language files fails on some browsers due to inconsistent status codes
- Synchronous XMLHttpRequest HOT 2
- japanese demo is broken HOT 2
- Bower
- ReferenceErrors in browserless environment HOT 2
- Do you need to include a translation when one isn't needed? HOT 3
- Does localization file have to be a .js file rather than .json file if included after library? HOT 3
- Cannot get this to work... HOT 4
- Problem and a possible fix for Chrome 39 HOT 2
- Can you do translations with numbers? HOT 2
- Support format {"property":{"lang1":"localized message in lang1"}}
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from l10n.js.