Updated to render correct ordinals in Download progress counts.
authorchangeling <cklarson@gmail.com>
Thu, 13 Dec 2018 18:04:49 +0000 (12:04 -0600)
committerchangeling <cklarson@gmail.com>
Thu, 13 Dec 2018 18:04:49 +0000 (12:04 -0600)
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
getmyancestors.py
translation.py

index 5be2d84da797a7c40cb4b84bb98c04575461fe81..1b859ede321b843eded9864fb5c8e26ade4a42ef 100644 (file)
@@ -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():
index 244ac795d1ff09ecace699036a6a371c57748f68..b7b52636502c22aa1fd3754b9f40940ff51db050 100755 (executable)
@@ -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
index 1ca6789f519b025035e1924be9a5950b45abaa53..ba43089701b9b23949d968fd99965fd7dd193069 100644 (file)
@@ -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...',