diff --git a/assets/javascripts/wizard/components/custom-user-selector.js.es6 b/assets/javascripts/wizard/components/custom-user-selector.js.es6 index dfc45604..6ca5698d 100644 --- a/assets/javascripts/wizard/components/custom-user-selector.js.es6 +++ b/assets/javascripts/wizard/components/custom-user-selector.js.es6 @@ -1,7 +1,7 @@ import { default as computed, observes } from 'discourse-common/utils/decorators'; import { renderAvatar } from 'discourse/helpers/user-avatar'; import userSearch from '../lib/user-search'; -import I18n from "I18n"; +import WizardI18n from "../lib/wizard-i18n"; const template = function(params) { const options = params.options; @@ -35,7 +35,7 @@ export default Ember.TextField.extend({ @computed("placeholderKey") placeholder(placeholderKey) { - return placeholderKey ? I18n.t(placeholderKey) : ""; + return placeholderKey ? WizardI18n(placeholderKey) : ""; }, @observes('usernames') diff --git a/assets/javascripts/wizard/components/wizard-composer-editor.js.es6 b/assets/javascripts/wizard/components/wizard-composer-editor.js.es6 index 2da0e4a6..3689588a 100644 --- a/assets/javascripts/wizard/components/wizard-composer-editor.js.es6 +++ b/assets/javascripts/wizard/components/wizard-composer-editor.js.es6 @@ -20,6 +20,7 @@ import { import { cacheShortUploadUrl } from "pretty-text/upload-short-url"; import { alias } from "@ember/object/computed"; import { uploadIcon } from "discourse/lib/uploads"; +import WizardI18n from '../lib/wizard-i18n'; const uploadMarkdownResolvers = []; @@ -103,7 +104,7 @@ export default ComposerEditor.extend({ // Limit the number of simultaneous uploads if (max > 0 && data.files.length > max) { bootbox.alert( - I18n.t("post.errors.too_many_dragged_and_dropped_files", { max }) + WizardI18n("post.errors.too_many_dragged_and_dropped_files", { max }) ); return false; } diff --git a/assets/javascripts/wizard/components/wizard-field-upload.js.es6 b/assets/javascripts/wizard/components/wizard-field-upload.js.es6 index 2241c940..5eefce9a 100644 --- a/assets/javascripts/wizard/components/wizard-field-upload.js.es6 +++ b/assets/javascripts/wizard/components/wizard-field-upload.js.es6 @@ -1,6 +1,6 @@ import getUrl from "discourse-common/lib/get-url"; import { getToken } from "wizard/lib/ajax"; -import I18n from "I18n"; +import WizardI18n from "../lib/wizard-i18n"; export default Ember.Component.extend({ classNames: ["wizard-field-upload"], @@ -41,7 +41,7 @@ export default Ember.Component.extend({ }); $upload.on("fileuploadfail", (e, response) => { - let message = I18n.t("wizard.upload_error"); + let message = WizardI18n("wizard.upload_error"); if (response.jqXHR.responseJSON && response.jqXHR.responseJSON.errors) { message = response.jqXHR.responseJSON.errors.join("\n"); } diff --git a/assets/javascripts/wizard/components/wizard-text-field.js.es6 b/assets/javascripts/wizard/components/wizard-text-field.js.es6 index 8e4570a7..a05b84e6 100644 --- a/assets/javascripts/wizard/components/wizard-text-field.js.es6 +++ b/assets/javascripts/wizard/components/wizard-text-field.js.es6 @@ -2,7 +2,7 @@ import computed from "discourse-common/utils/decorators"; import { siteDir, isRTL, isLTR } from "discourse/lib/text-direction"; -import I18n from "I18n"; +import WizardI18n from "../lib/wizard-i18n"; export default Ember.TextField.extend({ attributeBindings: ['autocorrect', 'autocapitalize', 'autofocus', 'maxLength', 'dir'], @@ -34,6 +34,6 @@ export default Ember.TextField.extend({ @computed("placeholderKey") placeholder(placeholderKey) { - return placeholderKey ? I18n.t(placeholderKey) : ""; + return placeholderKey ? WizardI18n(placeholderKey) : ""; } }); diff --git a/assets/javascripts/wizard/helpers/wizard-i18n.js.es6 b/assets/javascripts/wizard/helpers/wizard-i18n.js.es6 new file mode 100644 index 00000000..f357cc5b --- /dev/null +++ b/assets/javascripts/wizard/helpers/wizard-i18n.js.es6 @@ -0,0 +1,6 @@ +import { registerUnbound } from 'discourse-common/lib/helpers'; +import WizardI18n from '../lib/wizard-i18n'; + +export default registerUnbound("wizard-i18n", (key, params) => { + return WizardI18n(key, params); +}); \ No newline at end of file diff --git a/assets/javascripts/wizard/lib/wizard-i18n.js.es6 b/assets/javascripts/wizard/lib/wizard-i18n.js.es6 new file mode 100644 index 00000000..4d78bc7e --- /dev/null +++ b/assets/javascripts/wizard/lib/wizard-i18n.js.es6 @@ -0,0 +1,31 @@ +import I18n from "I18n"; + +const getThemeId = () => { + let themeId = parseInt($("meta[name=discourse_theme_ids]")[0].content, 10); + + if (!isNaN(themeId)) { + return themeId.toString(); + } else { + return null; + } +} + +const translationExists = (key) => { + return I18n.findTranslation(key, { locale: I18n.locale }) || + I18n.findTranslation(key, { locale: I18n.defaultLocale }); +} + +const WizardI18n = (key, params={}) => { + const themeId = getThemeId(); + if (!themeId) return I18n.t(key, params); + + const themeKey = `theme_translations.${themeId}.${key}`; + + if (translationExists(themeKey)) { + return I18n.t(themeKey, params); + } else { + return I18n.t(key, params); + } +} + +export default WizardI18n; \ No newline at end of file diff --git a/assets/javascripts/wizard/routes/custom-step.js.es6 b/assets/javascripts/wizard/routes/custom-step.js.es6 index 72dd5263..627da6a1 100644 --- a/assets/javascripts/wizard/routes/custom-step.js.es6 +++ b/assets/javascripts/wizard/routes/custom-step.js.es6 @@ -1,4 +1,4 @@ -import I18n from "I18n"; +import WizardI18n from "../lib/wizard-i18n"; export default Ember.Route.extend({ model(params) { @@ -26,7 +26,7 @@ export default Ember.Route.extend({ if (!model.permitted) { props['stepMessage'] = { state: 'not-permitted', - text: model.permitted_message || I18n.t('wizard.step_not_permitted') + text: model.permitted_message || WizardI18n('wizard.step_not_permitted') }; if (model.index > 0) { props['showReset'] = true; diff --git a/assets/javascripts/wizard/templates/components/wizard-composer-editor.hbs b/assets/javascripts/wizard/templates/components/wizard-composer-editor.hbs index 5e6cdb7f..28c697ce 100644 --- a/assets/javascripts/wizard/templates/components/wizard-composer-editor.hbs +++ b/assets/javascripts/wizard/templates/components/wizard-composer-editor.hbs @@ -31,7 +31,7 @@ {{#if isUploading}}