diff --git a/app/initializers/translations.js b/app/initializers/translations.js index 79c7c96..0a9cbe0 100644 --- a/app/initializers/translations.js +++ b/app/initializers/translations.js @@ -8,7 +8,7 @@ export default { initialize: function(container, application) { // detect browser language var language = ''; - + // have a look if it's already stored in a cookie var cookie = document.cookie.replace(" ", "").split(";"); cookie.forEach(function(t){ @@ -17,32 +17,32 @@ export default { language = x[1]; } }); - + // if not we do it by browser language if (language === '') { language = (window.navigator.userLanguage || window.navigator.language).split("-")[0]; } - + // check if language is supported if(typeof translations[language] !== "object") { language = "en"; } - + Ember.FEATURES.I18N_TRANSLATE_HELPER_SPAN = false; Ember.ENV.I18N_COMPILE_WITHOUT_HANDLEBARS = true; - Ember.I18n.translations = translations[language]; + Ember.I18n.translations = Ember.copy(translations[language]); Ember.I18n.locale = language; - + // inject into controller var languageStorage = Ember.Object.extend({ selected: language }); container.register('language:current', languageStorage, {singleton: true}); application.inject('controller', 'language', 'language:current'); - + // set moment locale moment.locale( language ); - + // set webshim locale webshim.activeLang(language); } diff --git a/tests/unit/lang-test.js b/tests/unit/lang-test.js index 930a5b3..a7a1708 100644 --- a/tests/unit/lang-test.js +++ b/tests/unit/lang-test.js @@ -6,11 +6,7 @@ module('Unit | languages'); // Replace this with your real tests. test('translations are correct', function(assert) { assert.ok(languages); - /* - * test not working - * ember-i18n pluralization seems to add another key to languages object - * not sure why this modified languages object is retrieved by test - * https://github.com/jamesarosen/ember-i18n/tree/810aa7f04b2d30903fa094a5aac10bd4c936fcfe#pluralization + Object.keys(languages).map(function(language) { if (language !== 'en') { assert.equal( @@ -20,7 +16,6 @@ test('translations are correct', function(assert) { ); } }); - */ Object.keys(languages.en).map(function(translationKey) { Object.keys(languages).map(function(language) {