diff --git a/src/mixins/localizeMoment.js b/src/mixins/localizeMoment.js index 97503cb48..9121656d7 100644 --- a/src/mixins/localizeMoment.js +++ b/src/mixins/localizeMoment.js @@ -11,15 +11,22 @@ export default { * This only maps the locales that need to be translated. * Most PKP locales work fine in Moment.js. * - * @param {String} locale The PKP locale, eg - `sr_RS@cyrillic` + * @param {String} locale The PKP locale, eg - `sr_Cyrl` */ getMomentLocale(locale) { + locale.replaceAll('_', '-').toLowerCase(); const map = { - 'sr_RS@latin': 'sr', - 'sr_RS@cyrillic': 'sr-cyrl', - 'uz_UZ@latin': 'uz-latn', + 'bs-latn': 'bs', + hy: 'hy-am', + 'nb-no': 'nb', + oc: 'oc-lnc', + pa: 'pa-in', + 'pt-pt': 'pt', + 'sr-latn': 'sr', + tl: 'tl-ph', + ug: 'ug-cn', + 'zh-hans': 'zh-cn', }; - return map[locale] ?? locale; }, }, diff --git a/src/pages/dashboard/mocks/pageInitConfig.js b/src/pages/dashboard/mocks/pageInitConfig.js index 2593cbd21..8b5d07c59 100644 --- a/src/pages/dashboard/mocks/pageInitConfig.js +++ b/src/pages/dashboard/mocks/pageInitConfig.js @@ -427,17 +427,6 @@ export default { _extractionAdaptersLoaded: false, _metadataInjectionAdapters: [], _injectionAdaptersLoaded: false, - _localesTable: { - 'be@cyrillic': 'be', - bs: 'bs_Latn', - fr_FR: 'fr', - nb: 'nb_NO', - 'sr@cyrillic': 'sr_Cyrl', - 'sr@latin': 'sr_Latn', - 'uz@cyrillic': 'uz', - 'uz@latin': 'uz_Latn', - zh_CN: 'zh_Hans', - }, }, 2: { _data: { @@ -475,17 +464,6 @@ export default { _extractionAdaptersLoaded: false, _metadataInjectionAdapters: [], _injectionAdaptersLoaded: false, - _localesTable: { - 'be@cyrillic': 'be', - bs: 'bs_Latn', - fr_FR: 'fr', - nb: 'nb_NO', - 'sr@cyrillic': 'sr_Cyrl', - 'sr@latin': 'sr_Latn', - 'uz@cyrillic': 'uz', - 'uz@latin': 'uz_Latn', - zh_CN: 'zh_Hans', - }, }, }, publicationTitleAbstractForm: { diff --git a/src/utils/i18n.js b/src/utils/i18n.js index ea8587667..0b66ff9a2 100644 --- a/src/utils/i18n.js +++ b/src/utils/i18n.js @@ -170,14 +170,21 @@ export function localizeSubmission(localizedString, submissionLocale) { * This only maps the locales that need to be translated. * Most PKP locales work fine in Moment.js. * - * @param {String} locale The PKP locale, eg - `sr_RS@cyrillic` + * @param {String} locale The PKP locale, eg - `sr_Cyrl` */ export function getMomentLocale(locale) { + locale.replaceAll('_', '-').toLowerCase(); const map = { - 'sr_RS@latin': 'sr', - 'sr_RS@cyrillic': 'sr-cyrl', - 'uz_UZ@latin': 'uz-latn', + 'bs-latn': 'bs', + hy: 'hy-am', + 'nb-no': 'nb', + oc: 'oc-lnc', + pa: 'pa-in', + 'pt-pt': 'pt', + 'sr-latn': 'sr', + tl: 'tl-ph', + ug: 'ug-cn', + 'zh-hans': 'zh-cn', }; - return map[locale] ?? locale; }