Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-22 09:20:29 +01:00
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 { default as computed, observes } from 'discourse-common/utils/decorators';
|
||||||
import { renderAvatar } from 'discourse/helpers/user-avatar';
|
import { renderAvatar } from 'discourse/helpers/user-avatar';
|
||||||
import userSearch from '../lib/user-search';
|
import userSearch from '../lib/user-search';
|
||||||
import I18n from "I18n";
|
import WizardI18n from "../lib/wizard-i18n";
|
||||||
|
|
||||||
const template = function(params) {
|
const template = function(params) {
|
||||||
const options = params.options;
|
const options = params.options;
|
||||||
|
@ -35,7 +35,7 @@ export default Ember.TextField.extend({
|
||||||
|
|
||||||
@computed("placeholderKey")
|
@computed("placeholderKey")
|
||||||
placeholder(placeholderKey) {
|
placeholder(placeholderKey) {
|
||||||
return placeholderKey ? I18n.t(placeholderKey) : "";
|
return placeholderKey ? WizardI18n(placeholderKey) : "";
|
||||||
},
|
},
|
||||||
|
|
||||||
@observes('usernames')
|
@observes('usernames')
|
||||||
|
|
|
@ -20,6 +20,7 @@ import {
|
||||||
import { cacheShortUploadUrl } from "pretty-text/upload-short-url";
|
import { cacheShortUploadUrl } from "pretty-text/upload-short-url";
|
||||||
import { alias } from "@ember/object/computed";
|
import { alias } from "@ember/object/computed";
|
||||||
import { uploadIcon } from "discourse/lib/uploads";
|
import { uploadIcon } from "discourse/lib/uploads";
|
||||||
|
import WizardI18n from '../lib/wizard-i18n';
|
||||||
|
|
||||||
const uploadMarkdownResolvers = [];
|
const uploadMarkdownResolvers = [];
|
||||||
|
|
||||||
|
@ -103,7 +104,7 @@ export default ComposerEditor.extend({
|
||||||
// Limit the number of simultaneous uploads
|
// Limit the number of simultaneous uploads
|
||||||
if (max > 0 && data.files.length > max) {
|
if (max > 0 && data.files.length > max) {
|
||||||
bootbox.alert(
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import getUrl from "discourse-common/lib/get-url";
|
import getUrl from "discourse-common/lib/get-url";
|
||||||
import { getToken } from "wizard/lib/ajax";
|
import { getToken } from "wizard/lib/ajax";
|
||||||
import I18n from "I18n";
|
import WizardI18n from "../lib/wizard-i18n";
|
||||||
|
|
||||||
export default Ember.Component.extend({
|
export default Ember.Component.extend({
|
||||||
classNames: ["wizard-field-upload"],
|
classNames: ["wizard-field-upload"],
|
||||||
|
@ -41,7 +41,7 @@ export default Ember.Component.extend({
|
||||||
});
|
});
|
||||||
|
|
||||||
$upload.on("fileuploadfail", (e, response) => {
|
$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) {
|
if (response.jqXHR.responseJSON && response.jqXHR.responseJSON.errors) {
|
||||||
message = response.jqXHR.responseJSON.errors.join("\n");
|
message = response.jqXHR.responseJSON.errors.join("\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import computed from "discourse-common/utils/decorators";
|
import computed from "discourse-common/utils/decorators";
|
||||||
import { siteDir, isRTL, isLTR } from "discourse/lib/text-direction";
|
import { siteDir, isRTL, isLTR } from "discourse/lib/text-direction";
|
||||||
import I18n from "I18n";
|
import WizardI18n from "../lib/wizard-i18n";
|
||||||
|
|
||||||
export default Ember.TextField.extend({
|
export default Ember.TextField.extend({
|
||||||
attributeBindings: ['autocorrect', 'autocapitalize', 'autofocus', 'maxLength', 'dir'],
|
attributeBindings: ['autocorrect', 'autocapitalize', 'autofocus', 'maxLength', 'dir'],
|
||||||
|
@ -34,6 +34,6 @@ export default Ember.TextField.extend({
|
||||||
|
|
||||||
@computed("placeholderKey")
|
@computed("placeholderKey")
|
||||||
placeholder(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({
|
export default Ember.Route.extend({
|
||||||
model(params) {
|
model(params) {
|
||||||
|
@ -26,7 +26,7 @@ export default Ember.Route.extend({
|
||||||
if (!model.permitted) {
|
if (!model.permitted) {
|
||||||
props['stepMessage'] = {
|
props['stepMessage'] = {
|
||||||
state: 'not-permitted',
|
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) {
|
if (model.index > 0) {
|
||||||
props['showReset'] = true;
|
props['showReset'] = true;
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
{{#if isUploading}}
|
{{#if isUploading}}
|
||||||
<div id="file-uploading">
|
<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}}
|
{{#if isCancellable}}
|
||||||
<a href id="cancel-file-upload" {{action "cancelUpload"}}>{{d-icon "times"}}</a>
|
<a href id="cancel-file-upload" {{action "cancelUpload"}}>{{d-icon "times"}}</a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
<div class="wizard-composer-hyperlink-contents">
|
<div class="wizard-composer-hyperlink-contents">
|
||||||
<h3>{{i18n "composer.link_dialog_title"}}</h3>
|
<h3>{{wizard-i18n "composer.link_dialog_title"}}</h3>
|
||||||
{{input
|
{{input
|
||||||
class="composer-link-name"
|
class="composer-link-name"
|
||||||
placeholder=(i18n 'composer.link_optional_text')
|
placeholder=(wizard-i18n 'composer.link_optional_text')
|
||||||
type="text"
|
type="text"
|
||||||
value=linkName}}
|
value=linkName}}
|
||||||
{{input
|
{{input
|
||||||
class="composer-link-url"
|
class="composer-link-url"
|
||||||
placeholder=(i18n 'composer.link_url_placeholder')
|
placeholder=(wizard-i18n 'composer.link_url_placeholder')
|
||||||
type="text"
|
type="text"
|
||||||
value=linkUrl}}
|
value=linkUrl}}
|
||||||
{{d-button
|
{{d-button
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
<button class='wizard-btn {{b.className}}' {{action b.action b}} title="{{b.title}}">
|
<button class='wizard-btn {{b.className}}' {{action b.action b}} title="{{b.title}}">
|
||||||
{{d-icon b.icon}}
|
{{d-icon b.icon}}
|
||||||
{{#if b.label}}
|
{{#if b.label}}
|
||||||
<span class="d-button-label">{{i18n b.label}}</span>
|
<span class="d-button-label">{{wizard-i18n b.label}}</span>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</button>
|
</button>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
@ -8,5 +8,5 @@
|
||||||
afterRefresh=(action "afterRefresh")}}
|
afterRefresh=(action "afterRefresh")}}
|
||||||
|
|
||||||
<button class='wizard-btn toggle-preview' {{action 'togglePreview'}}>
|
<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>
|
</button>
|
|
@ -1,8 +1,8 @@
|
||||||
<label class="wizard-btn wizard-btn-upload-file {{if uploading 'disabled'}}">
|
<label class="wizard-btn wizard-btn-upload-file {{if uploading 'disabled'}}">
|
||||||
{{#if uploading}}
|
{{#if uploading}}
|
||||||
{{i18n "wizard.uploading"}}
|
{{wizard-i18n "wizard.uploading"}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{i18n "wizard.upload"}}
|
{{wizard-i18n "wizard.upload"}}
|
||||||
{{d-icon "upload"}}
|
{{d-icon "upload"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<div>{{text}}</div>
|
<div>{{text}}</div>
|
||||||
<div class="no-access-gutter">
|
<div class="no-access-gutter">
|
||||||
<button class='wizard-btn primary return-to-site' {{action 'skip'}}>
|
<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"}}
|
{{d-icon "sign-out"}}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
<div class='white'></div>
|
<div class='white'></div>
|
||||||
<div class='black' style={{barStyle}}></div>
|
<div class='black' style={{barStyle}}></div>
|
||||||
<div class='screen'></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>
|
||||||
|
|
||||||
<div class='wizard-buttons'>
|
<div class='wizard-buttons'>
|
||||||
|
@ -34,23 +34,23 @@
|
||||||
{{loading-spinner size='small'}}
|
{{loading-spinner size='small'}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{#if showQuitButton}}
|
{{#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}}
|
||||||
{{#if showBackButton}}
|
{{#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}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if showNextButton}}
|
{{#if showNextButton}}
|
||||||
<button class='wizard-btn next primary' {{action "nextStep"}} disabled={{saving}} tabindex="10">
|
<button class='wizard-btn next primary' {{action "nextStep"}} disabled={{saving}} tabindex="10">
|
||||||
{{i18n "wizard.next"}}
|
{{wizard-i18n "wizard.next"}}
|
||||||
{{d-icon "chevron-right"}}
|
{{d-icon "chevron-right"}}
|
||||||
</button>
|
</button>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if showDoneButton}}
|
{{#if showDoneButton}}
|
||||||
<button class='wizard-btn done' {{action "done"}} disabled={{saving}} tabindex="10">
|
<button class='wizard-btn done' {{action "done"}} disabled={{saving}} tabindex="10">
|
||||||
{{i18n "wizard.done"}}
|
{{wizard-i18n "wizard.done"}}
|
||||||
</button>
|
</button>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
{{#if noWizard}}
|
{{#if noWizard}}
|
||||||
{{wizard-no-access text=(i18n 'wizard.none') wizardId=wizardId}}
|
{{wizard-no-access text=(wizard-i18n 'wizard.none') wizardId=wizardId}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{#if requiresLogin}}
|
{{#if requiresLogin}}
|
||||||
{{wizard-no-access text=(i18n 'wizard.requires_login') wizardId=wizardId}}
|
{{wizard-no-access text=(wizard-i18n 'wizard.requires_login') wizardId=wizardId}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{#if notPermitted}}
|
{{#if notPermitted}}
|
||||||
{{wizard-no-access text=(i18n 'wizard.not_permitted') wizardId=wizardId}}
|
{{wizard-no-access text=(wizard-i18n 'wizard.not_permitted') wizardId=wizardId}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{#if completed}}
|
{{#if completed}}
|
||||||
{{wizard-no-access text=(i18n 'wizard.completed') wizardId=wizardId}}
|
{{wizard-no-access text=(wizard-i18n 'wizard.completed') wizardId=wizardId}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
</div>
|
</div>
|
||||||
{{#if showReset}}
|
{{#if showReset}}
|
||||||
<a class="reset-wizard" {{action "resetWizard"}}>
|
<a class="reset-wizard" {{action "resetWizard"}}>
|
||||||
{{i18n 'wizard.reset'}}
|
{{wizard-i18n 'wizard.reset'}}
|
||||||
</a>
|
</a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
<%= csrf_meta_tags %>
|
<%= csrf_meta_tags %>
|
||||||
|
|
||||||
<%- unless customization_disabled? %>
|
<%- unless customization_disabled? %>
|
||||||
|
<%= theme_translations_lookup %>
|
||||||
<%= raw theme_lookup("head_tag") %>
|
<%= raw theme_lookup("head_tag") %>
|
||||||
<%- end %>
|
<%- end %>
|
||||||
|
|
||||||
|
|
Laden …
In neuem Issue referenzieren