Add i18n to `dayssince` filter (#477)

This commit is contained in:
Xuesong 2022-06-11 12:39:24 +08:00 committed by GitHub
parent cf33fc3e69
commit c1ee2a940b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 12 deletions

View File

@ -108,9 +108,9 @@ def dayssince(value, today=None):
delta = today - value delta = today - value
if delta < datetime.timedelta(days=1): if delta < datetime.timedelta(days=1):
return "today" return _("today")
if delta < datetime.timedelta(days=2): if delta < datetime.timedelta(days=2):
return "yesterday" return _("yesterday")
# use standard timesince for anything beyond yesterday # use standard timesince for anything beyond yesterday
return str(delta.days) + " days ago" return str(delta.days) + _(" days ago")

Binary file not shown.

View File

@ -2,7 +2,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Baby Buddy\n" "Project-Id-Version: Baby Buddy\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-06-04 03:37+0000\n" "POT-Creation-Date: 2022-06-07 06:48+0000\n"
"Language: zh-Hans\n" "Language: zh-Hans\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
@ -1559,6 +1559,20 @@ msgstr "{}, {}"
msgid "0 days" msgid "0 days"
msgstr "0天" msgstr "0天"
#: core/templatetags/duration.py:111
#: dashboard/templates/cards/diaperchange_types.html:49
msgid "today"
msgstr "今天"
#: core/templatetags/duration.py:113
#: dashboard/templates/cards/diaperchange_types.html:51
msgid "yesterday"
msgstr "昨天"
#: core/templatetags/duration.py:116
msgid " days ago"
msgstr "天之前"
#: core/timeline.py:53 #: core/timeline.py:53
#, python-format #, python-format
msgid "%(child)s started tummy time!" msgid "%(child)s started tummy time!"
@ -1694,14 +1708,6 @@ msgstr "小便"
msgid "solid" msgid "solid"
msgstr "大便" msgstr "大便"
#: dashboard/templates/cards/diaperchange_types.html:49
msgid "today"
msgstr "今天"
#: dashboard/templates/cards/diaperchange_types.html:51
msgid "yesterday"
msgstr "昨天"
#: dashboard/templates/cards/diaperchange_types.html:53 #: dashboard/templates/cards/diaperchange_types.html:53
#, python-format #, python-format
msgid "%(key)s days ago" msgid "%(key)s days ago"