diff options
author | Anton Tananaev <anton@traccar.org> | 2022-05-24 08:21:22 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-05-24 08:21:22 -0700 |
commit | ad94dc32e90626d42b8d4baeefadefa0042824ec (patch) | |
tree | eca80659583961ce27628a38fd25d81584e5aa74 /modern/src/common | |
parent | d5dd02b6eb1b71e420e68a72488f08374f04f678 (diff) | |
download | trackermap-web-ad94dc32e90626d42b8d4baeefadefa0042824ec.tar.gz trackermap-web-ad94dc32e90626d42b8d4baeefadefa0042824ec.tar.bz2 trackermap-web-ad94dc32e90626d42b8d4baeefadefa0042824ec.zip |
Show last update time
Diffstat (limited to 'modern/src/common')
-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} |