1
0
Fork 0

Update wizard-i18n.js.es6

Dieser Commit ist enthalten in:
Angus McLeod 2022-06-15 09:10:33 +02:00
Ursprung af93a67bb1
Commit 47eed48ad5

Datei anzeigen

@ -13,6 +13,11 @@ const getThemeId = () => {
}
};
const getThemeKey = (key) => {
const themeId = getThemeId();
return `theme_translations.${themeId}.${key}`;
};
const translationExists = (key) => {
return (
I18n.findTranslation(key, { locale: I18n.locale }) ||
@ -20,13 +25,20 @@ const translationExists = (key) => {
);
};
const translatedText = (key, value) => {
const themeKey = getThemeKey(key);
return translationExists(themeKey) ? I18n.t(themeKey) : value;
};
export { translatedText };
const WizardI18n = (key, params = {}) => {
const themeId = getThemeId();
if (!themeId) {
return I18n.t(key, params);
}
const themeKey = `theme_translations.${themeId}.${key}`;
let themeKey = getThemeKey(key);
if (translationExists(themeKey)) {
return I18n.t(themeKey, params);