Skip to content

Commit

Permalink
feat(glossary): visually differentiate explanation
Browse files Browse the repository at this point in the history
- color highlight whole block including explanation row to make
  groupping clear
- use badge for rendering explanation

See #11486
Related to #9082
  • Loading branch information
nijel committed May 3, 2024
1 parent eebafdd commit cf8e73a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 10 deletions.
2 changes: 2 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Not yet released.

**Improvements**

* Visually highlight explanation in :ref:`glossary`.

**Bug fixes**

**Compatibility**
Expand Down
2 changes: 1 addition & 1 deletion weblate/static/editor/full.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@

FullEditor.prototype.initGlossary = function () {
/* Copy from glossary */
this.$editor.on("click", ".glossary-embed.clickable-row", (e) => {
this.$editor.on("click", ".glossary-embed", (e) => {
/* Avoid copy when clicked on a link */
if ($(e.target).parents("a").length > 0) {
return;
Expand Down
10 changes: 10 additions & 0 deletions weblate/static/style-bootstrap.css
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,9 @@ th.number {
.clickable-row {
cursor: pointer;
}
.unclickable-row {
cursor: not-allowed;
}

.clickable-row:hover {
background-color: #e9eaec;
Expand Down Expand Up @@ -1988,3 +1991,10 @@ label .text-muted {
background-color: #ccc;
margin-bottom: 0;
}

tbody.danger {
background-color: #f2dede;
}
tbody.warning {
background-color: #fcf8e3;
}
6 changes: 6 additions & 0 deletions weblate/static/style-dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -2659,3 +2659,9 @@ a.language:hover {
.editor-wrap > .highlighted-output.readonly {
background-color: inherit;
}
tbody.danger {
background-color: rgb(62, 24, 24);
}
tbody.warning {
background-color: rgb(64, 54, 7);
}
20 changes: 11 additions & 9 deletions weblate/templates/snippets/glossary.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
{% load icons %}

{% for item in glossary %}
<tbody class="glossary-embed {% if "forbidden" in item.all_flags %}unclickable-row danger{% elif "read-only" in item.all_flags %}clickable-row warning{% else %}clickable-row{% endif %}">
{% if "forbidden" in item.all_flags %}
<tr class="glossary-embed danger" title="{% trans "This translation is forbidden." %}">
<tr title="{% trans "This translation is forbidden." %}">
{% elif "read-only" in item.all_flags %}
<tr class="glossary-embed clickable-row warning" title="{% trans "This term should not be translated." %}">
<tr title="{% trans "This term should not be translated." %}">
{% else %}
<tr class="glossary-embed clickable-row" title="{% trans "Copy word into translation" %}">
<tr title="{% trans "Copy word into translation" %}">
{% endif %}
<td class="source">{{ item.source }}</td>
<td class="target">
Expand All @@ -25,30 +26,31 @@
{% if item.note %}
<tr>
<td colspan="4">
<em>
<span class="badge" title="{% trans "Source string description" %}">
{{ item.note }}
</em>
</span>
</td>
</tr>
{% endif %}
{% if not item.is_source and item.explanation %}
<tr>
<td colspan="4">
<em>
<span class="badge" title="{% trans "Glossary translation explanation" %}">
{{ item.explanation|markdown }}
</em>
</span>
</td>
</tr>
{% endif %}
{% if item.source_unit.explanation %}
<tr>
<td colspan="4">
<em>
<span class="badge" title="{% trans "Glossary string explanation" %}">
{{ item.source_unit.explanation|markdown }}
</em>
</span>
</td>
</tr>
{% endif %}
</tbody>
{% empty %}
<tr>
<td colspan="4"><em>{% trans "No related strings found in the glossary." %}</em></td>
Expand Down

0 comments on commit cf8e73a

Please sign in to comment.