From d4088a4a06823418769a32732c6e5f2a23a36b3e Mon Sep 17 00:00:00 2001 From: changeling Date: Thu, 13 Dec 2018 12:04:49 -0600 Subject: [PATCH] Updated to render correct ordinals in Download progress counts. fstogedcom.py: Lines 34-45: Implemented ordinal() function. Line 441: Yield correct ordinal for ancestor generations. Line 450: Yield correct ordinal for descendant generations. getmyancestors.py Lines 107-118: Implemented ordinal() function. Line: 960: Yield correct ordinal for ancestor generations. Line 970: Yield correct ordinal for descendant generations. translation.py Lines 104-115: Translate ordinal suffixes. Lines 116-120: Translate updated ancestor and descendant generation strings. Fixed string slice in ordinal() to correctly handle 11, 12, 13. Fixed string slice in ordinal() to correctly handle 11, 12, 13 in fstogedcom.py and getmyancestors.py. --- fstogedcom.py | 16 ++++++++++++++-- getmyancestors.py | 16 ++++++++++++++-- translation.py | 20 ++++++++++++++++---- 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/fstogedcom.py b/fstogedcom.py index 5be2d84..1b859ed 100644 --- a/fstogedcom.py +++ b/fstogedcom.py @@ -31,6 +31,18 @@ def _(string): return string +def ordinal(string): + if string[-1] == '1' and string[-2:] != '11': + suffix = _('st ') + elif string[-1] == '2' and string[-2:] != '12': + suffix = _('nd ') + elif string[-1] == '3' and string[-2:] != '13': + suffix = _('rd ') + else: + suffix = _('th ') + return string + suffix + + # Entry widget with right-clic menu to copy/cut/paste class EntryWithMenu(Entry): def __init__(self, master, **kw): @@ -426,7 +438,7 @@ class Download(Frame): if not todo: break done |= todo - self.info(_('Download ') + str(i + 1) + _('th generation of ancestors...')) + self.info(_('Download ') + ordinal(str(i + 1)) + _('generation of ancestors...')) todo = self.tree.add_parents(todo) - done todo = set(self.tree.indi.keys()) @@ -435,7 +447,7 @@ class Download(Frame): if not todo: break done |= todo - self.info(_('Download ') + str(i + 1) + _('th generation of descendants...')) + self.info(_('Download ') + ordinal(str(i + 1)) + _('generation of descendants...')) todo = self.tree.add_children(todo) - done if self.options.spouses.get(): diff --git a/getmyancestors.py b/getmyancestors.py index 244ac79..b7b5263 100755 --- a/getmyancestors.py +++ b/getmyancestors.py @@ -104,6 +104,18 @@ def cont(string): return ('\n%s CONT ' % level).join(res) +def ordinal(string): + if string[-1] == '1' and string[-2:] != '11': + suffix = _('st ') + elif string[-1] == '2' and string[-2:] != '12': + suffix = _('nd ') + elif string[-1] == '3' and string[-2:] != '13': + suffix = _('rd ') + else: + suffix = _('th ') + return string + suffix + + # FamilySearch session class class Session: def __init__(self, username, password, verbose=False, logfile=sys.stderr, timeout=60): @@ -945,7 +957,7 @@ if __name__ == '__main__': if not todo: break done |= todo - print(_('Download ') + str(i + 1) + _('th generation of ancestors...')) + print(_('Download ') + ordinal(str(i + 1)) + _('generation of ancestors...')) todo = tree.add_parents(todo) - done # download descendants @@ -955,7 +967,7 @@ if __name__ == '__main__': if not todo: break done |= todo - print(_('Download ') + str(i + 1) + _('th generation of descendants...')) + print(_('Download ') + ordinal(str(i + 1)) + _('generation of descendants...')) todo = tree.add_children(todo) - done # download spouses diff --git a/translation.py b/translation.py index 1ca6789..ba43089 100644 --- a/translation.py +++ b/translation.py @@ -101,11 +101,23 @@ translations = { 'Download starting individuals...': { 'fr': 'Téléchargement des personnes de départ...', }, - 'th generation of ancestors...': { - 'fr': 'e génération d\'ancêtres...', + 'st ': { + 'fr': 'e ', }, - 'th generation of descendants...': { - 'fr': 'e génération de descendants...', + 'nd ': { + 'fr': 'e ', + }, + 'rd ': { + 'fr': 'e ', + }, + 'th ': { + 'fr': 'e ', + }, + 'generation of ancestors...': { + 'fr': 'génération d\'ancêtres...', + }, + 'generation of descendants...': { + 'fr': 'génération de descendants...', }, 'Download spouses and marriage information...': { 'fr': 'Téléchargement des conjoints et des informations de mariage...', -- 2.52.0