mirror of https://gitlab.com/tildes/tildes.git
Browse Source
Templates: use pluralize macro wherever possible
Templates: use pluralize macro wherever possible
Uses the new pluralize macro I added to simplify/shorten other cases where I was using {% trans %} previously. The only exception was for "vote"/"votes" in the topic voting button, since those are in separate HTML elements so it wouldn't work very cleanly through the macro.merge-requests/74/head
Deimos
6 years ago
6 changed files with 20 additions and 59 deletions
-
17tildes/tildes/templates/macros/comments.jinja2
-
10tildes/tildes/templates/macros/groups.jinja2
-
7tildes/tildes/templates/macros/topics.jinja2
-
14tildes/tildes/templates/macros/user.jinja2
-
10tildes/tildes/templates/macros/utils.jinja2
-
21tildes/tildes/templates/topic.jinja2
@ -1,15 +1,15 @@ |
|||
{# Copyright (c) 2019 Tildes contributors <code@tildes.net> #} |
|||
{# SPDX-License-Identifier: AGPL-3.0-or-later #} |
|||
|
|||
{% macro pluralize(counter, base_word, plural_word=None) %} |
|||
{% if not plural_word %} |
|||
{% set plural_word = base_word~"s" %} |
|||
{% macro pluralize(counter, singular_form, plural_form=None) %} |
|||
{% if not plural_form %} |
|||
{% set plural_form = singular_form~"s" %} |
|||
{% endif %} |
|||
|
|||
{%- trans counter=counter -%} |
|||
{{ counter }} {{ base_word }} |
|||
{{ counter }} {{ singular_form }} |
|||
{%- pluralize -%} |
|||
{{ counter }} {{ plural_word }} |
|||
{{ counter }} {{ plural_form }} |
|||
{%- endtrans %} |
|||
{% endmacro %} |
|||
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue