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 Sep 21, 2020
1 parent fe22ca2 commit 18d3266
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 18d3266

Please sign in to comment.