perf(categories): support singular and plural forms of locale (#595)

resolves #595
This commit is contained in:
Cotes Chung 2022-06-08 05:00:59 +08:00
parent cc6398c104
commit 35cadf969d
No known key found for this signature in database
GPG Key ID: 0D9E54843167A808
2 changed files with 31 additions and 6 deletions

View File

@ -75,5 +75,9 @@ post:
# categories page
categories:
category_measure: categories
post_measure: posts
category_measure:
singular: category
plural: categories
post_measure:
singular: post
plural: posts

View File

@ -47,10 +47,24 @@ layout: page
<span class="text-muted small font-weight-light">
{% if sub_categories_size > 0 %}
{{ sub_categories_size }}
{{ site.data.locales[lang].categories.category_measure }},
{% if sub_categories_size > 1 %}
{{ site.data.locales[lang].categories.category_measure.plural
| default: site.data.locales[lang].categories.category_measure }}
{% else %}
{{ site.data.locales[lang].categories.category_measure.singular
| default: site.data.locales[lang].categories.category_measure }}
{% endif %},
{% endif %}
{{ top_posts_size }}
{% if top_posts_size > 1 %}
{{ site.data.locales[lang].categories.post_measure.plural
| default: site.data.locales[lang].categories.post_measure }}
{% else %}
{{ site.data.locales[lang].categories.post_measure.singular
| default: site.data.locales[lang].categories.post_measure }}
{% endif %}
{{ top_posts_size }}
{{ site.data.locales[lang].categories.post_measure }}
</span>
</span>
@ -83,7 +97,14 @@ layout: page
{% assign posts_size = site.categories[sub_category] | size %}
<span class="text-muted small font-weight-light">
{{ posts_size }}
{{ site.data.locales[lang].categories.post_measure }}
{% if posts_size > 1 %}
{{ site.data.locales[lang].categories.post_measure.plural
| default: site.data.locales[lang].categories.post_measure }}
{% else %}
{{ site.data.locales[lang].categories.post_measure.singular
| default: site.data.locales[lang].categories.post_measure }}
{% endif %}
</span>
</li>
{% endfor %}