Bring lang detect code in line with coding style.

Change html files so that we auto-detect the lang now.
This commit is contained in:
JC Brand 2015-05-20 19:31:59 +02:00
parent 99a017fc8a
commit 6afcc0fbe1
3 changed files with 19 additions and 17 deletions

View File

@ -215,32 +215,36 @@
// Translation machinery
// ---------------------
this.isAvailableLocale=function(locale){
ret=null;
if (locales[locale]) ret=locales[locale];
else{
this.isAvailableLocale = function (locale) {
ret = null;
if (locales[locale]) {
ret = locales[locale];
} else{
sublocale=locale.split("-")[0];
if (sublocale!=locale && locales[sublocale]) ret=locales[sublocale];
if (sublocale!=locale && locales[sublocale]) {
ret=locales[sublocale];
}
}
return ret;
};
this.detectLocale=function(){
ret=null;
if (window.navigator.userLanguage) ret=this.isAvailableLocale(window.navigator.userLanguage);
else if (window.navigator.languages && !ret){
this.detectLocale = function () {
ret = null;
if (window.navigator.userLanguage) {
ret = this.isAvailableLocale(window.navigator.userLanguage);
} else if (window.navigator.languages && !ret) {
for (var i = 0; i < window.navigator.languages.length && !ret; i++) {
ret=this.isAvailableLocale(window.navigator.languages[i]);
ret = this.isAvailableLocale(window.navigator.languages[i]);
}
}
else if (window.navigator.browserLanguage && !ret) ret=this.isAvailableLocale(window.navigator.browserLanguage);
else if (window.navigator.language && !ret) ret=this.isAvailableLocale(window.navigator.language);
else if (window.navigator.systemLanguage && !ret) ret=this.isAvailableLocale(window.navigator.systemLanguage);
else {ret=locales.en}
else if (window.navigator.browserLanguage && !ret) ret = this.isAvailableLocale(window.navigator.browserLanguage);
else if (window.navigator.language && !ret) ret = this.isAvailableLocale(window.navigator.language);
else if (window.navigator.systemLanguage && !ret) ret = this.isAvailableLocale(window.navigator.systemLanguage);
else { ret = locales.en; }
return ret;
};
this.i18n = settings.i18n ? settings.i18n : this.detectLocale();
var __ = $.proxy(utils.__, this);
var ___ = utils.___;

View File

@ -53,7 +53,6 @@
require(['converse'], function (converse) {
converse.initialize({
bosh_service_url: 'https://conversejs.org/http-bind/', // Please use this connection manager only for testing purposes
i18n: locales['en'], // Refer to ./locale/locales.js to see which locales are supported
keepalive: true,
message_carbons: true,
play_sounds: true,

View File

@ -251,7 +251,6 @@
})();
converse.initialize({
bosh_service_url: 'https://conversejs.org/http-bind/', // Please use this connection manager only for testing purposes
i18n: locales['en'], // Refer to ./locale/locales.js to see which locales are supported
keepalive: true,
message_carbons: true,
play_sounds: true,