Commit 1ef495d5 authored by alexandre's avatar alexandre

user langage persistence through cookies

parent c14e4eac
......@@ -25,17 +25,8 @@ window.W = window.W || {};
// Declares the namespace to Dkango Relational
Backbone.Relational.store.addModelScope(W);
W.config = W.config || {};
var lang = W.utils.getCookie("lang");
if (!lang) {
lang = window.navigator.userLanguage || window.navigator.language;
lang = lang.substring(0,2)
}
W.config.lang = lang;
W.config.lang = W.utils.getUserLanguage();
var scoreApp = W.ScoreApp.start();
......
;
window.W = window.W || {};
window.W.utils = window.W.utils || {};
(function (undefined) {
'use strict';
W.utils = {};
W.utils.getUserLanguage = function () {
var lang = W.utils.getCookie("lang");
if (!lang) {
lang = window.navigator.userLanguage || window.navigator.language;
lang = lang.substring(0,2)
}
return lang;
}
W.utils.translate = window.t = function (string) {
if (!(W.config.lang in W.lang)) {
......
......@@ -1722,9 +1722,9 @@ window.W = window.W || {};
switchLanguage: function (view, event) {
W.config.lang = $(event.currentTarget).attr("data-lang");
var lang = W.utils.setCookie("lang", W.config.lang);
_.each(this.getRegions(), function(element, index, list) {
console.log(element);
var currentView = element.currentView;
if (currentView) { currentView.render(); }
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment