From: Dessalines Date: Thu, 30 Jul 2020 02:29:41 +0000 (-0400) Subject: Fixing language setting issue. Fixes #1041 X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/save/%22%7B%7D/static/%7Blink%7D?a=commitdiff_plain;h=d14bc121c0aa19bcec2c85c5d0b581f00dcae84a;p=lemmy.git Fixing language setting issue. Fixes #1041 --- diff --git a/ui/src/components/navbar.tsx b/ui/src/components/navbar.tsx index 2986ce7e..6418bb22 100644 --- a/ui/src/components/navbar.tsx +++ b/ui/src/components/navbar.tsx @@ -30,6 +30,7 @@ import { messageToastify, md, setTheme, + getLanguage, } from '../utils'; import { i18n } from '../i18next'; @@ -435,7 +436,7 @@ export class Navbar extends Component { this.requestNotificationPermission(); this.fetchUnreads(); setTheme(data.my_user.theme, true); - i18n.changeLanguage(data.my_user.lang); + i18n.changeLanguage(getLanguage()); } this.state.isLoggedIn = true; } diff --git a/ui/src/components/user.tsx b/ui/src/components/user.tsx index e4d4439b..d0dcdf55 100644 --- a/ui/src/components/user.tsx +++ b/ui/src/components/user.tsx @@ -30,6 +30,7 @@ import { showAvatars, toast, setupTippy, + getLanguage, } from '../utils'; import { UserListing } from './user-listing'; import { SortSelect } from './sort-select'; @@ -877,7 +878,7 @@ export class User extends Component { handleUserSettingsLangChange(i: User, event: any) { i.state.userSettingsForm.lang = event.target.value; - i18n.changeLanguage(i.state.userSettingsForm.lang); + i18n.changeLanguage(getLanguage(i.state.userSettingsForm.lang)); i.setState(i.state); } diff --git a/ui/src/utils.ts b/ui/src/utils.ts index 892516bf..fa7f1297 100644 --- a/ui/src/utils.ts +++ b/ui/src/utils.ts @@ -350,9 +350,9 @@ export function debounce( }; } -export function getLanguage(): string { +export function getLanguage(override: string): string { let user = UserService.Instance.user; - let lang = user && user.lang ? user.lang : 'browser'; + let lang = override || (user && user.lang ? user.lang : 'browser'); if (lang == 'browser') { return getBrowserLanguage();