✨ feat(i18n): implement pluralization logic (#277)
Co-authored-by: welpo <welpo@users.noreply.github.com>
This commit is contained in:

committed by
GitHub

parent
daef40338c
commit
c4893d4fdd
@@ -11,28 +11,21 @@
|
||||
<ul class="tags">
|
||||
{%- for term in terms -%}
|
||||
<li class="tags-item">
|
||||
{%- set number_of_posts = term.pages | length -%}
|
||||
{% if config.extra.compact_tags %}
|
||||
{# 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 -%}">
|
||||
aria-label="{{ term.name }} –
|
||||
{{ term.pages | length }}
|
||||
{{- macros_translate::translate(key="posts", number=number_of_posts, default="$NUMBER posts", language_strings=language_strings) -}}
|
||||
">
|
||||
{{ term.name }}
|
||||
</a> <sup>{{ term.pages | length }}</sup>
|
||||
</a> <sup>{{ number_of_posts }}</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=number_of_posts, default="$NUMBER posts", language_strings=language_strings) -}}
|
||||
{% endif %}
|
||||
</li>
|
||||
{%- endfor -%}
|
||||
|
Reference in New Issue
Block a user