Skip to content

Commit

Permalink
Better translation icon tooltips
Browse files Browse the repository at this point in the history
resolves #2808
  • Loading branch information
brandonkelly committed Apr 25, 2018
1 parent a4c1b71 commit 9edf6d1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG-v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

### Changed
- Fields’ translation icons now reveal the chosen Translation Method in their tooltip. ([#2808](https://github.com/craftcms/cms/issues/2808))
- Improved the error messages displayed when an Assets field has an invalid Upload Location setting. ([#2803](https://github.com/craftcms/cms/issues/2803))

### Fixed
Expand Down
12 changes: 12 additions & 0 deletions src/templates/_includes/field.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@
{% set translatable = field.getIsTranslatable(element) %}
{% set siteId = (translatable and (element.isLocalized() ?? true)) ? (siteId ?? element.siteId ?? craft.app.sites.currentSite.id) %}

{% if translatable %}
{% switch field.translationMethod %}
{% case 'site' %}
{% set translationDescription = 'This field is translated for each site.'|t('app') %}
{% case 'siteGroup' %}
{% set translationDescription = 'This field is translated for each site group.'|t('app') %}
{% case 'language' %}
{% set translationDescription = 'This field is translated for each language.'|t('app') %}
{% endswitch %}
{% endif %}

{% if not static %}
{% set input = field.getInputHtml(value, element) %}
{% else %}
Expand All @@ -17,6 +28,7 @@
{% embed "_includes/forms/field" with {
label: field.name|t('site')|e,
translatable: translatable,
translationDescription: translationDescription ?? null,
siteId: siteId,
required: (not static ? required : false),
instructions: instructions|e,
Expand Down
2 changes: 1 addition & 1 deletion src/templates/_includes/forms/field.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
{% if label %}
<label {% if labelId %} id="{{ labelId }}"{% endif %}{% if required is defined and required %} class="required"{% endif %}{% if id is defined and id %} for="{{ id }}"{% endif %}>
{{- label|raw -}}
{%- if translatable %} <span class="extralight" data-icon="language" title="{{ 'This field is translatable.'|t('app') }}"></span>{% endif -%}
{%- if translatable %} <span class="extralight" data-icon="language" title="{{ translationDescription ?? 'This field is translatable.'|t('app') }}"></span>{% endif -%}
</label>
{% endif %}
{% if instructions %}
Expand Down

0 comments on commit 9edf6d1

Please sign in to comment.