diff --git a/map/src/manager/AccountManager.js b/map/src/manager/AccountManager.js index e69760f11..f59ecea89 100644 --- a/map/src/manager/AccountManager.js +++ b/map/src/manager/AccountManager.js @@ -1,4 +1,5 @@ import { apiGet, apiPost } from '../util/HttpApi'; +import i18n from '../i18n'; export const LOGIN_LOGOUT_URL = '/map/loginForm#logout'; // lose window.location.search/window.location.hash @@ -40,6 +41,7 @@ async function userLogin({ ctx, username, pwd, setEmailError, handleClose, lang body: JSON.stringify({ username: username.toLowerCase(), password: pwd, lang }), }); if (await isRequestOk(response, setEmailError)) { + await resetLanguage(); setEmailError(''); ctx.setLoginUser(username); ctx.setEmailCookie(username, { days: 30, SameSite: 'Strict' }); // for next login @@ -54,6 +56,7 @@ async function userLogout({ ctx, username, setEmailError, handleClose, setState, body: JSON.stringify({ username: username.toLowerCase(), lang }), }); if (await isRequestOk(response, setEmailError)) { + await resetLanguage(); setState('login'); ctx.setLoginUser(''); setEmailError(''); @@ -167,6 +170,11 @@ async function changeEmail({ email, token, setEmailError, lang = DEFAULT_AUTH_AP } } +async function resetLanguage() { + localStorage.removeItem('i18nextLng'); + await i18n.changeLanguage(navigator.language); +} + const AccountManager = { deleteAccount, userRegister, diff --git a/map/src/menu/settings/SettingsMenu.jsx b/map/src/menu/settings/SettingsMenu.jsx index 6893681db..5d70575c0 100644 --- a/map/src/menu/settings/SettingsMenu.jsx +++ b/map/src/menu/settings/SettingsMenu.jsx @@ -107,6 +107,24 @@ export default function SettingsMenu({ setCloudSettings }) { const transB = getTransLanguage(b); return collator.compare(transA, transB); }); + res.push( + { + await i18n.changeLanguage(navigator.language).then(() => { + setCurrentLang(t(`lang_${i18n.language}`)); + }); + setOpenLangList(false); + ctx.setOpenedPopper(null); + }} + > + + + {`${t('system_locale')} (${t(`lang_${navigator.language}`)})`} + + + + ); sortedLangList.map((lang, index) => { const transLang = getTransLanguage(lang); if (transLang) { diff --git a/map/src/resources/translations/en/translation.json b/map/src/resources/translations/en/translation.json index d0adf1826..7d68bb46e 100644 --- a/map/src/resources/translations/en/translation.json +++ b/map/src/resources/translations/en/translation.json @@ -5205,5 +5205,6 @@ "shared_string_modified": "Modified", "shared_string_added": "Added", "shared_string_deleted": "Deleted", - "shared_string_changes": "Changes" + "shared_string_changes": "Changes", + "system_locale": "System" } \ No newline at end of file