Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,11 @@
// before initializing the form container load all the locale specific json resources
// for runtime
const formLanguage = formContainer.getLang();
const aemLangUrl = `/etc.clientlibs/core/fd/af-clientlibs/core-forms-components-runtime-all/resources/i18n/${formLanguage}.json`;
await FormView.LanguageUtils.loadLang(formLanguage, aemLangUrl, true);
// Only load locale if it's a valid product locale
if (FormView.LanguageUtils.isProductLocale(formLanguage)) {
const aemLangUrl = `/etc.clientlibs/core/fd/af-clientlibs/core-forms-components-runtime-all/resources/i18n/${formLanguage}.json`;
await FormView.LanguageUtils.loadLang(formLanguage, aemLangUrl, true);
}
formContainer.subscribe();
return formContainer;
}, FormContainerV2.selectors.self, FormContainerV2.IS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,11 @@
// before initializing the form container load all the locale specific json resources
// for runtime
const formLanguage = formContainer.getLang();
const aemLangUrl = `/etc.clientlibs/core/fd/af-clientlibs/core-forms-components-runtime-all/resources/i18n/${formLanguage}.json`;
await FormView.LanguageUtils.loadLang(formLanguage, aemLangUrl, true);
// Only load locale if it's a valid product locale
if (FormView.LanguageUtils.isProductLocale(formLanguage)) {
const aemLangUrl = `/etc.clientlibs/core/fd/af-clientlibs/core-forms-components-runtime-all/resources/i18n/${formLanguage}.json`;
await FormView.LanguageUtils.loadLang(formLanguage, aemLangUrl, true);
}
formContainer.subscribe();
return formContainer;
}, FormContainerV2.selectors.self, FormContainerV2.IS);
Expand Down
10 changes: 9 additions & 1 deletion ui.frontend/src/LanguageUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,15 @@ class LanguageUtils {
}
}


/**
* Check if the given locale is a valid product locale.
* @param {string} lang - The language code to check.
* @returns {boolean} True if the locale is a valid product locale, false otherwise.
*/
static isProductLocale(lang) {
const productLocales = ['en', 'de', 'es', 'fr', 'it', 'ja', 'ko-kr', 'pt-br', 'zh-cn', 'zh-tw'];
return productLocales.includes(lang);
}

/**
* Returns the translated string for the given language and key.
Expand Down
Loading