0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-26 11:00:28 +01:00

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) => { const translationExists = (key) => {
return ( return (
I18n.findTranslation(key, { locale: I18n.locale }) || 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 WizardI18n = (key, params = {}) => {
const themeId = getThemeId(); const themeId = getThemeId();
if (!themeId) { if (!themeId) {
return I18n.t(key, params); return I18n.t(key, params);
} }
const themeKey = `theme_translations.${themeId}.${key}`; let themeKey = getThemeKey(key);
if (translationExists(themeKey)) { if (translationExists(themeKey)) {
return I18n.t(themeKey, params); return I18n.t(themeKey, params);