Last active
March 21, 2017 23:07
-
-
Save frozeman/78c1849b05cf90467fe7 to your computer and use it in GitHub Desktop.
TAPi18n set default language
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SET default language | |
if(Cookie.get('TAPi18next')) { | |
TAPi18n.setLanguage(Cookie.get('TAPi18next')); | |
} else { | |
var userLang = navigator.language || navigator.userLanguage, | |
availLang = TAPi18n.getLanguages(); | |
// set default language | |
if (_.isObject(availLang) && availLang[userLang]) { | |
TAPi18n.setLanguage(userLang); | |
// lang = userLang; | |
} else if (_.isObject(availLang) && availLang[userLang.substr(0,2)]) { | |
TAPi18n.setLanguage(userLang.substr(0,2)); | |
// lang = userLang.substr(0,2); | |
} else { | |
TAPi18n.setLanguage('en'); | |
// lang = 'en'; | |
} | |
} | |
// change moment and numeral language, when language changes | |
Tracker.autorun(function(){ | |
if(_.isString(TAPi18n.getLanguage())) { | |
moment.locale(TAPi18n.getLanguage().substr(0,2)); | |
numeral.language(TAPi18n.getLanguage().substr(0,2)); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Eventually the cookie functionality was disabled.