Fix an issue with user language setting.

This commit is contained in:
Dessalines 2020-07-29 09:05:46 -04:00
parent 5dd0efb280
commit 19db9dea30
2 changed files with 12 additions and 14 deletions

View file

@ -31,7 +31,7 @@ import {
md, md,
setTheme, setTheme,
} from '../utils'; } from '../utils';
import { i18n, i18nextSetup } from '../i18next'; import { i18n } from '../i18next';
interface NavbarState { interface NavbarState {
isLoggedIn: boolean; isLoggedIn: boolean;
@ -435,12 +435,11 @@ 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);
} }
this.state.isLoggedIn = true; this.state.isLoggedIn = true;
} }
i18nextSetup();
this.state.siteLoading = false; this.state.siteLoading = false;
this.setState(this.state); this.setState(this.state);
} }

21
ui/src/i18next.ts vendored
View file

@ -65,16 +65,15 @@ function format(value: any, format: any, lng: any): any {
return format === 'uppercase' ? value.toUpperCase() : value; return format === 'uppercase' ? value.toUpperCase() : value;
} }
export function i18nextSetup() { i18next.init({
i18next.init({ debug: false,
debug: false, // load: 'languageOnly',
// load: 'languageOnly',
// initImmediate: false,
lng: getLanguage(),
fallbackLng: 'en',
resources,
interpolation: { format },
});
// initImmediate: false,
lng: getLanguage(),
fallbackLng: 'en',
resources,
interpolation: { format },
});
}
export { i18next as i18n, resources }; export { i18next as i18n, resources };