mirror of
https://github.com/nextcloud/server.git
synced 2026-06-12 18:21:40 -04:00
Alias locales to moment supported locales
Moment doesn't have aliases for every locale and doesn't parse some locale IDs correctly so we need to alias them Close #27982 Signed-off-by: Thomas Citharel <tcit@tcit.fr> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
This commit is contained in:
parent
9603069cc7
commit
092e6be473
3 changed files with 24 additions and 4 deletions
4
core/js/dist/main.js
vendored
4
core/js/dist/main.js
vendored
File diff suppressed because one or more lines are too long
2
core/js/dist/main.js.map
vendored
2
core/js/dist/main.js.map
vendored
File diff suppressed because one or more lines are too long
|
|
@ -103,10 +103,30 @@ const initLiveTimestamps = () => {
|
|||
}, 30 * 1000)
|
||||
}
|
||||
|
||||
/**
|
||||
* Moment doesn't have aliases for every locale and doesn't parse some locale IDs correctly so we need to alias them
|
||||
*/
|
||||
const localeAliases = {
|
||||
zh: 'zh-cn',
|
||||
zh_Hans: 'zh-cn',
|
||||
zh_Hans_CN: 'zh-cn',
|
||||
zh_Hans_HK: 'zh-cn',
|
||||
zh_Hans_MO: 'zh-cn',
|
||||
zh_Hans_SG: 'zh-cn',
|
||||
zh_Hant: 'zh-hk',
|
||||
zh_Hant_HK: 'zh-hk',
|
||||
zh_Hant_MO: 'zh-mo',
|
||||
zh_Hant_TW: 'zh-tw',
|
||||
}
|
||||
let locale = OC.getLocale()
|
||||
if (Object.prototype.hasOwnProperty.call(localeAliases, locale)) {
|
||||
locale = localeAliases[locale]
|
||||
}
|
||||
|
||||
/**
|
||||
* Set users locale to moment.js as soon as possible
|
||||
*/
|
||||
moment.locale(OC.getLocale())
|
||||
moment.locale(locale)
|
||||
|
||||
/**
|
||||
* Initializes core
|
||||
|
|
|
|||
Loading…
Reference in a new issue