Replaced ordinal() function and calls with num2word module and calls in fstogedcom.py and getmyancestors.py.
Removed ordinal suffixes from translation.py.
from mergemyancestors import Gedcom
from translation import translations
+try:
+ from num2words import num2words
+except ImportError:
+ sys.stderr.write('You need to install the num2words module first\n')
+ sys.stderr.write('(run this in your terminal: "python3 -m pip install num2words" or "python3 -m pip install --user num2words")\n')
+ exit(2)
tmp_dir = os.path.join(tempfile.gettempdir(), 'fstogedcom')
global cache
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):
if not todo:
break
done |= todo
- self.info(_('Download ') + ordinal(str(i + 1)) + _('generation of ancestors...'))
+ self.info(_('Download ') + num2words(i + 1, to='ordinal_num', lang=lang) + _(' generation of ancestors...'))
todo = self.tree.add_parents(todo) - done
todo = set(self.tree.indi.keys())
if not todo:
break
done |= todo
- self.info(_('Download ') + ordinal(str(i + 1)) + _('generation of descendants...'))
+ self.info(_('Download ') + num2words(i + 1, to='ordinal_num', lang=lang) + _(' generation of descendants...'))
todo = self.tree.add_children(todo) - done
if self.options.spouses.get():
# local import
from translation import translations
+try:
+ from num2words import num2words
+except ImportError:
+ sys.stderr.write('You need to install the num2words module first\n')
+ sys.stderr.write('(run this in your terminal: "python3 -m pip install num2words" or "python3 -m pip install --user num2words")\n')
+ exit(2)
+
try:
import requests
except ImportError:
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):
if not todo:
break
done |= todo
- print(_('Download ') + ordinal(str(i + 1)) + _('generation of ancestors...'))
+ print(_('Download ') + num2words(i + 1, to='ordinal_num', lang=fs.lang) + _(' generation of ancestors...'))
todo = tree.add_parents(todo) - done
# download descendants
if not todo:
break
done |= todo
- print(_('Download ') + ordinal(str(i + 1)) + _('generation of descendants...'))
+ print(_('Download ') + num2words(i + 1, to='ordinal_num', lang=fs.lang) + _(' generation of descendants...'))
todo = tree.add_children(todo) - done
# download spouses
'Download starting individuals...': {
'fr': 'Téléchargement des personnes de départ...',
},
- 'st ': {
- 'fr': 'e ',
+ ' generation of ancestors...': {
+ 'fr': ' génération d\'ancêtres...',
},
- '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...',
+ ' 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...',