diff options
Diffstat (limited to 'modern/src/common/components/LocalizationProvider.js')
-rw-r--r-- | modern/src/common/components/LocalizationProvider.js | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/modern/src/common/components/LocalizationProvider.js b/modern/src/common/components/LocalizationProvider.js index 147ac5ca..db3e1fb9 100644 --- a/modern/src/common/components/LocalizationProvider.js +++ b/modern/src/common/components/LocalizationProvider.js @@ -1,5 +1,9 @@ /* eslint-disable import/no-relative-packages */ -import React, { createContext, useContext, useMemo } from 'react'; +import React, { + createContext, useContext, useEffect, useMemo, +} from 'react'; +import moment from 'moment'; +import 'moment/min/locales.min'; import af from '../../../../web/l10n/af.json'; import ar from '../../../../web/l10n/ar.json'; @@ -146,6 +150,16 @@ export const LocalizationProvider = ({ children }) => { const value = useMemo(() => ({ languages, language, setLanguage }), [languages, language, setLanguage]); + useEffect(() => { + let selected; + if (language.length > 2) { + selected = `${language.slice(0, 2)}-${language.slice(-2).toLowerCase()}`; + } else { + selected = language; + } + moment.locale([selected, 'en']); + }, [language]); + return ( <LocalizationContext.Provider value={value}> {children} |