From 1daf3467e60bbd54998cab79bcabe4e3a8d4d153 Mon Sep 17 00:00:00 2001 From: Rafal Luzynski Date: Tue, 5 Feb 2019 01:00:04 +0100 Subject: [PATCH] Mark strftime format specifiers for translation Sometimes translators should be able to choose the correct date and time format for their language. --- dnf/cli/cli.py | 2 +- dnf/cli/commands/repoquery.py | 13 +++++++++++-- dnf/cli/output.py | 7 ++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/dnf/cli/cli.py b/dnf/cli/cli.py index 0c4f4c6ad9..1824bd00ed 100644 --- a/dnf/cli/cli.py +++ b/dnf/cli/cli.py @@ -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 diff --git a/dnf/cli/commands/repoquery.py b/dnf/cli/commands/repoquery.py index dc362547e9..0a962e50df 100644 --- a/dnf/cli/commands/repoquery.py +++ b/dnf/cli/commands/repoquery.py @@ -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) @@ -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 '' diff --git a/dnf/cli/output.py b/dnf/cli/output.py index 7f1d62c5a5..2156f3927f 100644 --- a/dnf/cli/output.py +++ b/dnf/cli/output.py @@ -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)