Browse Source

Fix pluralization for og:description

Added a new "pluralize" macro to make this easier, so I'll go back and
implement this in the other places as well.
merge-requests/74/head
Deimos 6 years ago
parent
commit
cfe6c0f564
  1. 15
      tildes/tildes/templates/macros/utils.jinja2
  2. 3
      tildes/tildes/templates/topic.jinja2

15
tildes/tildes/templates/macros/utils.jinja2

@ -0,0 +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" %}
{% endif %}
{%- trans counter=counter -%}
{{ counter }} {{ base_word }}
{%- pluralize -%}
{{ counter }} {{ plural_word }}
{%- endtrans %}
{% endmacro %}

3
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 %}
<meta property="og:title" content="{{ self.title() }}">
<meta property="og:description" content="{{ topic.num_comments }} comments in the discussion of this {{ "link" if topic.is_link_type else "post" }} on Tildes">
<meta property="og:description" content="{{ pluralize(topic.num_comments, "comment") }} in the discussion of this {{ "link" if topic.is_link_type else "post" }} on Tildes">
{% endblock %}
{% block templates %}

Loading…
Cancel
Save