This commit is contained in:
JC Brand 2021-03-03 22:24:13 +01:00
parent a778f3866a
commit 3e5bd34141
3 changed files with 6 additions and 4 deletions

View File

@ -36,6 +36,7 @@ Removed events:
- #2377: The @converse/headless NPM package is missing the dist directory, causing import errors - #2377: The @converse/headless NPM package is missing the dist directory, causing import errors
- #2396: @converse/headless wrongly depends on `CustomElement` from the view layer - #2396: @converse/headless wrongly depends on `CustomElement` from the view layer
- #2381: Converse does not reflect the browser language
## 7.0.4 (2020-12-09) ## 7.0.4 (2020-12-09)

View File

@ -108,7 +108,7 @@ const DEFAULT_SETTINGS = {
discover_connection_methods: true, discover_connection_methods: true,
geouri_regex: /https\:\/\/www.openstreetmap.org\/.*#map=[0-9]+\/([\-0-9.]+)\/([\-0-9.]+)\S*/g, geouri_regex: /https\:\/\/www.openstreetmap.org\/.*#map=[0-9]+\/([\-0-9.]+)\/([\-0-9.]+)\S*/g,
geouri_replacement: 'https://www.openstreetmap.org/?mlat=$1&mlon=$2#map=18/$1/$2', geouri_replacement: 'https://www.openstreetmap.org/?mlat=$1&mlon=$2#map=18/$1/$2',
i18n: 'en', i18n: undefined,
idle_presence_timeout: 300, // Seconds after which an idle presence is sent idle_presence_timeout: 300, // Seconds after which an idle presence is sent
jid: undefined, jid: undefined,
keepalive: true, keepalive: true,

View File

@ -16,12 +16,12 @@ function detectLocale (library_check) {
* @param { Function } library_check - Returns a boolean indicating whether * @param { Function } library_check - Returns a boolean indicating whether
* the locale is supported. * the locale is supported.
*/ */
var locale, i; let locale;
if (window.navigator.userLanguage) { if (window.navigator.userLanguage) {
locale = isLocaleAvailable(window.navigator.userLanguage, library_check); locale = isLocaleAvailable(window.navigator.userLanguage, library_check);
} }
if (window.navigator.languages && !locale) { if (window.navigator.languages && !locale) {
for (i=0; i<window.navigator.languages.length && !locale; i++) { for (let i=0; i<window.navigator.languages.length && !locale; i++) {
locale = isLocaleAvailable(window.navigator.languages[i], library_check); locale = isLocaleAvailable(window.navigator.languages[i], library_check);
} }
} }
@ -113,7 +113,8 @@ Object.assign(i18n, {
_converse.locale = 'en'; _converse.locale = 'en';
} else { } else {
try { try {
_converse.locale = i18n.getLocale(api.settings.get('i18n'), api.settings.get("locales")); const preferred_locale = api.settings.get('i18n');
_converse.locale = i18n.getLocale(preferred_locale, api.settings.get("locales"));
await fetchTranslations(_converse); await fetchTranslations(_converse);
} catch (e) { } catch (e) {
log.fatal(e.message); log.fatal(e.message);