Skip to content

Commit

Permalink
ui: fix dayjs i18n (#755)
Browse files Browse the repository at this point in the history
  • Loading branch information
baurine authored and breezewish committed Nov 26, 2020
1 parent b3b056d commit 7a73749
Showing 1 changed file with 3 additions and 5 deletions.
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

0 comments on commit 7a73749

Please sign in to comment.