Merge pull request #28402 from nextcloud/alias-locale-to-moment-supported-locale

Alias locales to moment supported locales
This commit is contained in:
szaimen 2021-08-12 23:27:28 +02:00 committed by GitHub
commit 26a4d73d85
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 4 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -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