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

@ -217,18 +217,22 @@
// ---------------------
this.isAvailableLocale = function (locale) {
ret = null;
if (locales[locale]) ret=locales[locale];
else{
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){
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]);
}
@ -236,11 +240,11 @@
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 { 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,