mirror of
https://github.com/discourse/discourse.git
synced 2024-11-28 18:04:38 +08:00
880311dd4d
- Themes can supply translation files in a format like `/locales/{locale}.yml`. These files should be valid YAML, with a single top level key equal to the locale being defined. For now these can only be defined using the `discourse_theme` CLI, importing a `.tar.gz`, or from a GIT repository. - Fallback is handled on a global level (if the locale is not defined in the theme), as well as on individual keys (if some keys are missing from the selected interface language). - Administrators can override individual keys on a per-theme basis in the /admin/customize/themes user interface. - Theme developers should access defined translations using the new theme prefix variables: JavaScript: `I18n.t(themePrefix("my_translation_key"))` Handlebars: `{{theme-i18n "my_translation_key"}}` or `{{i18n (theme-prefix "my_translation_key")}}` - To design for backwards compatibility, theme developers can check for the presence of the `themePrefix` variable in JavaScript - As part of this, the old `{{themeSetting.setting_name}}` syntax is deprecated in favour of `{{theme-setting "setting_name"}}`
183 lines
7.9 KiB
Handlebars
183 lines
7.9 KiB
Handlebars
<div class="show-current-style">
|
||
<div class="title">
|
||
{{#if editingName}}
|
||
{{text-field value=model.name autofocus="true"}}
|
||
{{d-button action=(action "finishedEditingName") class="btn-primary submit-edit" icon="check"}}
|
||
{{d-button action=(action "cancelEditingName") class="btn-default cancel-edit" icon="times"}}
|
||
{{else}}
|
||
{{model.name}} <a {{action "startEditingName"}}>{{d-icon "pencil"}}</a>
|
||
{{/if}}
|
||
</div>
|
||
|
||
{{#each model.errors as |error|}}
|
||
<div class="alert alert-error">
|
||
<button class="close" data-dismiss="alert">×</button>
|
||
{{error}}
|
||
</div>
|
||
{{/each}}
|
||
|
||
{{#if model.remote_theme}}
|
||
{{#if model.remote_theme.remote_url}}
|
||
<a class="remote-url" href="{{model.remote_theme.remote_url}}">{{model.remote_theme.remote_url}}</a>
|
||
{{/if}}
|
||
<a class="url about-url" href="{{model.remote_theme.about_url}}">{{i18n "admin.customize.theme.about_theme"}}</a>
|
||
{{#if model.remote_theme.license_url}}
|
||
<a class="url license-url" href="{{model.remote_theme.license_url}}">{{i18n "admin.customize.theme.license"}} {{d-icon "copyright"}}</a>
|
||
{{/if}}
|
||
{{/if}}
|
||
|
||
{{#if parentThemes}}
|
||
<div class="control-unit">
|
||
<div class="mini-title">{{i18n "admin.customize.theme.component_of"}}</div>
|
||
<ul>
|
||
{{#each parentThemes as |theme|}}
|
||
<li>{{#link-to 'adminCustomizeThemes.show' theme replace=true}}{{theme.name}}{{/link-to}}</li>
|
||
{{/each}}
|
||
</ul>
|
||
</div>
|
||
{{/if}}
|
||
|
||
{{#unless model.component}}
|
||
<div class="control-unit">
|
||
{{inline-edit-checkbox action=(action "applyDefault") labelKey="admin.customize.theme.is_default" checked=model.default}}
|
||
{{inline-edit-checkbox action=(action "applyUserSelectable") labelKey="admin.customize.theme.user_selectable" checked=model.user_selectable}}
|
||
</div>
|
||
|
||
<div class="control-unit">
|
||
<div class="mini-title">{{i18n "admin.customize.theme.color_scheme"}}</div>
|
||
<div class="description">{{i18n "admin.customize.theme.color_scheme_select"}}</div>
|
||
<div class="control">{{combo-box content=colorSchemes
|
||
filterable=true
|
||
forceEscape=true
|
||
value=colorSchemeId
|
||
icon="paint-brush"}}
|
||
{{#if colorSchemeChanged}}
|
||
{{d-button action=(action "changeScheme") class="btn-primary submit-edit" icon="check"}}
|
||
{{d-button action=(action "cancelChangeScheme") class="btn-default cancel-edit" icon="times"}}
|
||
{{/if}}
|
||
</div>
|
||
{{#link-to 'adminCustomize.colors' class="btn btn-default edit"}}{{i18n 'admin.customize.colors.edit'}}{{/link-to}}
|
||
</div>
|
||
{{/unless}}
|
||
|
||
<div class="control-unit">
|
||
<div class="mini-title">{{i18n "admin.customize.theme.css_html"}}</div>
|
||
{{#if model.hasEditedFields}}
|
||
<div class="description">{{i18n "admin.customize.theme.custom_sections"}}</div>
|
||
<ul>
|
||
{{#each editedFieldsFormatted as |field|}}
|
||
<li>{{field}}</li>
|
||
{{/each}}
|
||
</ul>
|
||
{{else}}
|
||
<div class="description">
|
||
{{i18n "admin.customize.theme.edit_css_html_help"}}
|
||
</div>
|
||
{{/if}}
|
||
|
||
{{#if model.remote_theme}}
|
||
{{#if model.remote_theme.commits_behind}}
|
||
{{#d-button action=(action "updateToLatest") icon="download" class='btn-primary'}}{{i18n "admin.customize.theme.update_to_latest"}}{{/d-button}}
|
||
{{else}}
|
||
{{#d-button action=(action "checkForThemeUpdates") icon="refresh" class="btn-default"}}{{i18n "admin.customize.theme.check_for_updates"}}{{/d-button}}
|
||
{{/if}}
|
||
{{/if}}
|
||
|
||
{{#d-button action=(action "editTheme") class="btn btn-default edit"}}{{i18n 'admin.customize.theme.edit_css_html'}}{{/d-button}}
|
||
{{#if model.remote_theme}}
|
||
<span class='status-message'>
|
||
{{#if updatingRemote}}
|
||
{{i18n 'admin.customize.theme.updating'}}
|
||
{{else}}
|
||
{{#if model.remote_theme.commits_behind}}
|
||
{{i18n 'admin.customize.theme.commits_behind' count=model.remote_theme.commits_behind}}
|
||
{{#if model.remote_theme.github_diff_link}}
|
||
<a href="{{model.remote_theme.github_diff_link}}">
|
||
{{i18n 'admin.customize.theme.compare_commits'}}
|
||
</a>
|
||
{{/if}}
|
||
{{else}}
|
||
{{#unless showRemoteError}}
|
||
{{i18n 'admin.customize.theme.up_to_date'}} {{format-date model.remote_theme.updated_at leaveAgo="true"}}
|
||
{{/unless}}
|
||
{{/if}}
|
||
{{/if}}
|
||
</span>
|
||
{{#if showRemoteError}}
|
||
<div class="error-message">
|
||
{{d-icon "exclamation-triangle"}} {{I18n "admin.customize.theme.repo_unreachable"}}
|
||
</div>
|
||
<div class="raw-error">
|
||
<code>{{model.remoteError}}</code>
|
||
</div>
|
||
{{/if}}
|
||
{{/if}}
|
||
</div>
|
||
|
||
<div class="control-unit">
|
||
<div class="mini-title">{{i18n "admin.customize.theme.uploads"}}</div>
|
||
{{#if model.uploads}}
|
||
<ul class='removable-list'>
|
||
{{#each model.uploads as |upload|}}
|
||
<li>
|
||
<span class='col'>${{upload.name}}: <a href={{upload.url}} target='_blank'>{{upload.filename}}</a></span>
|
||
<span class='col'>
|
||
{{d-button action=(action "removeUpload") actionParam=upload class="second btn-default btn-default cancel-edit" icon="times"}}
|
||
</span>
|
||
</li>
|
||
{{/each}}
|
||
</ul>
|
||
{{else}}
|
||
<div class="description">{{i18n "admin.customize.theme.no_uploads"}}</div>
|
||
{{/if}}
|
||
{{#d-button action=(action "addUploadModal") class="btn-default" icon="plus"}}{{i18n "admin.customize.theme.add"}}{{/d-button}}
|
||
</div>
|
||
|
||
{{#if hasSettings}}
|
||
<div class="control-unit">
|
||
<div class="mini-title">{{i18n "admin.customize.theme.theme_settings"}}</div>
|
||
{{#d-section class="form-horizontal theme settings"}}
|
||
{{#each settings as |setting|}}
|
||
{{theme-setting-editor setting=setting model=model class="theme-setting"}}
|
||
{{/each}}
|
||
{{/d-section}}
|
||
</div>
|
||
{{/if}}
|
||
|
||
{{#if hasTranslations}}
|
||
<div class="control-unit">
|
||
<div class="mini-title">{{i18n "admin.customize.theme.theme_translations"}}</div>
|
||
{{#d-section class="form-horizontal theme settings translations"}}
|
||
{{#each translations as |translation|}}
|
||
{{theme-translation translation=translation model=model class="theme-translation"}}
|
||
{{/each}}
|
||
{{/d-section}}
|
||
</div>
|
||
{{/if}}
|
||
|
||
{{#if availableChildThemes}}
|
||
<div class="control-unit">
|
||
<div class="mini-title">{{i18n "admin.customize.theme.theme_components"}}</div>
|
||
{{#if model.childThemes.length}}
|
||
<ul class='removable-list'>
|
||
{{#each model.childThemes as |child|}}
|
||
<li>{{#link-to 'adminCustomizeThemes.show' child replace=true class='col'}}{{child.name}}{{/link-to}} {{d-button action=(action "removeChildTheme") actionParam=child class="btn-default cancel-edit col" icon="times"}}</li>
|
||
{{/each}}
|
||
</ul>
|
||
{{/if}}
|
||
{{#if selectableChildThemes}}
|
||
<div class="description">
|
||
{{combo-box forceEscape=true filterable=true content=selectableChildThemes value=selectedChildThemeId none="admin.customize.theme.select_component"}}
|
||
{{#d-button action=(action "addChildTheme") icon="plus" disabled=addButtonDisabled class="btn-default add-component-button"}}{{i18n "admin.customize.theme.add"}}{{/d-button}}
|
||
</div>
|
||
{{/if}}
|
||
</div>
|
||
{{/if}}
|
||
|
||
<a href='{{previewUrl}}' title="{{i18n 'admin.customize.explain_preview'}}" target='_blank' class='btn btn-default'>{{d-icon 'desktop'}}{{i18n 'admin.customize.theme.preview'}}</a>
|
||
<a class="btn btn-default export" target="_blank" href={{downloadUrl}}>{{d-icon "download"}} {{i18n 'admin.export_json.button_text'}}</a>
|
||
|
||
{{d-button action=(action "switchType") label="admin.customize.theme.convert" icon=convertIcon class="btn-default btn-normal" title=convertTooltip}}
|
||
{{d-button action=(action "destroy") label="admin.customize.delete" icon="trash" class="btn-danger"}}
|
||
</div>
|