Skip to content

Commit

Permalink
Merge pull request #438 from bozana/9707
Browse files Browse the repository at this point in the history
pkp/pkp-lib#9707 use weblate locales for ui
  • Loading branch information
bozana authored Dec 11, 2024
2 parents 88080f2 + f7bd0ee commit 8395ce0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 32 deletions.
17 changes: 12 additions & 5 deletions src/mixins/localizeMoment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
},
Expand Down
22 changes: 0 additions & 22 deletions src/pages/dashboard/mocks/pageInitConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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: {
Expand Down
17 changes: 12 additions & 5 deletions src/utils/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 8395ce0

Please sign in to comment.