diff --git a/tildes/tildes/templates/macros/utils.jinja2 b/tildes/tildes/templates/macros/utils.jinja2 new file mode 100644 index 0000000..7aafd55 --- /dev/null +++ b/tildes/tildes/templates/macros/utils.jinja2 @@ -0,0 +1,15 @@ +{# Copyright (c) 2019 Tildes contributors #} +{# 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" %} + {% endif %} + + {%- trans counter=counter -%} + {{ counter }} {{ base_word }} + {%- pluralize -%} + {{ counter }} {{ plural_word }} + {%- endtrans %} +{% endmacro %} + diff --git a/tildes/tildes/templates/topic.jinja2 b/tildes/tildes/templates/topic.jinja2 index bdf338b..90d1970 100644 --- a/tildes/tildes/templates/topic.jinja2 +++ b/tildes/tildes/templates/topic.jinja2 @@ -9,12 +9,13 @@ {% from 'macros/forms.jinja2' import markdown_textarea %} {% from 'macros/links.jinja2' import group_linked, username_linked %} {% from 'macros/topics.jinja2' import topic_voting with context %} +{% from 'macros/utils.jinja2' import pluralize %} {% block title %}{{ topic.title }} - ~{{ topic.group.path }}{% endblock %} {% block meta_og_tags %} - + {% endblock %} {% block templates %}