Allow wizard i18n to be overridden by wizard theme i18n
Dieser Commit ist enthalten in:
Ursprung
f31054f75d
Commit
3bff13492f
17 geänderte Dateien mit 67 neuen und 28 gelöschten Zeilen
|
@ -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')
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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) : "";
|
||||
}
|
||||
});
|
||||
|
|
6
assets/javascripts/wizard/helpers/wizard-i18n.js.es6
Normale Datei
6
assets/javascripts/wizard/helpers/wizard-i18n.js.es6
Normale Datei
|
@ -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);
|
||||
});
|
31
assets/javascripts/wizard/lib/wizard-i18n.js.es6
Normale Datei
31
assets/javascripts/wizard/lib/wizard-i18n.js.es6
Normale Datei
|
@ -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;
|
|
@ -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;
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
{{#if isUploading}}
|
||||
<div id="file-uploading">
|
||||
{{loading-spinner size="small"}}<span>{{i18n "upload_selector.uploading"}} {{uploadProgress}}%</span>
|
||||
{{loading-spinner size="small"}}<span>{{wizard-i18n "upload_selector.uploading"}} {{uploadProgress}}%</span>
|
||||
{{#if isCancellable}}
|
||||
<a href id="cancel-file-upload" {{action "cancelUpload"}}>{{d-icon "times"}}</a>
|
||||
{{/if}}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<div class="wizard-composer-hyperlink-contents">
|
||||
<h3>{{i18n "composer.link_dialog_title"}}</h3>
|
||||
<h3>{{wizard-i18n "composer.link_dialog_title"}}</h3>
|
||||
{{input
|
||||
class="composer-link-name"
|
||||
placeholder=(i18n 'composer.link_optional_text')
|
||||
placeholder=(wizard-i18n 'composer.link_optional_text')
|
||||
type="text"
|
||||
value=linkName}}
|
||||
{{input
|
||||
class="composer-link-url"
|
||||
placeholder=(i18n 'composer.link_url_placeholder')
|
||||
placeholder=(wizard-i18n 'composer.link_url_placeholder')
|
||||
type="text"
|
||||
value=linkUrl}}
|
||||
{{d-button
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
<button class='wizard-btn {{b.className}}' {{action b.action b}} title="{{b.title}}">
|
||||
{{d-icon b.icon}}
|
||||
{{#if b.label}}
|
||||
<span class="d-button-label">{{i18n b.label}}</span>
|
||||
<span class="d-button-label">{{wizard-i18n b.label}}</span>
|
||||
{{/if}}
|
||||
</button>
|
||||
{{/if}}
|
||||
|
|
|
@ -8,5 +8,5 @@
|
|||
afterRefresh=(action "afterRefresh")}}
|
||||
|
||||
<button class='wizard-btn toggle-preview' {{action 'togglePreview'}}>
|
||||
<span class="d-button-label">{{i18n togglePreviewLabel}}</span>
|
||||
<span class="d-button-label">{{wizard-i18n togglePreviewLabel}}</span>
|
||||
</button>
|
|
@ -1,8 +1,8 @@
|
|||
<label class="wizard-btn wizard-btn-upload-file {{if uploading 'disabled'}}">
|
||||
{{#if uploading}}
|
||||
{{i18n "wizard.uploading"}}
|
||||
{{wizard-i18n "wizard.uploading"}}
|
||||
{{else}}
|
||||
{{i18n "wizard.upload"}}
|
||||
{{wizard-i18n "wizard.upload"}}
|
||||
{{d-icon "upload"}}
|
||||
{{/if}}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div>{{text}}</div>
|
||||
<div class="no-access-gutter">
|
||||
<button class='wizard-btn primary return-to-site' {{action 'skip'}}>
|
||||
{{i18n 'wizard.return_to_site' siteName=siteName}}
|
||||
{{wizard-i18n 'wizard.return_to_site' siteName=siteName}}
|
||||
{{d-icon "sign-out"}}
|
||||
</button>
|
||||
</div>
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
<div class='white'></div>
|
||||
<div class='black' style={{barStyle}}></div>
|
||||
<div class='screen'></div>
|
||||
<span>{{bound-i18n "wizard.step" current=step.displayIndex total=wizard.totalSteps}}</span>
|
||||
<span>{{wizard-i18n "wizard.step" current=step.displayIndex total=wizard.totalSteps}}</span>
|
||||
</div>
|
||||
|
||||
<div class='wizard-buttons'>
|
||||
|
@ -34,23 +34,23 @@
|
|||
{{loading-spinner size='small'}}
|
||||
{{else}}
|
||||
{{#if showQuitButton}}
|
||||
<a href {{action "quit"}} class='action-link quit' tabindex="11">{{i18n "wizard.quit"}}</a>
|
||||
<a href {{action "quit"}} class='action-link quit' tabindex="11">{{wizard-i18n "wizard.quit"}}</a>
|
||||
{{/if}}
|
||||
{{#if showBackButton}}
|
||||
<a href {{action "backStep"}} class='action-link back' tabindex="11">{{i18n "wizard.back"}}</a>
|
||||
<a href {{action "backStep"}} class='action-link back' tabindex="11">{{wizard-i18n "wizard.back"}}</a>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{#if showNextButton}}
|
||||
<button class='wizard-btn next primary' {{action "nextStep"}} disabled={{saving}} tabindex="10">
|
||||
{{i18n "wizard.next"}}
|
||||
{{wizard-i18n "wizard.next"}}
|
||||
{{d-icon "chevron-right"}}
|
||||
</button>
|
||||
{{/if}}
|
||||
|
||||
{{#if showDoneButton}}
|
||||
<button class='wizard-btn done' {{action "done"}} disabled={{saving}} tabindex="10">
|
||||
{{i18n "wizard.done"}}
|
||||
{{wizard-i18n "wizard.done"}}
|
||||
</button>
|
||||
{{/if}}
|
||||
</div>
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
{{#if noWizard}}
|
||||
{{wizard-no-access text=(i18n 'wizard.none') wizardId=wizardId}}
|
||||
{{wizard-no-access text=(wizard-i18n 'wizard.none') wizardId=wizardId}}
|
||||
{{else}}
|
||||
{{#if requiresLogin}}
|
||||
{{wizard-no-access text=(i18n 'wizard.requires_login') wizardId=wizardId}}
|
||||
{{wizard-no-access text=(wizard-i18n 'wizard.requires_login') wizardId=wizardId}}
|
||||
{{else}}
|
||||
{{#if notPermitted}}
|
||||
{{wizard-no-access text=(i18n 'wizard.not_permitted') wizardId=wizardId}}
|
||||
{{wizard-no-access text=(wizard-i18n 'wizard.not_permitted') wizardId=wizardId}}
|
||||
{{else}}
|
||||
{{#if completed}}
|
||||
{{wizard-no-access text=(i18n 'wizard.completed') wizardId=wizardId}}
|
||||
{{wizard-no-access text=(wizard-i18n 'wizard.completed') wizardId=wizardId}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
</div>
|
||||
{{#if showReset}}
|
||||
<a class="reset-wizard" {{action "resetWizard"}}>
|
||||
{{i18n 'wizard.reset'}}
|
||||
{{wizard-i18n 'wizard.reset'}}
|
||||
</a>
|
||||
{{/if}}
|
||||
</div>
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
<%= csrf_meta_tags %>
|
||||
|
||||
<%- unless customization_disabled? %>
|
||||
<%= theme_translations_lookup %>
|
||||
<%= raw theme_lookup("head_tag") %>
|
||||
<%- end %>
|
||||
|
||||
|
|
Laden …
In neuem Issue referenzieren