In my ember application I am supporting different languages. I am doing it this way:
This is part of the index.html
:
<script src="scripts/vendor/ember.js"></script>
<script src="scripts/vendor/ember-i18n.js"></script>
...
<script>window.mynamespace = {};</script>
<script src="scripts/languages/en.js"></script>
<script src="scripts/ember_application.js"></script>
In my languages/es.js
I configure a translations object as expected by ember-i18n:
var lang = {
key1 : 'Translation1',
...
};
window.mynamespace.lang = lang;
And now in my Ember application, I can do:
Ember.I18n.translations = window.mynamespace.lang;
var App = Ember.Application.createWithMixins({...});
I have three questions:
- Is there another approach for serving multi-lingual pages? Specifically I do not like very much the use of
window.mynamespace
, but I do not know how to share those settings before creating my ember application. - How can I serve a different language file, for example
scripts/languages/es.js
, based on the language preference settings in the browser (comming in the HTTP request)? - And this one is more difficult: how could I serve a different language file, depending on a database setting (belonging to the user profile for my application)? This setting would override the *language preference settings` coming in the HTTP request.