Skip to content

Commit 47eed48

Browse files
committed
Update wizard-i18n.js.es6
1 parent af93a67 commit 47eed48

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

assets/javascripts/wizard/lib/wizard-i18n.js.es6

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,32 @@ const getThemeId = () => {
1313
}
1414
};
1515

16+
const getThemeKey = (key) => {
17+
const themeId = getThemeId();
18+
return `theme_translations.${themeId}.${key}`;
19+
};
20+
1621
const translationExists = (key) => {
1722
return (
1823
I18n.findTranslation(key, { locale: I18n.locale }) ||
1924
I18n.findTranslation(key, { locale: I18n.defaultLocale })
2025
);
2126
};
2227

28+
const translatedText = (key, value) => {
29+
const themeKey = getThemeKey(key);
30+
return translationExists(themeKey) ? I18n.t(themeKey) : value;
31+
};
32+
33+
export { translatedText };
34+
2335
const WizardI18n = (key, params = {}) => {
2436
const themeId = getThemeId();
2537
if (!themeId) {
2638
return I18n.t(key, params);
2739
}
2840

29-
const themeKey = `theme_translations.${themeId}.${key}`;
41+
let themeKey = getThemeKey(key);
3042

3143
if (translationExists(themeKey)) {
3244
return I18n.t(themeKey, params);

0 commit comments

Comments
 (0)