Skip to content

Commit

Permalink
loading only one locale does not work properly, load all of them
Browse files Browse the repository at this point in the history
  • Loading branch information
tsubik committed Jan 23, 2025
1 parent ad82f00 commit 77c507d
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,16 @@ if (typeof window === 'undefined') {
}
}

// workaround as import(`dayjs/locale/${locale}`) was not working
const loadLocales = {
en: () => Promise.resolve(),
fr: () => import('dayjs/locale/fr'),
pt: () => import('dayjs/locale/pt'),
ja: () => import('dayjs/locale/ja'),
ko: () => import('dayjs/locale/ko'),
vi: () => import('dayjs/locale/vi'),
zh: () => import('dayjs/locale/zh-cn')
}

import dayjs from 'dayjs';
import dayOfYearPlugin from 'dayjs/plugin/dayOfYear';

import 'dayjs/locale/fr';
import 'dayjs/locale/pt';
import 'dayjs/locale/ja';
import 'dayjs/locale/ko';
import 'dayjs/locale/vi';
import 'dayjs/locale/zh-cn';

dayjs.extend(dayOfYearPlugin);

const IGNORE_WARNINGS = [
Expand Down Expand Up @@ -132,8 +128,6 @@ MyApp.getInitialProps = wrapper.getInitialAppProps(store => async ({ Component,
user = state.user;
}

await loadLocales[language]();

store.dispatch(setLanguage(language));
store.dispatch(setUser(user));

Expand Down

0 comments on commit 77c507d

Please sign in to comment.