Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix dayjs i18n #755

Merged
merged 9 commits into from
Sep 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions ui/lib/utils/i18n.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import 'dayjs/locale/en'
import 'dayjs/locale/zh-cn'
import 'dayjs/locale/zh'

import dayjs from 'dayjs'
import i18next from 'i18next'
import LanguageDetector from 'i18next-browser-languagedetector'
import { initReactI18next } from 'react-i18next'

i18next.on('languageChanged', function (lng) {
console.log('Language', lng)
dayjs.locale(lng.toLowerCase())
})

Expand Down Expand Up @@ -46,8 +44,8 @@ i18next
.use(initReactI18next)
.init({
resources: {}, // oh! this line is a big pitfall, we can't remove it, else it will cause strange crash!
fallbackLng: 'en',
whitelist: ['zh', 'en'],
fallbackLng: 'en', // fallbackLng won't change the detected language
whitelist: ['zh', 'en'], // whitelist will change the detected lanuage
interpolation: {
escapeValue: false,
},
Expand Down