i18n prural_items
This commit is contained in:
parent
2bdfb06b9e
commit
74cdd1e709
4 changed files with 139 additions and 26 deletions
|
@ -63,7 +63,9 @@
|
|||
</p>
|
||||
<p>
|
||||
{% for cat, count in collection.get_summary.items %}
|
||||
{% if count %}<span>{{ count }} {{ cat|prural_items }}</span> {% endif %}
|
||||
{% if count %}
|
||||
<span>{% prural_items count cat %}</span>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</p>
|
||||
{% if featured_since %}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from django import template
|
||||
from django.template.defaultfilters import stringfilter
|
||||
from django.utils.translation import ngettext
|
||||
|
||||
from journal.models import Collection
|
||||
from journal.models.mixins import UserOwnedObjectMixin
|
||||
|
@ -27,24 +28,42 @@ def user_stats_of(collection: Collection, identity: APIdentity):
|
|||
return collection.get_stats(identity) if identity else {}
|
||||
|
||||
|
||||
@register.filter(is_safe=True)
|
||||
@stringfilter
|
||||
def prural_items(category: str):
|
||||
# TODO support i18n here
|
||||
# return _(f"items of {category}")
|
||||
if category == "book":
|
||||
return "本书"
|
||||
elif category == "movie":
|
||||
return "部电影"
|
||||
elif category == "tv":
|
||||
return "部剧集"
|
||||
elif category == "album" or category == "music":
|
||||
return "张专辑"
|
||||
elif category == "game":
|
||||
return "个游戏"
|
||||
elif category == "podcast":
|
||||
return "个播客"
|
||||
elif category == "performance":
|
||||
return "场演出"
|
||||
else:
|
||||
return category
|
||||
@register.simple_tag()
|
||||
def prural_items(count: int, category: str):
|
||||
match category:
|
||||
case "book":
|
||||
return ngettext("%(count)d book", "%(count)d books", count,) % {
|
||||
"count": count,
|
||||
}
|
||||
case "movie":
|
||||
return ngettext("%(count)d movie", "%(count)d movies", count,) % {
|
||||
"count": count,
|
||||
}
|
||||
case "tv":
|
||||
return ngettext("%(count)d tv show", "%(count)d tv shows", count,) % {
|
||||
"count": count,
|
||||
}
|
||||
case "music":
|
||||
return ngettext("%(count)d album", "%(count)d albums", count,) % {
|
||||
"count": count,
|
||||
}
|
||||
case "game":
|
||||
return ngettext("%(count)d game", "%(count)d games", count,) % {
|
||||
"count": count,
|
||||
}
|
||||
case "podcast":
|
||||
return ngettext("%(count)d podcast", "%(count)d podcasts", count,) % {
|
||||
"count": count,
|
||||
}
|
||||
case "performance":
|
||||
return ngettext(
|
||||
"%(count)d performance",
|
||||
"%(count)d performances",
|
||||
count,
|
||||
) % {
|
||||
"count": count,
|
||||
}
|
||||
case _:
|
||||
return ngettext("%(count)d item", "%(count)d items", count,) % {
|
||||
"count": count,
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2024-05-20 11:52-0400\n"
|
||||
"POT-Creation-Date: 2024-05-20 18:21-0400\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -857,12 +857,12 @@ msgid "Are you sure to delete?"
|
|||
msgstr "确认删除吗?"
|
||||
|
||||
#: catalog/templates/catalog_delete.html:47
|
||||
#: catalog/templates/catalog_merge.html:91
|
||||
#: catalog/templates/catalog_merge.html:91 neodb-takahe/activities/admin.py:25
|
||||
msgid "Yes"
|
||||
msgstr "是"
|
||||
|
||||
#: catalog/templates/catalog_delete.html:48
|
||||
#: catalog/templates/catalog_merge.html:92
|
||||
#: catalog/templates/catalog_merge.html:92 neodb-takahe/activities/admin.py:26
|
||||
msgid "No"
|
||||
msgstr "否"
|
||||
|
||||
|
@ -2010,6 +2010,62 @@ msgstr ""
|
|||
msgid "分享"
|
||||
msgstr ""
|
||||
|
||||
#: journal/templatetags/collection.py:36
|
||||
#, python-format
|
||||
msgid "%(count)d book"
|
||||
msgid_plural "%(count)d books"
|
||||
msgstr[0] "%(count)d 本书"
|
||||
msgstr[1] "%(count)d 本书"
|
||||
|
||||
#: journal/templatetags/collection.py:44
|
||||
#, python-format
|
||||
msgid "%(count)d movie"
|
||||
msgid_plural "%(count)d movies"
|
||||
msgstr[0] "%(count)d 部电影"
|
||||
msgstr[1] "%(count)d 部电影"
|
||||
|
||||
#: journal/templatetags/collection.py:52
|
||||
#, python-format
|
||||
msgid "%(count)d tv show"
|
||||
msgid_plural "%(count)d tv shows"
|
||||
msgstr[0] "%(count)d 部电视剧"
|
||||
msgstr[1] "%(count)d 部电视剧"
|
||||
|
||||
#: journal/templatetags/collection.py:60
|
||||
#, python-format
|
||||
msgid "%(count)d album"
|
||||
msgid_plural "%(count)d albums"
|
||||
msgstr[0] "%(count)d 张专辑"
|
||||
msgstr[1] "%(count)d 张专辑"
|
||||
|
||||
#: journal/templatetags/collection.py:68
|
||||
#, python-format
|
||||
msgid "%(count)d game"
|
||||
msgid_plural "%(count)d games"
|
||||
msgstr[0] "%(count)d 个游戏"
|
||||
msgstr[1] "%(count)d 个游戏"
|
||||
|
||||
#: journal/templatetags/collection.py:76
|
||||
#, python-format
|
||||
msgid "%(count)d podcast"
|
||||
msgid_plural "%(count)d podcasts"
|
||||
msgstr[0] "%(count)d 个播客"
|
||||
msgstr[1] "%(count)d 个播客"
|
||||
|
||||
#: journal/templatetags/collection.py:84
|
||||
#, python-format
|
||||
msgid "%(count)d performance"
|
||||
msgid_plural "%(count)d performances"
|
||||
msgstr[0] "%(count)d 场演出"
|
||||
msgstr[1] "%(count)d 场演出"
|
||||
|
||||
#: journal/templatetags/collection.py:92
|
||||
#, python-format
|
||||
msgid "%(count)d item"
|
||||
msgid_plural "%(count)d items"
|
||||
msgstr[0] "%(count)d 个条目"
|
||||
msgstr[1] "%(count)d 个条目"
|
||||
|
||||
#: journal/views/collection.py:38
|
||||
#, python-brace-format
|
||||
msgid "Collection by {0}"
|
||||
|
@ -2148,6 +2204,42 @@ msgstr ""
|
|||
msgid "target site domain name"
|
||||
msgstr ""
|
||||
|
||||
#: neodb-takahe/activities/admin.py:18
|
||||
msgid "Local Identity"
|
||||
msgstr ""
|
||||
|
||||
#: neodb-takahe/core/admin.py:8
|
||||
msgid "config options type"
|
||||
msgstr ""
|
||||
|
||||
#: neodb-takahe/core/admin.py:13
|
||||
msgid "System"
|
||||
msgstr "系统"
|
||||
|
||||
#: neodb-takahe/core/admin.py:14
|
||||
msgid "Identity"
|
||||
msgstr "身份"
|
||||
|
||||
#: neodb-takahe/core/admin.py:15
|
||||
msgid "User"
|
||||
msgstr ""
|
||||
|
||||
#: neodb-takahe/users/admin.py:147
|
||||
msgid "Local Source Identity"
|
||||
msgstr ""
|
||||
|
||||
#: neodb-takahe/users/admin.py:153
|
||||
msgid "Local Target Identity"
|
||||
msgstr ""
|
||||
|
||||
#: neodb-takahe/users/views/auth.py:20
|
||||
msgid "No account was found with that email and password."
|
||||
msgstr ""
|
||||
|
||||
#: neodb-takahe/users/views/auth.py:21
|
||||
msgid "This account is inactive."
|
||||
msgstr ""
|
||||
|
||||
#: social/templates/activity/create_collection.html:17 takahe/utils.py:553
|
||||
msgid "created collection"
|
||||
msgstr "创建了收藏单"
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
placeholder="email"
|
||||
autocomplete="email" />
|
||||
{% if request.user.pending_email %}
|
||||
<small> {% blocktrans pending_email=request.user.pending_email %}Please click the confirmation link in the email sent to {{ pending_email }}; if you haven't received it for more than a few minutes, please input and save again.{% endblocktrans %} </small>
|
||||
<small> {% blocktrans with pending_email=request.user.pending_email %}Please click the confirmation link in the email sent to {{ pending_email }}; if you haven't received it for more than a few minutes, please input and save again.{% endblocktrans %} </small>
|
||||
{% endif %}
|
||||
{% for error in form.email.errors %}<small>{{ error }}</small>{% endfor %}
|
||||
</label>
|
||||
|
|
Loading…
Add table
Reference in a new issue