Skip to content

Commit b03f0f7

Browse files
authored
Merge pull request #1193 from scottsut/lang
fix: language switching and initialization logic
2 parents c800fa4 + 7b48e98 commit b03f0f7

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

frontend/src/locales/i18n.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,14 @@ export const translationsJson = {
2424
convertLanguageJsonToObject(en);
2525

2626
export const changeLang = lang => {
27-
i18next.changeLanguage(lang);
28-
requestInstance.defaults.headers['Accept-Language'] =
29-
lang === 'zh' ? 'zh-CN' : 'en-US'; // FIXME locale
3027
localStorage.setItem(StorageKeys.Locale, lang);
31-
moment.locale(lang === 'zh' ? 'zh-cn' : 'en-us'); // FIXME locale
3228
window.location && window.location.reload();
3329
};
3430

3531
const initialLocale = getInitialLocale();
36-
moment.locale(initialLocale);
32+
requestInstance.defaults.headers['Accept-Language'] =
33+
initialLocale === 'zh' ? 'zh-CN' : 'en-US'; // FIXME locale
34+
moment.locale(initialLocale === 'zh' ? 'zh-cn' : 'en-us'); // FIXME locale
3735

3836
export const i18n = i18next
3937
// pass the i18n instance to react-i18next.

0 commit comments

Comments
 (0)