Commit 6afcc0fb authored by JC Brand's avatar JC Brand

Bring lang detect code in line with coding style.

Change html files so that we auto-detect the lang now.
parent 99a017fc
...@@ -215,32 +215,36 @@ ...@@ -215,32 +215,36 @@
// Translation machinery // Translation machinery
// --------------------- // ---------------------
this.isAvailableLocale=function(locale){ this.isAvailableLocale = function (locale) {
ret=null; ret = null;
if (locales[locale]) ret=locales[locale]; if (locales[locale]) {
else{ ret = locales[locale];
} else{
sublocale=locale.split("-")[0]; sublocale=locale.split("-")[0];
if (sublocale!=locale && locales[sublocale]) ret=locales[sublocale]; if (sublocale!=locale && locales[sublocale]) {
ret=locales[sublocale];
}
} }
return ret; return ret;
}; };
this.detectLocale=function(){ this.detectLocale = function () {
ret=null; ret = null;
if (window.navigator.userLanguage) ret=this.isAvailableLocale(window.navigator.userLanguage); if (window.navigator.userLanguage) {
else if (window.navigator.languages && !ret){ ret = this.isAvailableLocale(window.navigator.userLanguage);
} else if (window.navigator.languages && !ret) {
for (var i = 0; i < window.navigator.languages.length && !ret; i++) { 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.browserLanguage && !ret) ret = this.isAvailableLocale(window.navigator.browserLanguage);
else if (window.navigator.language && !ret) ret=this.isAvailableLocale(window.navigator.language); 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 if (window.navigator.systemLanguage && !ret) ret = this.isAvailableLocale(window.navigator.systemLanguage);
else {ret=locales.en} else { ret = locales.en; }
return ret; return ret;
}; };
this.i18n = settings.i18n ? settings.i18n : this.detectLocale(); this.i18n = settings.i18n ? settings.i18n : this.detectLocale();
var __ = $.proxy(utils.__, this); var __ = $.proxy(utils.__, this);
var ___ = utils.___; var ___ = utils.___;
......
...@@ -53,7 +53,6 @@ ...@@ -53,7 +53,6 @@
require(['converse'], function (converse) { require(['converse'], function (converse) {
converse.initialize({ converse.initialize({
bosh_service_url: 'https://conversejs.org/http-bind/', // Please use this connection manager only for testing purposes 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, keepalive: true,
message_carbons: true, message_carbons: true,
play_sounds: true, play_sounds: true,
......
...@@ -251,7 +251,6 @@ ...@@ -251,7 +251,6 @@
})(); })();
converse.initialize({ converse.initialize({
bosh_service_url: 'https://conversejs.org/http-bind/', // Please use this connection manager only for testing purposes 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, keepalive: true,
message_carbons: true, message_carbons: true,
play_sounds: true, play_sounds: true,
......
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