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:
parent
99a017fc8a
commit
6afcc0fbe1
34
converse.js
34
converse.js
@ -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.___;
|
||||
|
||||
|
1
dev.html
1
dev.html
@ -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,
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user