Skip to content

Commit

Permalink
Mark strftime format specifiers for translation
Browse files Browse the repository at this point in the history
Sometimes translators should be able to choose the correct date and time
format for their language.
  • Loading branch information
rluzynski authored and m-blaha committed Mar 31, 2023
1 parent e00219c commit 1daf346
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dnf/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def latest_changelogs(self, package):
def format_changelog(self, changelog):
"""Return changelog formatted as in spec file"""
chlog_str = '* %s %s\n%s\n' % (
changelog['timestamp'].strftime("%a %b %d %X %Y"),
changelog['timestamp'].strftime("%c"),
dnf.i18n.ucd(changelog['author']),
dnf.i18n.ucd(changelog['text']))
return chlog_str
Expand Down
13 changes: 11 additions & 2 deletions dnf/cli/commands/repoquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,15 @@ def build_format_fn(self, opts, pkg):
out.append('Changelog for %s' % str(pkg))
for chlog in pkg.changelogs:
dt = chlog['timestamp']
out.append('* %s %s\n%s\n' % (dt.strftime("%a %b %d %Y"),
out.append('* %s %s\n%s\n' % (
# TRANSLATORS: This is the date format for a changelog
# in dnf repoquery. You are encouraged to change it
# according to the requirements of your language. Format
# specifiers used here: %a - abbreviated weekday name in
# your language, %b - abbreviated month name in the correct
# grammatical form, %d - day number (01-31), %Y - year
# number (4 digits).
dt.strftime(_("%a %b %d %Y")),
dnf.i18n.ucd(chlog['author']),
dnf.i18n.ucd(chlog['text'])))
return '\n'.join(out)
Expand Down Expand Up @@ -712,7 +720,8 @@ def __getattr__(self, attr):
def _get_timestamp(timestamp):
if timestamp > 0:
dt = datetime.datetime.utcfromtimestamp(timestamp)
return dt.strftime("%Y-%m-%d %H:%M")
# TRANSLATORS: This is the default time format for dnf repoquery.
return dt.strftime(_("%Y-%m-%d %H:%M"))
else:
return ''

Expand Down
7 changes: 6 additions & 1 deletion dnf/cli/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -1548,7 +1548,12 @@ def historyListCmd(self, tids, reverse=False):
else:
name = self._pwd_ui_username(transaction.loginuid, 24)
name = ucd(name)
tm = time.strftime("%Y-%m-%d %H:%M",
# TRANSLATORS: This is the time format for dnf history list.
# You can change it but do it with caution because the output
# must be no longer than 16 characters. Format specifiers:
# %Y - year number (4 digits), %m - month (00-12), %d - day
# number (01-31), %H - hour (00-23), %M - minute (00-59).
tm = time.strftime(_("%Y-%m-%d %H:%M"),
time.localtime(transaction.beg_timestamp))
num, uiacts = self._history_uiactions(transaction.data())
name = fill_exact_width(name, name_width, name_width)
Expand Down

0 comments on commit 1daf346

Please sign in to comment.