mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-26 22:31:20 +00:00
Fixing language setting issue. Fixes #1041
This commit is contained in:
parent
f5211aab2a
commit
d14bc121c0
3 changed files with 6 additions and 4 deletions
3
ui/src/components/navbar.tsx
vendored
3
ui/src/components/navbar.tsx
vendored
|
@ -30,6 +30,7 @@ import {
|
||||||
messageToastify,
|
messageToastify,
|
||||||
md,
|
md,
|
||||||
setTheme,
|
setTheme,
|
||||||
|
getLanguage,
|
||||||
} from '../utils';
|
} from '../utils';
|
||||||
import { i18n } from '../i18next';
|
import { i18n } from '../i18next';
|
||||||
|
|
||||||
|
@ -435,7 +436,7 @@ export class Navbar extends Component<any, NavbarState> {
|
||||||
this.requestNotificationPermission();
|
this.requestNotificationPermission();
|
||||||
this.fetchUnreads();
|
this.fetchUnreads();
|
||||||
setTheme(data.my_user.theme, true);
|
setTheme(data.my_user.theme, true);
|
||||||
i18n.changeLanguage(data.my_user.lang);
|
i18n.changeLanguage(getLanguage());
|
||||||
}
|
}
|
||||||
this.state.isLoggedIn = true;
|
this.state.isLoggedIn = true;
|
||||||
}
|
}
|
||||||
|
|
3
ui/src/components/user.tsx
vendored
3
ui/src/components/user.tsx
vendored
|
@ -30,6 +30,7 @@ import {
|
||||||
showAvatars,
|
showAvatars,
|
||||||
toast,
|
toast,
|
||||||
setupTippy,
|
setupTippy,
|
||||||
|
getLanguage,
|
||||||
} from '../utils';
|
} from '../utils';
|
||||||
import { UserListing } from './user-listing';
|
import { UserListing } from './user-listing';
|
||||||
import { SortSelect } from './sort-select';
|
import { SortSelect } from './sort-select';
|
||||||
|
@ -877,7 +878,7 @@ export class User extends Component<any, UserState> {
|
||||||
|
|
||||||
handleUserSettingsLangChange(i: User, event: any) {
|
handleUserSettingsLangChange(i: User, event: any) {
|
||||||
i.state.userSettingsForm.lang = event.target.value;
|
i.state.userSettingsForm.lang = event.target.value;
|
||||||
i18n.changeLanguage(i.state.userSettingsForm.lang);
|
i18n.changeLanguage(getLanguage(i.state.userSettingsForm.lang));
|
||||||
i.setState(i.state);
|
i.setState(i.state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
4
ui/src/utils.ts
vendored
4
ui/src/utils.ts
vendored
|
@ -350,9 +350,9 @@ export function debounce(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getLanguage(): string {
|
export function getLanguage(override: string): string {
|
||||||
let user = UserService.Instance.user;
|
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') {
|
if (lang == 'browser') {
|
||||||
return getBrowserLanguage();
|
return getBrowserLanguage();
|
||||||
|
|
Loading…
Reference in a new issue