summaryrefslogtreecommitdiffstats
path: root/core/src
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2021-08-12 15:22:00 +0200
committernextcloud-command <nextcloud-command@users.noreply.github.com>2021-08-12 20:24:58 +0000
commit092e6be4731b436be752a478e59958a8bfc7c1e4 (patch)
tree9175211e8545121c63ef69e07bd3d381d6ee9691 /core/src
parent9603069cc7eff8967ccba1c8d805f3d9d6103924 (diff)
downloadnextcloud-server-092e6be4731b436be752a478e59958a8bfc7c1e4.tar.gz
nextcloud-server-092e6be4731b436be752a478e59958a8bfc7c1e4.zip
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>
Diffstat (limited to 'core/src')
-rw-r--r--core/src/init.js22
1 files changed, 21 insertions, 1 deletions
diff --git a/core/src/init.js b/core/src/init.js
index f1c3eaa17c1..60193b9eaab 100644
--- a/core/src/init.js
+++ b/core/src/init.js
@@ -104,9 +104,29 @@ const initLiveTimestamps = () => {
}
/**
+ * 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