Skip to content

Commit

Permalink
Update translate macro call for plural forms translates
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAwiteb committed Feb 13, 2024
1 parent 5f074c6 commit 13448cb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 28 deletions.
2 changes: 1 addition & 1 deletion templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ <h1 class="article-title">

{# page settings override config settings #}
{% if macros_settings::evaluate_setting_priority(setting="show_reading_time", page=page, default_global_value=true) == "true" %}
{{ separator }} <li title="{{ macros_translate::translate(key="word", number=page.word_count, default=page.word_count ~ " words", language_strings=language_strings) }}">{{ macros_translate::translate(key="min_read", number=page.reading_time, default=page.reading_time ~ " min read", language_strings=language_strings) }}</li>
{{ separator }} <li title="{{ macros_translate::translate(key="words", number=page.word_count, default=page.word_count ~ " words", language_strings=language_strings) }}">{{ macros_translate::translate(key="min_read", number=page.reading_time, default=page.reading_time ~ " min read", language_strings=language_strings) }}</li>
{% endif %}

{%- if page.taxonomies and page.taxonomies.tags -%}
Expand Down
6 changes: 6 additions & 0 deletions templates/partials/search_modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ <h1 id="modalTitle" class="visually-hidden">{{ macros_translate::translate(key='
</div>
</div>
<div id="results-container">
<!--
#TODO(@welpo): This the javascript section I think
so I'll leave it for you to handle.
#NOTE(@welpo): The `key` is "results" for all
(take a look at `i18n/en.toml` in the `results` section)
-->
<div id="results-info">
<span id="n-results">0</span>&nbsp;<span id="result-text-singular">{{ macros_translate::translate(key='result', default='result', language_strings=language_strings) }}</span>
<span id="result-text-plural">{{ macros_translate::translate(key='results', default='results', language_strings=language_strings) }}</span>
Expand Down
18 changes: 5 additions & 13 deletions templates/tags/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,15 @@
<a href="{{ term.permalink | safe }}"
aria-label="{{ term.name }} –
{{ term.pages | length }}
{% if term.pages | length == 1 -%}
{{- macros_translate::translate(key="post", default="post", language_strings=language_strings) -}}
{%- else -%}
{{- macros_translate::translate(key="posts", default="posts", language_strings=language_strings) -}}
{%- endif -%}">
{{- macros_translate::translate(key="posts", number=length, default="posts", language_strings=language_strings) -}}
">
{{ term.name }}
</a> <sup>{{ term.pages | length }}</sup>
{% else %}
<a href="{{ term.permalink | safe }}">
{{ term.name }}</a>
– {{ term.pages | length }}{%- if term.pages | length == 1 %}
{# Only one post. Singular. #}
{{- macros_translate::translate(key="post", default="post", language_strings=language_strings) -}}
{% elif term.pages | length > 1 %}
{# More than one post per tag. Plural. #}
{{- macros_translate::translate(key="posts", default="posts", language_strings=language_strings) -}}
{%- endif -%}
{{ term.name }} </a>
<span></span>
{{- macros_translate::translate(key="posts", number=term.pages | length, default="posts", language_strings=language_strings) -}}
{% endif %}
</li>
{%- endfor -%}
Expand Down
18 changes: 4 additions & 14 deletions templates/taxonomy_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,14 @@
{# Shows the number of posts per tag as a superscript #}
<a href="{{ term.permalink | safe }}"
aria-label="{{ term.name }} –
{{ term.pages | length }}
{% if term.pages | length == 1 -%}
{{- macros_translate::translate(key="post", default="post", language_strings=language_strings) -}}
{%- else -%}
{{- macros_translate::translate(key="posts", default="posts", language_strings=language_strings) -}}
{%- endif -%}">
{{ term.name }}
{{- macros_translate::translate(key="posts", number=length, default="posts", language_strings=language_strings) -}}
{{ term.name }}
</a> <sup>{{ term.pages | length }}</sup>
{% else %}
<a href="{{ term.permalink | safe }}">
{{ term.name }}</a>
– {{ term.pages | length }}{%- if term.pages | length == 1 %}
{# Only one post. Singular. #}
{{- macros_translate::translate(key="post", default="post", language_strings=language_strings) -}}
{% elif term.pages | length > 1 %}
{# More than one post per tag. Plural. #}
{{- macros_translate::translate(key="posts", default="posts", language_strings=language_strings) -}}
{%- endif -%}
– {{ term.pages | length }}
{{- macros_translate::translate(key="posts", number=length, default="posts", language_strings=language_strings) -}}
{% endif %}
</li>
{%- endfor -%}
Expand Down

0 comments on commit 13448cb

Please sign in to comment.