Move all relationship calculator translators into plugins/rel.

svn: r11632
This commit is contained in:
Brian Matherly
2009-01-16 16:46:40 +00:00
parent a6fa59cc35
commit ec7ded54c6
17 changed files with 20 additions and 13 deletions

234
src/plugins/rel/rel_cs.py Normal file
View File

@@ -0,0 +1,234 @@
# -*- coding: utf-8 -*-
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2003-2006 Donald N. Allingham
# Copyright (C) 2008 Brian G. Matherly
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id:rel_cs.py 9912 2008-01-22 09:17:46Z acraphae $
# Czech terms added by Zdeněk Hataš. Based on rel_sk.py by Lubo Vasko
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
import gen.lib
import Relationship
from gen.plug import PluginManager
#-------------------------------------------------------------------------
#
# Czech-specific definitions of relationships
#
#-------------------------------------------------------------------------
_level_name = [ "", "prvního", "druhého", "třetího", "čtvrtého", "pátého", "šestého",
"sedmého", "osmého", "devátého", "desátého", "jedenáctého", "dvanáctého",
"třináctého", "čtrnáctého", "patnáctého", "šestnáctého",
"sedemnáctého", "osmnáctého", "devatenáctého", "dvacátého", "dvacátého prvního", "dvacátého druhého",
"dvacátého třetího", "dvacátého čtvrtého","dvacátého pátého","dvacátého šestého","dvacátého sedmého",
"dvacátého osmého","dvacátého devátého","třicátého" ]
_parents_level = [ "", "rodiče", "prarodiče", "praprarodiče",
"vzdálení příbuzní", ]
_father_level = [ "", "otec", "děd", "praděd", "prapředek", ]
_mother_level = [ "", "matka", "babička", "prababička", "prapředek", ]
_son_level = [ "", "syn", "vnuk", "pravnuk", ]
_daughter_level = [ "", "dcera", "vnučka", "pravnučka", ]
_sister_level = [ "", "sestra", "teta", "prateta", "praprateta", ]
_brother_level = [ "", "bratr", "strýc", "prastrýc", "praprastrýc", ]
_nephew_level = [ "", "synovec", "prasynovec", "praprasynovec", ]
_niece_level = [ "", "neteř", "praneteř", "prapraneteř", ]
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
class RelationshipCalculator(Relationship.RelationshipCalculator):
def __init__(self):
Relationship.RelationshipCalculator.__init__(self)
def get_male_cousin(self,level):
if level>len(_level_name)-1:
return "vzdálený příbuzný"
else:
return "bratranec %s stupně" % (_level_name[level])
def get_female_cousin(self,level):
if level>len(_level_name)-1:
return "vzdálená příbuzná"
else:
return "sestřenice %s stupně" % (_level_name[level])
def get_parents(self,level):
if level>len(_parents_level)-1:
return "vzdáleení příbuzní"
else:
return _parents_level[level]
def get_father(self,level):
if level>len(_father_level)-1:
return "vzdálený příbuzný"
else:
return _father_level[level]
def get_son(self,level):
if level>len(_son_level)-1:
return "vzdálený potomek"
else:
return _son_level[level]
def get_mother(self,level):
if level>len(_mother_level)-1:
return "vzdálený předek"
else:
return _mother_level[level]
def get_daughter(self,level):
if level>len(_daughter_level)-1:
return "vzdálený potomek"
else:
return _daughter_level[level]
def get_aunt(self,level):
if level>len(_sister_level)-1:
return "vzdálený předek"
else:
return _sister_level[level]
def get_uncle(self,level):
if level>len(_brother_level)-1:
return "vzdálený předek"
else:
return _brother_level[level]
def get_nephew(self,level):
if level>len(_nephew_level)-1:
return "vzdálený potomek"
else:
return _nephew_level[level]
def get_niece(self,level):
if level>len(_niece_level)-1:
return "vzdálený potomek"
else:
return _niece_level[level]
def get_relationship(self,db, orig_person, other_person):
"""
Return a string representing the relationshp between the two people,
along with a list of common ancestors (typically father,mother)
Special cases: relation strings "", "undefined" and "spouse".
"""
if orig_person is None:
return ("undefined",[])
if orig_person.get_handle() == other_person.get_handle():
return ('', [])
is_spouse = self.is_spouse(db, orig_person, other_person)
if is_spouse:
return (is_spouse,[])
#get_relationship_distance changed, first data is relation to
#orig person, apperently secondRel in this function
(secondRel,firstRel,common) = \
self.get_relationship_distance(db, orig_person, other_person)
if isinstance(common, basestring):
return (common,[])
elif common:
person_handle = common[0]
else:
return ("",[])
firstRel = len(firstRel)
secondRel = len(secondRel)
if firstRel == 0:
if secondRel == 0:
return ('',common)
elif other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_father(secondRel),common)
else:
return (self.get_mother(secondRel),common)
elif secondRel == 0:
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_son(firstRel),common)
else:
return (self.get_daughter(firstRel),common)
elif firstRel == 1:
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_uncle(secondRel),common)
else:
return (self.get_aunt(secondRel),common)
elif secondRel == 1:
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_nephew(firstRel-1),common)
else:
return (self.get_niece(firstRel-1),common)
elif firstRel == secondRel == 2:
if other_person.get_gender() == gen.lib.Person.MALE:
return ('vlastní bratranec',common)
else:
return ('vlastní sestřenice',common)
elif firstRel == 3 and secondRel == 2:
if other_person.get_gender() == gen.lib.Person.MALE:
return ('bratranec druhého stupně',common)
else:
return ('sestřenice druhého stupně',common)
elif firstRel == 2 and secondRel == 3:
if other_person.get_gender() == gen.lib.Person.MALE:
return ('bratranec druhého stupně',common)
else:
return ('sestřenice druhého stupně',common)
else:
if other_person.get_gender() == gen.lib.Person.MALE:
if firstRel+secondRel>len(_level_name)-1:
return (self.get_male_cousin(firstRel+secondRel),common)
else:
return ('vzdálený bratranec',common)
else:
if firstRel+secondRel>len(_level_name)-1:
return (self.get_female_cousin(firstRel+secondRel),common)
else:
return ('vzdálená sestřenice',common)
#-------------------------------------------------------------------------
#
# Register this class with the Plugins system
#
#-------------------------------------------------------------------------
pmgr = PluginManager.get_instance()
pmgr.register_relcalc(RelationshipCalculator,
["cs", "CZ", "cs_CZ", "česky", "czech", "Czech", "cs_CZ.UTF8", "cs_CZ.UTF-8", "cs_CZ.utf-8", "cs_CZ.utf8"])

212
src/plugins/rel/rel_da.py Normal file
View File

@@ -0,0 +1,212 @@
# -*- coding: utf-8 -*-
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2003-2005 Donald N. Allingham
# Copyright (C) 2008 Brian G. Matherly
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id$
# Written by Alex Roitman, largely based on Relationship.py by Don Allingham
# and on valuable input from Lars Kr. Lundin
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
import gen.lib
import Relationship
import types
from gen.plug import PluginManager
#-------------------------------------------------------------------------
#
# Danish-specific definitions of relationships
#
#-------------------------------------------------------------------------
_level_name = [ "", "første", "anden", "tredje", "fjerde", "femte", "sjette",
"syvende", "ottende", "niende", "tiende", "ellevte", "tolvte",
"trettende", "fjortende", "femtende", "sekstende",
"syttende", "attende", "nittende", "tyvende", "enogtyvende", "toogtyvende",
"treogtyvende","fireogtyvende","femogtyvende","seksogtyvende",
"syvogtyvende","otteogtyvende","niogtyvende","tredivte", ]
_parents_level = [ "forældre", "bedsteforældre", "oldeforældre",
"tipoldeforældre", "tiptipoldeforældre" , "tiptiptipoldeforældre", ]
_father_level = [ "", "faderen", "bedstefaderen", "oldefaderen", "tipoldefaderen", ]
_mother_level = [ "", "moderen", "bedstemoderen", "oldemoderen", "tipoldemoderen", ]
_son_level = [ "", "sønnen", "barnebarnet", "oldebarnet", ]
_daughter_level = [ "", "datteren", "barnebarnet", "oldebarnet", ]
_sister_level = [ "", "søsteren", "tanten", "grandtanten", "oldetanten", ]
_brother_level = [ "", "broderen", "onklen", "grandonklen", "oldeonkel", ]
_nephew_level = [ "", "nevøen", "næstsøskendebarnet", "broderens barnebarn", ]
_niece_level = [ "", "niecen", "næstsøskendebarnet", "søsterens barnebarn", ]
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
class RelationshipCalculator(Relationship.RelationshipCalculator):
def __init__(self):
Relationship.RelationshipCalculator.__init__(self)
def get_parents(self,level):
if level>len(_parents_level)-1:
#return "fjern forfader"
#Instead of "remote ancestors" using "tip (level) oldeforældre" here.
return "tip (%d) oldeforældre" % level
else:
return _parents_level[level]
def pair_up(self,rel_list):
result = []
item = ""
for word in rel_list[:]:
if not word:
continue
if item:
if word == 'søster':
item = item[0:-1]
word = 'ster'
elif word == 'sønne':
word = 'søn'
result.append(item + word)
item = ""
else:
item = word
if item:
result.append(item)
gen_result = [ item + 's' for item in result[0:-1] ]
return ' '.join(gen_result+result[-1:])
def get_direct_ancestor(self,person,rel_string):
result = []
for ix in range(len(rel_string)):
if rel_string[ix] == 'f':
result.append('far')
else:
result.append('mor')
return self.pair_up(result)
def get_direct_descendant(self,person,rel_string):
result = []
for ix in range(len(rel_string)-2,-1,-1):
if rel_string[ix] == 'f':
result.append('sønne')
else:
result.append('datter')
if person.get_gender() == gen.lib.Person.MALE:
result.append('søn')
else:
result.append('datter')
return self.pair_up(result)
def get_two_way_rel(self,person,first_rel_string,second_rel_string):
result = []
for ix in range(len(second_rel_string)-1):
if second_rel_string[ix] == 'f':
result.append('far')
else:
result.append('mor')
if len(first_rel_string)>1:
if first_rel_string[-2] == 'f':
result.append('bror')
else:
result.append('søster')
for ix in range(len(first_rel_string)-3,-1,-1):
if first_rel_string[ix] == 'f':
result.append('sønne')
else:
result.append('datter')
if person.get_gender() == gen.lib.Person.MALE:
result.append('søn')
else:
result.append('datter')
else:
if person.get_gender() == gen.lib.Person.MALE:
result.append('bror')
else:
result.append('søster')
return self.pair_up(result)
def get_relationship(self,db, orig_person, other_person):
"""
Return a string representing the relationshp between the two people,
along with a list of common ancestors (typically father,mother)
Special cases: relation strings "", "undefined" and "spouse".
"""
if orig_person is None:
return ("undefined",[])
if orig_person.get_handle() == other_person.get_handle():
return ('', [])
is_spouse = self.is_spouse(db, orig_person, other_person)
if is_spouse:
return (is_spouse,[])
#get_relationship_distance changed, first data is relation to
#orig person, apperently secondRel in this function
(secondRel,firstRel,common) = \
self.get_relationship_distance(db, orig_person, other_person)
if isinstance(common, basestring):
return (common,[])
elif common:
person_handle = common[0]
else:
return ("",[])
if not firstRel:
if not secondRel:
return ('',common)
else:
return (self.get_direct_ancestor(other_person,secondRel),common)
elif not secondRel:
return (self.get_direct_descendant(other_person,firstRel),common)
else:
return (self.get_two_way_rel(other_person,firstRel,secondRel),common)
#-------------------------------------------------------------------------
#
# Register this class with the Plugins system
#
#-------------------------------------------------------------------------
pmgr = PluginManager.get_instance()
pmgr.register_relcalc(RelationshipCalculator,
[ "da", "DA", "da_DK", "danish", "Danish", "da_DK.UTF8",
"da_DK@euro", "da_DK.UTF8@euro", "dansk", "Dansk",
"da_DK.UTF-8", "da_DK.utf-8", "da_DK.utf8",
"da_DK.ISO-8859-1","da_DK.iso-8859-1","da_DK.iso88591" ])

304
src/plugins/rel/rel_de.py Normal file
View File

@@ -0,0 +1,304 @@
# -*- coding: utf-8 -*-
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2003-2005 Donald N. Allingham
# Copyright (C) 2008 Stefan Siegel
# Copyright (C) 2008 Brian G. Matherly
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id$
# Original version written by Alex Roitman, largely based on Relationship.py
# by Don Allingham and on valuable input from Dr. Martin Senftleben
# Modified by Joachim Breitner to not use „Großcousine“, in accordance with
# http://de.wikipedia.org/wiki/Verwandtschaftsbeziehung
# Rewritten from scratch for GRAMPS 3 by Stefan Siegel,
# loosely based on rel_fr.py
#-------------------------------------------------------------------------
#
# standard python modules
#
#-------------------------------------------------------------------------
import re
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
import gen.lib
import Relationship
from gen.plug import PluginManager
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
_ordinal = [ u'nullte',
u'erste', u'zweite', u'dritte', u'vierte', u'fünfte', u'sechste',
u'siebte', u'achte', u'neunte', u'zehnte', u'elfte', u'zwölfte',
]
_removed = [ u'',
u'', u'Groß', u'Urgroß',
u'Alt', u'Altgroß', u'Alturgroß',
u'Ober', u'Obergroß', u'Oberurgroß',
u'Stamm', u'Stammgroß', u'Stammurgroß',
u'Ahnen', u'Ahnengroß', u'Ahnenurgroß',
u'Urahnen', u'Urahnengroß', u'Urahnenurgroß',
u'Erz', u'Erzgroß', u'Erzurgroß',
u'Erzahnen', u'Erzahnengroß', u'Erzahnenurgroß',
]
_lineal_up = {
'many': u'%(p)sEltern%(s)s',
'unknown': u'%(p)sElter%(s)s', # "Elter" sounds strange but is correct
'male': u'%(p)sVater%(s)s',
'female': u'%(p)sMutter%(s)s',
}
_lineal_down = {
'many': u'%(p)sKinder%(s)s',
'unknown': u'%(p)sKind%(s)s',
'male': u'%(p)sSohn%(s)s',
'female': u'%(p)sTochter%(s)s',
}
_collateral_up = {
'many': u'%(p)sOnkel und %(p)sTanten%(s)s',
'unknown': u'%(p)sOnkel oder %(p)sTante%(s)s',
'male': u'%(p)sOnkel%(s)s',
'female': u'%(p)sTante%(s)s',
}
_collateral_down = {
'many': u'%(p)sNeffen und %(p)sNichten%(s)s',
'unknown': u'%(p)sNeffe oder %(p)sNichte%(s)s',
'male': u'%(p)sNeffe%(s)s',
'female': u'%(p)sNichte%(s)s',
}
_collateral_same = {
'many': u'%(p)sCousins und %(p)sCousinen%(s)s',
'unknown': u'%(p)sCousin oder %(p)sCousine%(s)s',
'male': u'%(p)sCousin%(s)s',
'female': u'%(p)sCousine%(s)s',
}
_collateral_sib = {
'many': u'%(p)sGeschwister%(s)s',
'unknown': u'%(p)sGeschwisterkind%(s)s',
'male': u'%(p)sBruder%(s)s',
'female': u'%(p)sSchwester%(s)s',
}
_schwager = {
'many': u'%(p)sSchwager%(s)s',
'unknown': u'%(p)sSchwager%(s)s',
'male': u'%(p)sSchwager%(s)s',
'female': u'%(p)sSchwägerin%(s)s',
}
_schwippschwager = {
'many': u'%(p)sSchwippschwager%(s)s',
'unknown': u'%(p)sSchwippschwager%(s)s',
'male': u'%(p)sSchwippschwager%(s)s',
'female': u'%(p)sSchwippschwägerin%(s)s',
}
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
class RelationshipCalculator(Relationship.RelationshipCalculator):
def __init__(self):
Relationship.RelationshipCalculator.__init__(self)
def _make_roman(self, num):
roman = ''
for v, r in [(1000, u'M'), (900, u'CM'), (500, u'D'), (400, u'CD'),
( 100, u'C'), ( 90, u'XC'), ( 50, u'L'), ( 40, u'XL'),
( 10, u'X'), ( 9, u'IX'), ( 5, u'V'), ( 4, u'IV'),
( 1, u'I')]:
while num > v:
num -= v
roman += r
return roman
def _fix_caps(self, string):
return re.sub(r'(?<=[^\s(/A-Z])[A-Z]', lambda m: m.group().lower(), string)
def _removed_text(self, degree, removed):
if (degree, removed) == (0, -2):
return u'Enkel'
elif (degree, removed) == (0, -3):
return u'Urenkel'
removed = abs(removed)
if removed < len(_removed):
return _removed[removed]
else:
return u'(%s)' % self._make_roman(removed-2)
def _degree_text(self, degree, removed):
if removed == 0:
degree -= 1 # a cousin has same degree as his parent (uncle/aunt)
if degree <= 1:
return u''
if degree < len(_ordinal):
return u' %sn Grades' % _ordinal[degree]
else:
return u' %d. Grades' % degree
def _gender_convert(self, gender):
if gender == gen.lib.Person.MALE:
return 'male'
elif gender == gen.lib.Person.FEMALE:
return 'female'
else:
return 'unknown'
def _get_relationship_string(self, Ga, Gb, gender,
reltocommon_a='', reltocommon_b='',
only_birth=True,
in_law_a=False, in_law_b=False):
common_ancestor_count = 0
if reltocommon_a == '':
reltocommon_a = self.REL_FAM_BIRTH
if reltocommon_b == '':
reltocommon_b = self.REL_FAM_BIRTH
if reltocommon_a[-1] in [self.REL_MOTHER, self.REL_FAM_BIRTH,
self.REL_FAM_BIRTH_MOTH_ONLY] and \
reltocommon_b[-1] in [self.REL_MOTHER, self.REL_FAM_BIRTH,
self.REL_FAM_BIRTH_MOTH_ONLY]:
common_ancestor_count += 1 # same female ancestor
if reltocommon_a[-1] in [self.REL_FATHER, self.REL_FAM_BIRTH,
self.REL_FAM_BIRTH_FATH_ONLY] and \
reltocommon_b[-1] in [self.REL_FATHER, self.REL_FAM_BIRTH,
self.REL_FAM_BIRTH_FATH_ONLY]:
common_ancestor_count += 1 # same male ancestor
degree = min(Ga, Gb)
removed = Ga-Gb
if degree == 0 and removed < 0:
# for descendants the "in-law" logic is reversed
(in_law_a, in_law_b) = (in_law_b, in_law_a)
rel_str = u''
pre = u''
post = u''
if in_law_b and degree == 0:
pre += u'Stief'
elif (not only_birth) or common_ancestor_count == 0:
pre += u'Stief-/Adoptiv'
if in_law_a and (degree, removed) != (1, 0):
# A "Schwiegerbruder" really is a "Schwager" (handled later)
pre += u'Schwieger'
if degree != 0 and common_ancestor_count == 1:
pre += u'Halb'
pre += self._removed_text(degree, removed)
post += self._degree_text(degree, removed)
if in_law_b and degree != 0 and (degree, removed) != (1, 0):
# A "Bruder (angeheiratet)" also is a "Schwager" (handled later)
post += u' (angeheiratet)'
if degree == 0:
# lineal relationship
if removed > 0:
rel_str = _lineal_up[gender]
elif removed < 0:
rel_str = _lineal_down[gender]
else:
rel_str = u'Proband'
else:
# collateral relationship
if removed > 0:
rel_str = _collateral_up[gender]
elif removed < 0:
rel_str = _collateral_down[gender]
elif degree == 1:
if in_law_a or in_law_b:
if in_law_a and in_law_b:
rel_str = _schwippschwager[gender]
else:
rel_str = _schwager[gender]
else:
rel_str = _collateral_sib[gender]
else:
rel_str = _collateral_same[gender]
return self._fix_caps(rel_str % {'p': pre, 's': post})
def get_plural_relationship_string(self, Ga, Gb):
return self._get_relationship_string(Ga, Gb, 'many')
def get_single_relationship_string(self, Ga, Gb, gender_a, gender_b,
reltocommon_a, reltocommon_b,
only_birth=True,
in_law_a=False, in_law_b=False):
return self._get_relationship_string(Ga, Gb,
self._gender_convert(gender_b),
reltocommon_a, reltocommon_b,
only_birth, in_law_a, in_law_b)
def get_sibling_relationship_string(self, sib_type, gender_a, gender_b,
in_law_a=False, in_law_b=False):
if sib_type in [self.NORM_SIB, self.UNKNOWN_SIB]:
# the NORM_SIB translation is generic and suitable for UNKNOWN_SIB
rel = self.REL_FAM_BIRTH
only_birth = True
elif sib_type == self.HALF_SIB_FATHER:
rel = self.REL_FAM_BIRTH_FATH_ONLY
only_birth = True
elif sib_type == self.HALF_SIB_MOTHER:
rel = self.REL_FAM_BIRTH_MOTH_ONLY
only_birth = True
elif sib_type == self.STEP_SIB:
rel = self.REL_FAM_NONBIRTH
only_birth = False
return self._get_relationship_string(1, 1,
self._gender_convert(gender_b),
rel, rel,
only_birth, in_law_a, in_law_b)
#-------------------------------------------------------------------------
#
# Register this class with the Plugins system
#
#-------------------------------------------------------------------------
pmgr = PluginManager.get_instance()
pmgr.register_relcalc(RelationshipCalculator,
["de","DE","de_DE","deutsch","Deutsch","de_DE.UTF8","de_DE@euro","de_DE.UTF8@euro",
"german","German", "de_DE.UTF-8", "de_DE.utf-8", "de_DE.utf8"])
if __name__ == "__main__":
# Test function. Call it as follows from the command line (so as to find
# imported modules):
# export PYTHONPATH=/path/to/gramps/src
# python src/plugins/rel_fr.py
# (Above not needed here)
"""TRANSLATORS, copy this if statement at the bottom of your
rel_xx.py module, and test your work with:
python src/plugins/rel_xx.py
"""
from Relationship import test
rc = RelationshipCalculator()
test(rc, True)

340
src/plugins/rel/rel_es.py Normal file
View File

@@ -0,0 +1,340 @@
# -*- coding: utf-8 -*-
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2003-2005 Donald N. Allingham
# Copyright (C) 2008 Brian G. Matherly
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Written by Julio Sanchez <julio.sanchez@gmail.com>
# $Id$
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
import gen.lib
import Relationship
import types
from gen.plug import PluginManager
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
_level_name_male = [ "", "primero", "segundo", "tercero", "cuarto", "quinto",
"sexto", "séptimo", "octavo", "noveno", "décimo", "undécimo",
"duodécimo", "decimotercero", "decimocuarto", "decimoquinto",
"decimosexto", "decimoséptimo", "decimoctavo", "decimonono",
"vigésimo", ]
# Short forms (in apocope) used before names
_level_name_male_a = [ "", "primer", "segundo", "tercer", "cuarto", "quinto",
"sexto", "séptimo", "octavo", "noveno", "décimo", "undécimo",
"duodécimo", "decimotercer", "decimocuarto", "decimoquinto",
"decimosexto", "decimoséptimo", "decimoctavo", "decimonono",
"vigésimo"]
_level_name_female = [ "", "primera", "segunda", "tercera", "cuarta", "quinta",
"sexta", "séptima", "octava", "novena", "décima", "undécima",
"duodécima", "decimotercera", "decimocuarta", "decimoquinta",
"decimosexta", "decimoséptima", "decimoctava", "decimonona",
"vigésima"]
_level_name_plural = [ "", "primeros", "segundos", "terceros", "cuartos",
"quintos", "sextos", "séptimos", "octavos", "novenos",
"décimos", "undécimos", "duodécimos", "decimoterceros",
"decimocuartos", "decimoquintos", "decimosextos",
"decimoséptimos", "decimoctavos", "decimononos",
"vigésimos", ]
# This plugin tries to be flexible and expect little from the following
# tables. Ancestors are named from the list for the first generations.
# When this list is not enough, ordinals are used based on the same idea,
# i.e. bisabuelo is 'segundo abuelo' and so on, that has been the
# traditional way in Spanish. When we run out of ordinals we resort to
# N-ésimo notation, that is sort of understandable if in context.
_parents_level = [ "", "padres", "abuelos", "bisabuelos", "tatarabuelos",
"trastatarabuelos"]
_father_level = [ "", "padre", "abuelo", "bisabuelo", "tatarabuelo",
"trastatarabuelo"]
_mother_level = [ "", "madre", "abuela", "bisabuela", "tatarabuela",
"trastatarabuela"]
# Higher-order terms (after trastatarabuelo) on this list are not standard,
# but then there is no standard naming scheme at all for this in Spanish.
# Check http://www.genealogia-es.com/guia3.html that echoes a proposed
# scheme that has got some reception in the Spanish-language genealogy
# community. Uncomment these names if you want to use them.
#_parents_level = [ "", "padres", "abuelos", "bisabuelos", "tatarabuelos",
# "trastatarabuelos", "pentabuelos", "hexabuelos",
# "heptabuelos", "octabuelos", "eneabuelos", "decabuelos"]
#_father_level = [ "", "padre", "abuelo", "bisabuelo", "tatarabuelo",
# "trastatarabuelo", "pentabuelo", "hexabuelo",
# "heptabuelo", "octabuelo", "eneabuelo", "decabuelo"]
#_mother_level = [ "", "madre", "abuela", "bisabuela", "tatarabuela",
# "trastatarabuela", "pentabuela", "hexabuela",
# "heptabuela", "octabuela", "eneabuela", "decabuela"]
_son_level = [ "", "hijo", "nieto", "bisnieto",
"tataranieto", "trastataranieto", ]
_daughter_level = [ "", "hija", "nieta", "bisnieta",
"tataranieta", "trastataranieta", ]
_sister_level = [ "", "hermana", "tía", "tía abuela",
"tía bisabuela", ]
_brother_level = [ "", "hermano", "tío", "tío abuelo",
"tío bisabuelo", ]
_nephew_level = [ "", "sobrino", "sobrino nieto", "sobrino bisnieto", ]
_niece_level = [ "", "sobrina", "sobrina nieta", "sobrina bisnieta", ]
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
class RelationshipCalculator(Relationship.RelationshipCalculator):
def __init__(self):
Relationship.RelationshipCalculator.__init__(self)
def get_male_cousin(self,level):
if level<len(_level_name_male):
return "primo %s" % (_level_name_male[level])
else:
return "primo %d-ésimo" % level
def get_female_cousin(self,level):
if level<len(_level_name_female):
return "prima %s" % (_level_name_female[level])
else:
return "prima %d-ésima" % level
def get_distant_uncle(self,level):
if level<len(_level_name_male):
return "tío %s" % (_level_name_male[level])
else:
return "tío %d-ésimo" % level
def get_distant_aunt(self,level):
if level<len(_level_name_female):
return "tía %s" % (_level_name_female[level])
else:
return "tía %d-ésima" % level
def get_distant_nephew(self,level):
if level<len(_level_name_male):
return "sobrino %s" % (_level_name_male[level])
else:
return "sobrino %d-ésimo" % level
def get_distant_nieve(self,level):
if level<len(_level_name_female):
return "sobrina %s" % (_level_name_female[level])
else:
return "sobrina %d-ésima" % level
def get_male_relative(self,level1,level2):
if level1<len(_level_name_male_a):
level1_str = _level_name_male_a[level1]
else:
level1_str = "%d-ésimo" % level1
if level2<len(_level_name_male_a):
level2_str = _level_name_male_a[level2]
else:
level2_str = "%d-ésimo" % level2
level = level1 + level2
if level<len(_level_name_male_a):
level_str = _level_name_male_a[level]
else:
level_str = "%d-ésimo" % level
return "pariente en %s grado (%s con %s)" % (level_str,level1_str,level2_str)
def get_female_relative(self,level1,level2):
return self.get_male_relative(level1,level2)
def get_parents(self,level):
if level<len(_parents_level):
return _parents_level[level]
elif (level-1)<len(_level_name_plural):
return "%s abuelos" % (_level_name_plural[level-1])
else:
return "%d-ésimos abuelos" % (level-1)
def get_father(self,level):
if level<len(_father_level):
return _father_level[level]
elif (level-1)<len(_level_name_male_a):
return "%s abuelo" % (_level_name_male_a[level-1])
else:
return "%d-ésimo abuelo" % (level-1)
def get_son(self,level):
if level<len(_son_level):
return _son_level[level]
elif (level-1)<len(_level_name_male_a):
return "%s nieto" % (_level_name_male_a[level-1])
else:
return "%d-ésimo nieto" % (level-1)
def get_mother(self,level):
if level<len(_mother_level):
return _mother_level[level]
elif (level-1)<len(_level_name_female):
return "%s abuela" % (_level_name_female[level-1])
else:
return "%d-ésima abuela" % (level-1)
def get_daughter(self,level):
if level<len(_daughter_level):
return _daughter_level[level]
elif (level-1)<len(_level_name_female):
return "%s nieta" % (_level_name_female[level-1])
else:
return "%d-ésima nieta" % (level-1)
def get_aunt(self,level):
if level<len(_sister_level):
return _sister_level[level]
elif (level-2)<len(_level_name_female):
return "%s tía abuela" % (_level_name_female[level-2])
else:
return "%d-ésima tía abuela" % (level-2)
def get_uncle(self,level):
if level<len(_brother_level):
return _brother_level[level]
elif (level-2)<len(_level_name_male_a):
return "%s tío abuelo" % (_level_name_male_a[level-2])
else:
return "%d-ésimo tío abuelo" % (level-2)
def get_nephew(self,level):
if level<len(_nephew_level):
return _nephew_level[level]
elif (level-1)<len(_level_name_male_a):
return "%s sobrino nieto" % (_level_name_male_a[level-1])
else:
return "%d-ésimo sobrino nieto" % (level-1)
def get_niece(self,level):
if level<len(_niece_level):
return _niece_level[level]
elif (level-1)<len(_level_name_female):
return "%s sobrina nieta" % (_level_name_female[level-1])
else:
return "%d-ésima sobrina nieta" % (level-1)
def get_relationship(self,db, orig_person, other_person):
"""
returns a string representing the relationshp between the two people,
along with a list of common ancestors (typically father,mother)
"""
if orig_person is None:
return ("undefined",[])
if orig_person.get_handle() == other_person.get_handle():
return ('', [])
is_spouse = self.is_spouse(db, orig_person, other_person)
if is_spouse:
return (is_spouse,[])
#get_relationship_distance changed, first data is relation to
#orig person, apperently secondRel in this function
(secondRel,firstRel,common) = \
self.get_relationship_distance(db, orig_person, other_person)
if isinstance(common, basestring):
return (common,[])
elif common:
person_handle = common[0]
else:
return ("",[])
firstRel = len(firstRel)
secondRel = len(secondRel)
if firstRel == 0:
if secondRel == 0:
return ('',common)
elif other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_father(secondRel),common)
else:
return (self.get_mother(secondRel),common)
elif secondRel == 0:
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_son(firstRel),common)
else:
return (self.get_daughter(firstRel),common)
elif firstRel == 1:
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_uncle(secondRel),common)
else:
return (self.get_aunt(secondRel),common)
elif secondRel == 1:
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_nephew(firstRel-1),common)
else:
return (self.get_niece(firstRel-1),common)
elif firstRel == secondRel == 2:
if other_person.get_gender() == gen.lib.Person.MALE:
return ('primo hermano',common)
else:
return ('prima hermana',common)
elif firstRel == secondRel:
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_male_cousin(firstRel-1),common)
else:
return (self.get_female_cousin(firstRel-1),common)
elif firstRel == secondRel+1:
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_distant_nephew(secondRel),common)
else:
return (self.get_distant_niece(secondRel),common)
elif firstRel+1 == secondRel:
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_distant_uncle(firstRel),common)
else:
return (self.get_distant_aunt(firstRel),common)
else:
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_male_relative(firstRel,secondRel),common)
else:
return (self.get_female_relative(firstRel,secondRel),common)
#-------------------------------------------------------------------------
#
# Register this function with the Plugins system
#
#-------------------------------------------------------------------------
pmgr = PluginManager.get_instance()
pmgr.register_relcalc(RelationshipCalculator,
["es","ES","es_ES","espanol","Espanol","es_ES.UTF8","es_ES@euro","es_ES.UTF8@euro",
"spanish","Spanish", "es_ES.UTF-8", "es_ES.utf-8", "es_ES.utf8"])

227
src/plugins/rel/rel_fi.py Normal file
View File

@@ -0,0 +1,227 @@
# -*- coding: utf-8 -*-
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2003-2005 Donald N. Allingham
# Copyright (C) 2008 Brian G. Matherly
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id$
# Written by Alex Roitman, largely based on Relationship.py by Don Allingham
# and on valuable input from Eero Tamminen
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
import gen.lib
import Relationship
import types
from gen.plug import PluginManager
#-------------------------------------------------------------------------
#
# Finnish-specific definitions of relationships
#
#-------------------------------------------------------------------------
_parents_level = [ "", "vanhemmat", "isovanhemmat", "isoisovanhemmat",
"isoisoisovanhemmat", "isoisoisoisovanhemmat" ]
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
class RelationshipCalculator(Relationship.RelationshipCalculator):
def __init__(self):
Relationship.RelationshipCalculator.__init__(self)
def get_cousin(self,level):
if level == 0:
return ""
elif level == 1:
return "serkku"
elif level == 2:
return "pikkuserkku"
elif level > 2:
return "%d. serkku" % level
def get_cousin_genitive(self,level):
if level == 0:
return ""
elif level == 1:
return "serkun"
elif level == 2:
return "pikkuserkun"
elif level > 2:
return "%d. serkun" % level
def get_parents(self,level):
if level>len(_parents_level)-1:
return "kaukaiset esivanhemmat"
else:
return _parents_level[level]
def get_direct_ancestor(self,person,rel_string):
result = []
for ix in range(len(rel_string)-1):
if rel_string[ix] == 'f':
result.append('isän')
else:
result.append('äidin')
if person.get_gender() == gen.lib.Person.MALE:
result.append('isä')
else:
result.append('äiti')
return ' '.join(result)
def get_direct_descendant(self,person,rel_string):
result = []
for ix in range(len(rel_string)-2,-1,-1):
if rel_string[ix] == 'f':
result.append('pojan')
elif rel_string[ix] == 'm':
result.append('tyttären')
else:
result.append('lapsen')
if person.get_gender() == gen.lib.Person.MALE:
result.append('poika')
elif person.get_gender() == gen.lib.Person.FEMALE:
result.append('tytär')
else:
result.append('lapsi')
return ' '.join(result)
def get_ancestors_cousin(self,rel_string_long,rel_string_short):
result = []
removed = len(rel_string_long)-len(rel_string_short)
level = len(rel_string_short)-1
for ix in range(removed):
if rel_string_long[ix] == 'f':
result.append('isän')
else:
result.append('äidin')
result.append(self.get_cousin(level))
return ' '.join(result)
def get_cousins_descendant(self,person,rel_string_long,rel_string_short):
result = []
removed = len(rel_string_long)-len(rel_string_short)-1
level = len(rel_string_short)-1
if level:
result.append(self.get_cousin_genitive(level))
elif rel_string_long[removed] == 'f':
result.append('veljen')
else:
result.append('sisaren')
for ix in range(removed-1,-1,-1):
if rel_string_long[ix] == 'f':
result.append('pojan')
elif rel_string_long[ix] == 'm':
result.append('tyttären')
else:
result.append('lapsen')
if person.get_gender() == gen.lib.Person.MALE:
result.append('poika')
elif person.get_gender() == gen.lib.Person.FEMALE:
result.append('tytär')
else:
result.append('lapsi')
return ' '.join(result)
def get_ancestors_brother(self,rel_string):
result = []
for ix in range(len(rel_string)-1):
if rel_string[ix] == 'f':
result.append('isän')
else:
result.append('äidin')
result.append('veli')
return ' '.join(result)
def get_ancestors_sister(self,rel_string):
result = []
for ix in range(len(rel_string)-1):
if rel_string[ix] == 'f':
result.append('isän')
else:
result.append('äidin')
result.append('sisar')
return ' '.join(result)
def get_relationship(self,db, orig_person, other_person):
"""
Return a string representing the relationshp between the two people,
along with a list of common ancestors (typically father,mother)
Special cases: relation strings "", "undefined" and "spouse".
"""
if orig_person is None:
return ("undefined",[])
if orig_person.get_handle() == other_person.get_handle():
return ('', [])
is_spouse = self.is_spouse(db, orig_person, other_person)
if is_spouse:
return (is_spouse,[])
#get_relationship_distance changed, first data is relation to
#orig person, apperently secondRel in this function
(secondRel,firstRel,common) = \
self.get_relationship_distance(db, orig_person, other_person)
if isinstance(common, basestring):
return (common,[])
elif common:
person_handle = common[0]
else:
return ("",[])
if not firstRel:
if not secondRel:
return ('',common)
else:
return (self.get_direct_ancestor(other_person,secondRel),common)
elif not secondRel:
return (self.get_direct_descendant(other_person,firstRel),common)
elif len(firstRel) == 1:
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_ancestors_brother(secondRel),common)
else:
return (self.get_ancestors_sister(secondRel),common)
elif len(secondRel) >= len(firstRel):
return (self.get_ancestors_cousin(secondRel,firstRel),common)
else:
return (self.get_cousins_descendant(other_person,firstRel,secondRel),common)
#-------------------------------------------------------------------------
#
# Register this class with the Plugins system
#
#-------------------------------------------------------------------------
pmgr = PluginManager.get_instance()
pmgr.register_relcalc(RelationshipCalculator,
["fi","FI","fi_FI","finnish","Finnish","fi_FI.UTF8","fi_FI@euro","fi_FI.UTF8@euro",
"suomi","Suomi", "fi_FI.UTF-8", "fi_FI.utf-8", "fi_FI.utf8"])

623
src/plugins/rel/rel_fr.py Normal file
View File

@@ -0,0 +1,623 @@
# -*- coding: utf-8 -*-
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2003-2007 Donald N. Allingham
# Copyright (C) 2008 Brian G. Matherly
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
import gen.lib
import Relationship
from gen.plug import PluginManager
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
# level est utilisé pour trouver/afficher le niveau de la génération :
# à la %sème génération
_level_name = [ "première", "deuxième", "troisième", "quatrième",
"cinquième", "sixième", "septième", "huitième",
"neuvième", "dixième", "onzième", "douzième",
"treizième", "quatorzième", "quinzième",
"seizième", "dix-septième", "dix-huitième",
"dix-neuvième", "vingtième", "vingt-et-unième",
"vingt-deuxième", "vingt-troisième",
"vingt-quatrième", "vingt-cinquième",
"vingt-sixième", "vingt-septième",
"vingt-huitième", "vingt-neuvième",
"trentième", ]
# pour le degrè (canon et civil), limitation 20+20 ainsi que pour
# LE [premier] cousin
_removed_level = [ "premier", "deuxième", "troisième", "quatrième",
"cinquième", "sixième", "septième", "huitième",
"neuvième", "dixième", "onzième", "douzième",
"treizième", "quatorzième", "quinzième",
"seizième", "dix-septième", "dix-huitième",
"dix-neuvième", "vingtième", "vingt-et-unième",
"vingt-deuxième", "vingt-troisième",
"vingt-quatrième", "vingt-cinquième",
"vingt-sixième", "vingt-septième",
"vingt-huitième", "vingt-neuvième",
"trentième", "trente-et-unième",
"trente-deuxième", "trente-troisième",
"trente-quatrième", "trente-cinquième",
"trente-sixième", "trente-septième",
"trente-huitième", "trente-neuvième",
"quarantième", "quanrante-et-unième", ]
# listes volontairement limitées | small lists, use generation level if > [5]
_father_level = [ "", "le père%s", "le grand-père%s",
"l'arrière-grand-père%s", "le trisaïeul%s", ]
_mother_level = [ "", "la mère%s", "la grand-mère%s",
"l'arrière-grand-mère%s", "la trisaïeule%s", ]
_son_level = [ "", "le fils%s", "le petit-fils%s", "l'arrière-petit-fils%s", ]
_daughter_level = [ "", "la fille%s", "la petite-fille%s",
"l'arrière-petite-fille%s", ]
_sister_level = [ "", "la sœur%s", "la tante%s", "la grand-tante%s",
"l'arrière-grand-tante%s", ]
_brother_level = [ "", "le frère%s", "l'oncle%s", "le grand-oncle%s",
"l'arrière-grand-oncle%s", ]
_nephew_level = [ "", "le neveu%s", "le petit-neveu%s",
"l'arrière-petit-neveu%s", ]
_niece_level = [ "", "la nièce%s", "la petite-nièce%s",
"l'arrière-petite-nièce%s", ]
# kinship report
_parents_level = [ "", "les parents", "les grands-parents",
"les arrières-grands-parents", "les trisaïeux", ]
_children_level = [ "", "les enfants", "les petits-enfants",
"les arrières-petits-enfants",
"les arrières-arrières-petits-enfants", ]
_siblings_level = [ "", "les frères et les sœurs",
"les oncles et les tantes",
"les grands-oncles et les grands-tantes",
"les arrières-grands-oncles et les arrières-grands-tantes",
]
_nephews_nieces_level = [ "", "les neveux et les nièces",
"les petits-neveux et les petites-nièces",
"les arrière-petits-neveux et les arrières-petites-nièces",
]
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
class RelationshipCalculator(Relationship.RelationshipCalculator):
INLAW = ' (par alliance)'
def __init__(self):
Relationship.RelationshipCalculator.__init__(self)
# RelCalc tool - Status Bar
# de la personne active à l'ascendant commun Ga=[level]
def get_cousin(self, level, removed, dir = '', inlaw=''):
if removed == 0 and level < len(_level_name):
return "le %s cousin%s" % (_removed_level[level-1],
inlaw)
elif (level) < (removed):
rel_str = self.get_uncle(level-1, inlaw)
else:
# limitation gen = 29
return "le cousin lointain, relié à la %s génération" % (
_level_name[removed])
def get_cousine(self, level, removed, dir = '', inlaw=''):
if removed == 0 and level < len(_level_name):
return "la %s cousine%s" % (_level_name[level-1],
inlaw)
elif (level) < (removed):
rel_str = self.get_aunt(level-1, inlaw)
else:
return "la cousine lointaine, reliée à la %s génération" % (
_level_name[removed])
def get_parents(self, level):
if level > len(_parents_level)-1:
return "les ascendants lointains, à la %s génération" % (
_level_name[level])
else:
return _parents_level[level]
def get_father(self, level, inlaw=''):
if level > len(_father_level)-1:
return "l'ascendant lointain, à la %s génération" % (
_level_name[level])
else:
return _father_level[level] % inlaw
def get_mother(self, level, inlaw=''):
if level > len(_mother_level)-1:
return "l'ascendante lointaine, à la %s génération" % (
_level_name[level])
else:
return _mother_level[level] % inlaw
def get_parent_unknown(self, level, inlaw=''):
if level > len(_level_name)-1:
return "l'ascendant lointain, à la %s génération" % (
_level_name[level])
elif level == 1:
return "un parent%s" % (inlaw)
else:
return "un parent lointain%s" % (inlaw)
def get_son(self, level, inlaw=''):
if level > len(_son_level)-1:
return "le descendant lointain, à la %s génération" % (
_level_name[level+1])
else:
return _son_level[level] % (inlaw)
def get_daughter(self, level, inlaw=''):
if level > len(_daughter_level)-1:
return "la descendante lointaine, à la %s génération" % (
_level_name[level+1])
else:
return _daughter_level[level] % (inlaw)
def get_child_unknown(self, level, inlaw=''):
if level > len(_level_name)-1:
return "le descendant lointain, à la %s génération" % (
_level_name[level+1])
elif level == 1:
return "un enfant%s" % (inlaw)
else:
return "un descendant lointain%s" % (inlaw)
def get_sibling_unknown(self, level, inlaw=''):
return "un parent lointain%s" % (inlaw)
def get_uncle(self, level, inlaw=''):
if level > len(_brother_level)-1:
return "l'oncle lointain, relié à la %s génération" % (
_level_name[level])
else:
return _brother_level[level] % (inlaw)
def get_aunt(self, level, inlaw=''):
if level > len(_sister_level)-1:
return "la tante lointaine, reliée à la %s génération" % (
_level_name[level])
else:
return _sister_level[level] % (inlaw)
def get_nephew(self, level, inlaw=''):
if level > len(_nephew_level)-1:
return "le neveu lointain, à la %s génération" % (
_level_name[level])
else:
return _nephew_level[level] % (inlaw)
def get_niece(self, level, inlaw=''):
if level > len(_niece_level)-1:
return "la nièce lointaine, à la %s génération" % (
_level_name[level])
else:
return _niece_level[level] % (inlaw)
# kinship report
def get_plural_relationship_string(self, Ga, Gb):
"""
voir Relationship.py
"""
rel_str = "des parents lointains"
gen = " à la %sème génération"
bygen = " par la %sème génération"
cmt = " (frères ou sœurs d'un ascendant" + gen % (
Ga) + ")"
if Ga == 0:
# These are descendants
if Gb < len(_children_level):
rel_str = _children_level[Gb]
else:
rel_str = "les descendants" + gen % (
Gb+1)
elif Gb == 0:
# These are parents/grand parents
if Ga < len(_parents_level):
rel_str = _parents_level[Ga]
else:
rel_str = "les ascendants" + gen % (
Ga+1)
elif Gb == 1:
# These are siblings/aunts/uncles
if Ga < len(_siblings_level):
rel_str = _siblings_level[Ga]
else:
rel_str = "Les enfants d'un ascendant" + gen % (
Ga+1) + cmt
elif Ga == 1:
# These are nieces/nephews
if Gb < len(_nephews_nieces_level):
rel_str = _nephews_nieces_level[Gb-1]
else:
rel_str = "les neveux et les nièces" + gen % (
Gb)
elif Ga > 1 and Ga == Gb:
# These are cousins in the same generation
# use custom level for latin words
if Ga == 2:
rel_str = "les cousins germains et cousines germaines"
elif Ga <= len(_level_name):
# %ss for plural
rel_str = "les %ss cousins et cousines" % _level_name[Ga-2]
# security
else:
rel_str = "les cousins et cousines"
elif Ga > 1 and Ga > Gb:
# These are cousins in different generations with the second person
# being in a higher generation from the common ancestor than the
# first person.
# use custom level for latin words and specific relation
if Ga == 3 and Gb == 2:
desc = " (cousins germains d'un parent)"
rel_str = "les oncles et tantes à la mode de Bretagne" + desc
elif Gb <= len(_level_name) and (Ga-Gb) < len(_removed_level) and (Ga+Gb+1) < len(_removed_level):
can = " du %s au %s degré (canon)" % (
_removed_level[Gb], _removed_level[Ga] )
civ = " et au %s degré (civil)" % ( _removed_level[Ga+Gb+1] )
rel_str = "les oncles et tantes" + can + civ
elif Ga < len(_level_name):
rel_str = "les grands-oncles et grands-tantes" + bygen % (
Ga+1)
else:
return rel_str
elif Gb > 1 and Gb > Ga:
# These are cousins in different generations with the second person
# being in a lower generation from the common ancestor than the
# first person.
# use custom level for latin words and specific relation
if Ga == 2 and Gb == 3:
info = " (cousins issus d'un germain)"
rel_str = "les neveux et nièces à la mode de Bretagne" + info
elif Ga <= len(_level_name) and (Gb-Ga) < len(_removed_level) and (Ga+Gb+1) < len(_removed_level):
can = " du %s au %s degré (canon)" % (
_removed_level[Gb], _removed_level[Ga] )
civ = " et au %s degré (civil)" % ( _removed_level[Ga+Gb+1] )
rel_str = "les neveux et nièces" + can + civ
elif Ga < len(_level_name):
rel_str = "les neveux et nièces" + bygen % (
Gb)
else:
return rel_str
return rel_str
# quick report (missing on RelCalc tool - Status Bar)
def get_single_relationship_string(self, Ga, Gb, gender_a, gender_b,
reltocommon_a, reltocommon_b,
only_birth=True,
in_law_a=False, in_law_b=False):
"""
voir Relationship.py
"""
if only_birth:
step = ''
else:
step = self.STEP
if in_law_a or in_law_b :
inlaw = self.INLAW
else:
inlaw = ''
rel_str = "un parent lointains%s" % (inlaw)
bygen = " par la %sème génération"
if Ga == 0:
# b is descendant of a
if Gb == 0 :
rel_str = 'le même individu'
elif gender_b == gen.lib.Person.MALE and Gb < len(_son_level):
# spouse of daughter
if inlaw and Gb == 1 and not step:
rel_str = "le gendre"
else:
rel_str = self.get_son(Gb)
elif gender_b == gen.lib.Person.FEMALE and Gb < len(_daughter_level):
# spouse of son
if inlaw and Gb == 1 and not step:
rel_str = "la bru"
else:
rel_str = self.get_daughter(Gb)
# don't display inlaw
elif Gb < len(_level_name) and gender_b == gen.lib.Person.MALE:
rel_str = "le descendant lointain (%dème génération)" % (
Gb+1)
elif Gb < len(_level_name) and gender_b == gen.lib.Person.FEMALE:
rel_str = "la descendante lointaine (%dème génération)" % (
Gb+1)
else:
return self.get_child_unknown(Gb)
elif Gb == 0:
# b is parents/grand parent of a
if gender_b == gen.lib.Person.MALE and Ga < len(_father_level):
# other spouse of father (new parent)
if Ga == 1 and inlaw and self.STEP_SIB:
rel_str = "le beau-père"
# father of spouse (family of spouse)
elif Ga == 1 and inlaw:
rel_str = "le père du conjoint"
else:
rel_str = self.get_father(Ga, inlaw)
elif gender_b == gen.lib.Person.FEMALE and Ga < len(_mother_level):
# other spouse of mother (new parent)
if Ga == 1 and inlaw and self.STEP_SIB:
rel_str = "la belle-mère"
# mother of spouse (family of spouse)
elif Ga == 1 and inlaw:
rel_str = "la mère du conjoint"
else:
rel_str = self.get_mother(Ga, inlaw)
elif Ga < len(_level_name) and gender_b == gen.lib.Person.MALE:
rel_str = "l'ascendant lointain%s (%dème génération)" % (
inlaw, Ga+1)
elif Ga < len(_level_name) and gender_b == gen.lib.Person.FEMALE:
rel_str = "l'ascendante lointaine%s (%dème génération)" % (
inlaw, Ga+1)
else:
return self.get_parent_unknown(Ga, inlaw)
elif Gb == 1:
# b is sibling/aunt/uncle of a
if gender_b == gen.lib.Person.MALE and Ga < len(_brother_level):
rel_str = self.get_uncle(Ga, inlaw)
elif gender_b == gen.lib.Person.FEMALE and Ga < len(_sister_level):
rel_str = self.get_aunt(Ga, inlaw)
else:
# don't display inlaw
if gender_b == gen.lib.Person.MALE:
rel_str = "l'oncle lointain" + bygen % (
Ga+1)
elif gender_b == gen.lib.Person.FEMALE:
rel_str = "la tante lointaine" + bygen % (
Ga+1)
elif gender_b == gen.lib.Person.UNKNOWN:
rel_str = self.get_sibling_unknown(Ga, inlaw)
else:
return rel_str
elif Ga == 1:
# b is niece/nephew of a
if gender_b == gen.lib.Person.MALE and Gb < len(_nephew_level):
rel_str = self.get_nephew(Gb-1, inlaw)
elif gender_b == gen.lib.Person.FEMALE and Gb < len(_niece_level):
rel_str = self.get_niece(Gb-1, inlaw)
else:
if gender_b == gen.lib.Person.MALE:
rel_str = "le neveu lointain%s (%dème génération)" % (
inlaw, Gb)
elif gender_b == gen.lib.Person.FEMALE:
rel_str = "la nièce lointaine%s (%dème génération)" % (
inlaw, Gb)
elif gender_b == gen.lib.Person.UNKNOWN:
rel_str = self.get_sibling_unknown(Ga, inlaw)
else:
return rel_str
elif Ga == Gb:
# a and b cousins in the same generation
if gender_b == gen.lib.Person.MALE:
rel_str = self.get_cousin(Ga-1, 0, dir = '',
inlaw=inlaw)
elif gender_b == gen.lib.Person.FEMALE:
rel_str = self.get_cousine(Ga-1, 0, dir = '',
inlaw=inlaw)
elif gender_b == gen.lib.Person.UNKNOWN:
rel_str = self.get_sibling_unknown(Ga-1, inlaw)
else:
return rel_str
elif Ga > 1 and Ga > Gb:
# These are cousins in different generations with the second person
# being in a higher generation from the common ancestor than the
# first person.
if Ga == 3 and Gb == 2:
if gender_b == gen.lib.Person.MALE:
desc = " (cousin germain d'un parent)"
rel_str = "l'oncle à la mode de Bretagne" + desc
elif gender_b == gen.lib.Person.FEMALE:
desc = " (cousine germaine d'un parent)"
rel_str = "la tante à la mode de Bretagne" + desc
elif gender_b == gen.lib.Person.UNKNOWN:
return self.get_sibling_unknown(Ga, inlaw)
else:
return rel_str
elif Gb <= len(_level_name) and (Ga-Gb) < len(_removed_level) and (Ga+Gb+1) < len(_removed_level):
can = " du %s au %s degré (canon)" % (
_removed_level[Gb], _removed_level[Ga] )
civ = " et au %s degré (civil)" % ( _removed_level[Ga+Gb+1] )
if gender_b == gen.lib.Person.MALE:
rel_str = "l'oncle" + can + civ
elif gender_b == gen.lib.Person.FEMALE:
rel_str = "la tante" + can + civ
elif gender_b == gen.lib.Person.UNKNOWN:
rel_str = self.get_sibling_unknown(Ga, inlaw)
else:
return rel_str
else:
if gender_b == gen.lib.Person.MALE:
rel_str = self.get_uncle(Ga, inlaw)
elif gender_b == gen.lib.Person.FEMALE:
rel_str = self.get_aunt(Ga, inlaw)
elif gender_b == gen.lib.Person.UNKNOWN:
rel_str = self.get_sibling_unknown(Ga, inlaw)
else:
return rel_str
elif Gb > 1 and Gb > Ga:
# These are cousins in different generations with the second person
# being in a lower generation from the common ancestor than the
# first person.
if Ga == 2 and Gb == 3:
info = " (cousins issus d'un germain)"
if gender_b == gen.lib.Person.MALE:
rel_str = "le neveu à la mode de Bretagne" + info
elif gender_b == gen.lib.Person.FEMALE:
rel_str = "la nièce à la mode de Bretagne" + info
elif gender_b == gen.lib.Person.UNKNOWN:
rel_str = self.get_sibling_unknown(Ga, inlaw)
else:
return rel_str
elif Ga <= len(_level_name) and (Gb-Ga) < len(_removed_level) and (Ga+Gb+1) < len(_removed_level):
can = " du %s au %s degré (canon)" % (
_removed_level[Gb], _removed_level[Ga] )
civ = " et au %s degré (civil)" % ( _removed_level[Ga+Gb+1] )
if gender_b == gen.lib.Person.MALE:
rel_str = "le neveu" + can + civ
if gender_b == gen.lib.Person.FEMALE:
rel_str = "la nièce" + can + civ
elif gender_b == gen.lib.Person.UNKNOWN:
rel_str = self.get_sibling_unknown(Ga, inlaw)
else:
return rel_str
elif Ga > len(_level_name):
return rel_str
else:
if gender_b == gen.lib.Person.MALE:
rel_str = self.get_nephew(Ga, inlaw)
elif gender_b ==gen.lib.Person.FEMALE:
rel_str = self.get_niece(Ga, inlaw)
elif gender_b == gen.lib.Person.UNKNOWN:
rel_str = self.get_sibling_unknown(Ga, inlaw)
else:
return rel_str
return rel_str
# RelCalc tool - Status Bar
def get_sibling_relationship_string(self, sib_type, gender_a, gender_b,
in_law_a=False, in_law_b=False):
if in_law_a or in_law_b :
inlaw = self.INLAW
else:
inlaw = ''
if sib_type == self.NORM_SIB:
if not inlaw:
if gender_b == gen.lib.Person.MALE:
rel_str = 'le frère (germain)'
elif gender_b == gen.lib.Person.FEMALE:
rel_str = 'la sœur (germaine)'
else:
rel_str = 'le frère ou la sœur germain(e)'
else:
if gender_b == gen.lib.Person.MALE:
rel_str = "le beau-frère"
elif gender_b == gen.lib.Person.FEMALE:
rel_str = "la belle-sœur"
else:
rel_str = "le beau-frère ou la belle-sœur"
elif sib_type == self.UNKNOWN_SIB:
if not inlaw:
if gender_b == gen.lib.Person.MALE:
rel_str = 'le frère'
elif gender_b == gen.lib.Person.FEMALE:
rel_str = 'la sœur'
else:
rel_str = 'le frère ou la sœur'
else:
if gender_b == gen.lib.Person.MALE:
rel_str = "le beau-frère"
elif gender_b == gen.lib.Person.FEMALE:
rel_str = "la belle-sœur"
else:
rel_str = "le beau-frère ou la belle-sœur"
# Logique inversée ! Pourquoi ?
elif sib_type == self.HALF_SIB_MOTHER:
if gender_b == gen.lib.Person.MALE:
rel_str = "le demi-frère consanguin"
elif gender_b == gen.lib.Person.FEMALE:
rel_str = "la demi-sœur consanguine"
else:
rel_str = "le demi-frère ou la demi-sœur consanguin(e)"
# Logique inversée ! Pourquoi ?
elif sib_type == self.HALF_SIB_FATHER:
if gender_b == gen.lib.Person.MALE:
rel_str = "le demi-frère utérin"
elif gender_b == gen.lib.Person.FEMALE:
rel_str = "la demi-sœur utérine"
else:
rel_str = "le demi-frère ou la demi-sœur utérin(e)"
elif sib_type == self.STEP_SIB:
if gender_b == gen.lib.Person.MALE:
rel_str = "le demi-frère"
elif gender_b == gen.lib.Person.FEMALE:
rel_str = "la demi-sœur"
else:
rel_str = "le demi-frère ou la demi-sœur"
return rel_str
#-------------------------------------------------------------------------
#
# Register this class with the Plugins system
#
#-------------------------------------------------------------------------
pmgr = PluginManager.get_instance()
pmgr.register_relcalc(RelationshipCalculator,
["fr", "FR", "fr_FR", "fr_CA", "francais", "Francais", "fr_FR.UTF8",
"fr_FR@euro", "fr_FR.UTF8@euro",
"french","French", "fr_FR.UTF-8", "fr_FR.utf-8", "fr_FR.utf8",
"fr_CA.UTF-8"])
if __name__ == "__main__":
# Test function. Call it as follows from the command line (so as to find
# imported modules):
# export PYTHONPATH=/path/to/gramps/src
# python src/plugins/rel_fr.py
# (Above not needed here)
"""TRANSLATORS, copy this if statement at the bottom of your
rel_xx.py module, and test your work with:
python src/plugins/rel_xx.py
"""
from Relationship import test
rc = RelationshipCalculator()
test(rc, True)

363
src/plugins/rel/rel_hu.py Normal file
View File

@@ -0,0 +1,363 @@
# -*- coding: utf-8 -*-
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2003-2006 Donald N. Allingham
# Copyright (C) 2008 Brian G. Matherly
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id$
#
# Written by Egyeki Gergely <egeri@elte.hu>, 2004
#
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
import gen.lib
import Relationship
from gen.plug import PluginManager
import types
#-------------------------------------------------------------------------
#
# Shared constants
#
#-------------------------------------------------------------------------
_level =\
["", "", "másod", "harmad", "negyed", "ötöd", "hatod",
"heted", "nyolcad", "kilenced", "tized", "tizenegyed", "tizenketted",
"tizenharmad", "tizennegyed", "tizenötöd", "tizenhatod",
"tizenheted", "tizennyolcad", "tizenkilenced", "huszad","huszonegyed"]
#-------------------------------------------------------------------------
#
# Specific relationship functions
#
#-------------------------------------------------------------------------
class RelationshipCalculator(Relationship.RelationshipCalculator):
def __init__(self):
Relationship.RelationshipCalculator.__init__(self)
def get_parents (self,level):
if level == 0: return ""
elif level == 1: return "szülei"
elif level == 2: return "nagyszülei"
elif level == 3: return "dédszülei"
elif level == 4: return "ükszülei"
else : return "%s szülei" % _level[level]
def get_father (self,level):
if level == 0: return ""
elif level == 1: return "apja"
elif level == 2: return "nagyapja"
elif level == 3: return "dédapja"
elif level == 4: return "ükapja"
else : return "%s ükapja" % (_level[level])
def get_mother (self,level):
if level == 0: return ""
elif level == 1: return "anyja"
elif level == 2: return "nagyanyja"
elif level == 3: return "dédanyja"
elif level == 4: return "ükanyja"
else : return "%s ükanyja" % (_level[level])
def get_son (self,level):
if level == 0: return ""
elif level == 1: return "fia"
elif level == 2: return "unokája"
elif level == 3: return "dédunokája"
elif level == 4: return "ükunokája"
else : return "%s unokája" % (_level[level])
def get_daughter (self,level):
if level == 0: return ""
elif level == 1: return "lánya"
else : return self.get_son(level)
def get_uncle (self,level):
if level == 0: return ""
elif level == 1: return "testvére"
elif level == 2: return "nagybátyja"
else : return "%s nagybátyja" % (_level[level])
def get_aunt (self,level):
if level == 0: return ""
elif level == 1: return "testvére"
elif level == 2: return "nagynénje"
else : return "%s nagynénje" % (_level[level])
def get_nephew (self,level):
if level == 0: return ""
elif level == 1: return "unokája"
else : return "%s unokája" % (_level[level])
def get_niece(self,level):
return self.get_nephew(level)
def get_male_cousin (self,level):
if level == 0: return ""
elif level == 1: return "unokatestvére"
else : return "%s unokatestvére" % (_level[level])
def get_female_cousin (self,level):
return self.get_male_cousin(level)
#----------------------------------------------
#
# brother and sister age differences
#
#----------------------------------------------
def get_age_comp(self, orig_person, other_person):
# 0=nothing, -1=other is younger 1=other is older
orig_birth_event = orig_person.get_birth()
orig_birth_date = orig_birth_event.get_date_object()
other_birth_event = other_person.get_birth()
other_birth_date = other_birth_event.get_date_object()
if (orig_birth_date == "")or(other_birth_date == "") :return 0
else :return orig_birth_date>other_birth_date
def get_age_brother (self,level):
if level == 0 : return "testvére"
elif level == 1 : return "öccse"
else : return "bátyja"
def get_age_sister (self,level):
if level == 0 : return "testvére"
elif level == 1 : return "húga"
else : return "nővére"
#---------------------------------------------
#
# en: father-in-law, mother-in-law, son-in-law, daughter-in-law
# hu: após, anyós, vő, meny
#
#---------------------------------------------
def is_fathermother_in_law(self, orig, other):
for f in other.get_family_handle_list():
family = self.db.get_family_from_handle(f)
sp_id = None
if family:
if other == family.get_father_handle():
sp_id = family.get_mother_handle()
elif other == family.get_mother_handle():
sp_id = family.get_father_handle()
for g in orig.get_family_handle_list():
family = self.db.get_family_from_handle(g)
if family:
if sp_id in family.get_child_handle_list():
return 1
return 0
def get_fathermother_in_law_common(self, orig, other):
for f in other.get_family_handle_list():
family = self.db.get_family_from_handle(f)
sp_id = None
if family:
if other == family.get_father_handle():
sp_id = family.get_mother_handle()
elif other == family.get_mother_handle():
sp_id = family.get_father_handler()
for g in orig.get_family_handle_list():
family = self.db.get_family_from_handle(g)
if family:
if sp_id in family.get_child_handle_list():
return [sp_id]
return []
#------------------------------------------------------------------------
#
# hu: sógor, sógornő
# en: brother-in-law, sister-in-law
#
#------------------------------------------------------------------------
def is_brothersister_in_law(self, orig, other):
for f in orig.get_family_handle_list():
family = self.db.get_family_from_handle(f)
sp_id = None
if family:
if orig == family.get_father_handle():
sp_id = family.get_mother_handle()
elif other == family.get_mother_handle():
sp_id = family.get_father_handler()
p = other.get_main_parents_family_handle()
family = self.db.get_family_from_handle(p)
if family:
c = family.get_child_handle_list()
if (other.get_handle() in c) and (sp_id in c):
return 1
return 0
def get_brothersister_in_law_common(self, orig, other):
for f in orig.get_family_handle_list():
family = self.db.get_family_from_handle(f)
sp_id = None
if family:
if orig == family.get_father_handle():
sp_id = family.get_mother_handle()
elif other == family.get_mother_handle():
sp_id = family.get_father_handler()
p = other.get_main_parents_family_handle()
family = self.db.get_family_from_handle(p)
if family:
c = family.get_child_handle_list()
if (other.get_handle() in c) and (sp_id in c):
return [sp_id]
return []
#-------------------------------------------------------------------------
#
# get_relationship
#
#-------------------------------------------------------------------------
def get_relationship(self,db, orig_person, other_person):
"""
returns a string representing the relationshp between the two people,
along with a list of common ancestors (typically father,mother)
"""
if orig_person is None:
return ("undefined",[])
if orig_person.get_handle() == other_person.get_handle():
return ('', [])
is_spouse = self.is_spouse(db, orig_person, other_person)
if is_spouse:
return (is_spouse,[])
if self.is_fathermother_in_law(other_person, orig_person):
if other_person.getGender() == gen.lib.Person.MALE:
return ("apósa",self.get_fathermother_in_law_common(other_person, orig_person))
elif other_person.getGender() == gen.lib.Person.FEMALE:
return ("anyósa",self.get_fathermother_in_law_common(other_person, orig_person))
elif other_person.getGender() == 2 :
return ("apósa vagy anyósa",self.get_fathermother_in_law_common(other_person, orig_person))
if self.is_fathermother_in_law(orig_person, other_person):
if orig_person.getGender() == gen.lib.Person.MALE:
return ("veje",self.get_fathermother_in_law_common(orig_person, other_person))
elif orig_person.getGender() == gen.lib.Person.FEMALE:
return ("menye",self.get_fathermother_in_law_common(orig_person, other_person))
elif orig_person.getGender() == 2 :
return ("veje vagy menye",self.get_fathermother_in_law_common(orig_person, other_person))
if self.is_brothersister_in_law(orig_person, other_person):
if other_person.getGender() == gen.lib.Person.MALE:
return ("sógora",self.get_brothersister_in_law_common(orig_person, other_person))
elif other_person.getGender() == gen.lib.Person.FEMALE:
return ("sógornője",self.get_brothersister_in_law_common(orig_person, other_person))
elif other_person.getGender() == 2 :
return ("sógora vagy sógornője",self.get_brothersister_in_law_common(orig_person, other_person))
#get_relationship_distance changed, first data is relation to
#orig person, apperently secondRel in this function
(secondRel,firstRel,common) = \
self.get_relationship_distance(db, orig_person, other_person)
if isinstance(common, basestring):
return (common,[])
elif common:
person_handle = common[0]
else:
return ("",[])
firstRel = len(firstRel)
secondRel = len(secondRel)
if firstRel == 0:
if secondRel == 0:
return ('',common)
elif other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_father(secondRel),common)
else:
return (self.get_mother(secondRel),common)
elif secondRel == 0:
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_son(firstRel),common)
else:
return (self.get_daughter(firstRel),common)
elif firstRel == 1:
if other_person.get_gender() == gen.lib.Person.MALE:
if secondRel == 1:
return (self.get_age_brother(self.get_age_comp(orig_person, other_person)),common)
else :return (self.get_uncle(secondRel),common)
else:
if secondRel == 1:
return (self.get_age_sister(self.get_age_comp(orig_person, other_person)),common)
else :return (self.get_aunt(secondRel),common)
elif secondRel == 1:
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_nephew(firstRel-1),common)
else:
return (self.get_niece(firstRel-1),common)
else:
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_male_cousin(firstRel-1), common)
else:
return (self.get_female_cousin(firstRel-1), common)
#-------------------------------------------------------------------------
#
# Function registration
#
#-------------------------------------------------------------------------
pmgr = PluginManager.get_instance()
pmgr.register_relcalc(RelationshipCalculator,
["hu", "HU", "hu_HU", "hu_HU.utf8", "hu_HU.UTF8"])
# Local variables:
# buffer-file-coding-system: utf-8
# End:

533
src/plugins/rel/rel_it.py Normal file
View File

@@ -0,0 +1,533 @@
# -*- python -*-
# -*- coding: utf-8 -*-
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2003-2005 Donald N. Allingham
# Copyright (C) 2008 Brian G. Matherly
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id:rel_it.py 9912 2008-01-22 09:17:46Z acraphae $
#
# Written by Lorenzo Cappelletti <lorenzo.cappelletti@email.it>, 2003
# Benny Malengier <benny.malengier@gramps-project.org, 2007
# Maria-Cristina Ciocci <see above>, 2007
#
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
import gen.lib
import Relationship
import types
from gen.plug import PluginManager
#-------------------------------------------------------------------------
#
# Shared constants
#
#-------------------------------------------------------------------------
_level = [
"", "prim%(gen)s", "second%(gen)s", "terz%(gen)s", "quart%(gen)s",
"quint%(gen)s", "sest%(gen)s",
"settim%(gen)s", "ottav%(gen)s", "non%(gen)s", "decim%(gen)s",
"undicesim%(gen)s", "dodicesim%(gen)s",
"tredicesim%(gen)s", "quattordicesim%(gen)s", "quindicesim%(gen)s",
"sedicesim%(gen)s", "diciasettesim%(gen)s", "diciottesim%(gen)s",
"diciannovesim%(gen)s", "ventesim%(gen)s"
]
_level_m = [
"", "primo", "secondo", "terzo", "quarto",
"quinto", "sesto",
"settimo", "ottavo", "nono", "decimo",
"undicesimo", "dodicesimo",
"tredicesimo", "quattordicesimo", "quindicesimo",
"sedicesimo", "diciasettesimo", "diciottesimo",
"diciannovesimo", "ventesimo"
]
_level_f = [
"", "prima", "seconda", "terza", "quarta",
"quinta", "sesta",
"settima", "ottava", "nona", "decima",
"undicesima", "dodicesima",
"tredicesima", "quattordicesima", "quindicesima",
"sedicesima", "diciasettesima", "diciottesima",
"diciannovesima", "ventesima"
]
_father_level = [ "",
"il padre%(step)s%(inlaw)s",
"il nonno%(step)s%(inlaw)s",
"il bisnonno%(step)s%(inlaw)s",
"il trisnonno%(step)s%(inlaw)s",
]
_mother_level = [ "",
"la madre%(step)s%(inlaw)s",
"la nonna%(step)s%(inlaw)s",
"la bisnonna%(step)s%(inlaw)s",
"la trisnonna%(step)s%(inlaw)s",
]
_son_level = [ "", "il figlio%(step)s%(inlaw)s",
"il nipote%(step)s%(inlaw)s diretto",
"il pronipote%(step)s%(inlaw)s diretto"
]
_daughter_level = [ "", "la figlia%(step)s%(inlaw)s",
"la nipote%(step)s%(inlaw)s diretta",
"la pronipote%(step)s%(inlaw)s diretta"
]
_brother_level = [ "", "il fratello%(step)s%(inlaw)s",
"lo zio%(step)s%(inlaw)s",
"il prozio%(step)s%(inlaw)s",
]
_sister_level = [ "", "la sorella%(step)s%(inlaw)s",
"la zia%(step)s%(inlaw)s",
"la prozia%(step)s%(inlaw)s",
]
_nephew_level = [ "", "il nipote%(step)s%(inlaw)s",
"il pronipote%(step)s%(inlaw)s"
]
_niece_level = [ "", "la nipote%(step)s%(inlaw)s",
"la pronipote%(step)s%(inlaw)s"
]
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
class RelationshipCalculator(Relationship.RelationshipCalculator):
INLAW = ' acquisit%(gen)s'
STEP = ' adottiv%(gen)s'
def __init__(self):
Relationship.RelationshipCalculator.__init__(self)
#-------------------------------------------------------------------------
#
# Specific relationship functions
#
# To be honest, I doubt that this relationship naming method is widely
# spread... If you know of a rigorous, italian naming convention,
# please, drop me an email.
#
#-------------------------------------------------------------------------
def __gen_suffix(self, gender):
if gender == gen.lib.Person.MALE:
return 'o'
return 'a'
def get_parents (self,level):
if level>len(_level)-1:
return "remote ancestors"
else:
return "%si genitori" % _level[level]
def get_father (self, level, step='', inlaw=''):
gen = "o"
if level < len(_father_level):
return _father_level[level] % {'step': step, 'inlaw': inlaw} \
% {'gen': gen}
elif level < len(_level):
return 'il nonno%(step)s%(inlaw)s della %(level_f)s generazione' % {
'level_f': _level_f[level],
'step': step, 'inlaw': inlaw} % {'gen': gen}
else:
return "l'avo%(step)s%(inlaw)s (%(level)d generazioni)" % {
'step': step, 'inlaw': inlaw,
'level': level} % {'gen': gen}
def get_mother (self, level, step='', inlaw=''):
gen = "a"
if level < len(_father_level):
return _mother_level[level] % {'step': step, 'inlaw': inlaw} \
% {'gen': gen}
elif level < len(_level):
return 'la nonna%(step)s%(inlaw)s della %(level_f)s generazione' % {
'level_f': _level_f[level],
'step': step, 'inlaw': inlaw} % {'gen': gen}
else:
return "l'ava%(step)s%(inlaw)s (%(level)d generazioni)" % {
'step': step, 'inlaw': inlaw,
'level': level} % {'gen': gen}
def get_parent_unknown(self, level, step='', inlaw=''):
gen = "o/a"
if level == 1:
return "uno dei genitori%(step)s%(inlaw)s" % {'step': step, 'inlaw': inlaw} \
% {'gen': gen}
elif level < len(_father_level):
return _mother_level[level] % {'step': step, 'inlaw': inlaw} \
% {'gen': gen}
elif level < len(_level):
return 'nonno/a%(step)s%(inlaw)s della %(level_f)s generazione' % {
'level_f': _level_f[level],
'step': step, 'inlaw': inlaw} % {'gen': gen}
else:
return "l'ava%(step)s%(inlaw)s (%(level)d generazioni)" % {
'step': step, 'inlaw': inlaw,
'level': level} % {'gen': gen}
def get_son (self, level, step="", inlaw=""):
gen = "o"
if level < len(_son_level):
return _son_level[level] % {'step': step, 'inlaw': inlaw} \
% {'gen': gen}
elif level < len(_level):
return 'il nipote%(step)s%(inlaw)s diretto della %(level_f)s generazione' % {
'level_f': _level_f[level],
'step': step, 'inlaw': inlaw} % {'gen': gen}
else:
return "il discendente%(step)s%(inlaw)s diretto (%(level)d generazioni)" % {
'step': step, 'inlaw': inlaw,
'level': level} % {'gen': gen}
def get_daughter (self, level, step="", inlaw=""):
gen = "a"
if level < len(_daughter_level):
return _daughter_level[level] % {'step': step, 'inlaw': inlaw} \
% {'gen': gen}
elif level < len(_level):
return 'la nipote%(step)s%(inlaw)s diretta della %(level_f)s generazione' % {
'level_f': _level_f[level],
'step': step, 'inlaw': inlaw} % {'gen': gen}
else:
return "la discendente%(step)s%(inlaw)s diretta (%(level)d generazioni)" % {
'step': step, 'inlaw': inlaw,
'level': level} % {'gen': gen}
def get_uncle (self, level, step="", inlaw=""):
gen = "o"
if level < len(_brother_level):
return _brother_level[level] % {'step': step, 'inlaw': inlaw} \
% {'gen': gen}
elif level < len(_level):
return 'lo zio%(step)s%(inlaw)s della %(level_f)s generazione' % {
'level_f': _level_f[level],
'step': step, 'inlaw': inlaw} % {'gen': gen}
else:
return 'uno zio%(step)s%(inlaw)s lontano (%(level)d generazioni)' % {
'step': step, 'inlaw': inlaw,
'level': level} % {'gen': gen}
def get_aunt (self, level, step="", inlaw=""):
gen = "a"
if level < len(_brother_level):
return _sister_level[level] % {'step': step, 'inlaw': inlaw} \
% {'gen': gen}
elif level < len(_level):
return 'la zia%(step)s%(inlaw)s della %(level_f)s generazione' % {
'level_f': _level_f[level],
'step': step, 'inlaw': inlaw} % {'gen': gen}
else:
return 'una zia%(step)s%(inlaw)s lontana (%(level)d generazioni)' % {
'step': step, 'inlaw': inlaw,
'level': level} % {'gen': gen}
def get_nephew(self, level, step="", inlaw=""):
gen = "o"
if level < len(_nephew_level):
return _nephew_level[level] % {'step': step, 'inlaw': inlaw} \
% {'gen': gen}
elif level < len(_level):
return 'il nipote%(step)s%(inlaw)s ' \
'della %(level_f)s generazione' % {
'level_f': _level_f[level],
'step': step, 'inlaw': inlaw} % {'gen': gen}
else:
return 'un nipote%(step)s%(inlaw)s lontano ('\
'%(level)d generazioni)' % {
'step': step, 'inlaw': inlaw,
'level': level} % {'gen': gen}
def get_niece(self, level, step="", inlaw=""):
gen = "a"
if level < len(_nephew_level):
return _niece_level[level] % {'step': step, 'inlaw': inlaw} \
% {'gen': gen}
elif level < len(_level):
return 'la nipote%(step)s%(inlaw)s ' \
'della %(level_f)s generazione' % {
'level_f': _level_f[level],
'step': step, 'inlaw': inlaw} % {'gen': gen}
else:
return 'una nipote%(step)s%(inlaw)s lontana ('\
'%(level)d generazioni)' % {
'step': step, 'inlaw': inlaw,
'level': level} % {'gen': gen}
def get_male_cousin (self, levelA, levelB, step="", inlaw=""):
gen = "o"
return "il cugino%(step)s%(inlaw)s di %(level)d° grado"\
"(%(levA)d-%(levB)d)" \
% {'level': levelA+levelB-1,
'step': step, 'inlaw': inlaw,
'levA': levelA,
'levB': levelB} % {'gen': gen}
def get_female_cousin (self, levelA, levelB, step="", inlaw=""):
gen = "a"
return "la cugina%(step)s%(inlaw)s di %(level)d° grado"\
"(%(levA)d-%(levB)d)" \
% {'level': levelA+levelB-1,
'step': step, 'inlaw': inlaw,
'levA': levelA,
'levB': levelB} % {'gen': gen}
#-------------------------------------------------------------------------
#
# get_relationship
#
#-------------------------------------------------------------------------
def get_relationship(self,db, orig_person, other_person):
"""
returns a string representing the relationshp between the two people,
along with a list of common ancestors (typically father,mother)
"""
if orig_person is None:
return ("non definito",[])
if orig_person.get_handle() == other_person.get_handle():
return ('', [])
is_spouse = self.is_spouse(db, orig_person, other_person)
if is_spouse:
return (is_spouse,[])
#get_relationship_distance changed, first data is relation to
#orig person, apperently secondRel in this function
(secondRel,firstRel,common) = \
self.get_relationship_distance(db, orig_person, other_person)
if isinstance(common, basestring):
return (common,[])
elif common:
person_handle = common[0]
else:
return ("",[])
firstRel = len(firstRel)
secondRel = len(secondRel)
if firstRel == 0:
if secondRel == 0:
return ('',common)
elif other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_father(secondRel),common)
else:
return (self.get_mother(secondRel),common)
elif secondRel == 0:
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_son(firstRel),common)
else:
return (self.get_daughter(firstRel),common)
elif firstRel == 1:
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_uncle(secondRel),common)
else:
return (self.get_aunt(secondRel),common)
elif secondRel == 1:
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_nephew(firstRel-1),common)
else:
return (self.get_niece(firstRel-1),common)
else:
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_male_cousin(firstRel-1, secondRel-1), common)
else:
return (self.get_female_cousin(firstRel-1, secondRel-1), common)
def get_single_relationship_string(self, Ga, Gb, gender_a, gender_b,
reltocommon_a, reltocommon_b,
only_birth=True,
in_law_a=False, in_law_b=False):
"""
See Comment in Relationship Class (Relationship.py)
"""
if only_birth:
step = ''
else:
step = self.STEP
if in_law_a or in_law_b :
inlaw = self.INLAW
else:
inlaw = ''
if gender_b == gen.lib.Person.MALE:
rel_str = "un parente%s%s lontano" % (step, inlaw) % {'gen': 'o'}
elif gender_b == gen.lib.Person.FEMALE:
rel_str = "una parente%s%s lontana" % (step, inlaw) % {'gen': 'a'}
else:
rel_str = "uno dei parenti%s%s lontani" % (step, inlaw) % {'gen': 'i'}
if Gb == 0:
if Ga == 0:
rel_str = 'la stessa persona'
elif Ga == 1 and inlaw and not step:
if gender_b == gen.lib.Person.MALE:
rel_str = 'il suocero'
elif gender_b == gen.lib.Person.FEMALE:
rel_str = 'la suocera'
else:
rel_str = 'uno dei suoceri'
elif Ga == 1 and not inlaw and step:
if gender_b == gen.lib.Person.MALE:
rel_str = 'il patrigno'
elif gender_b == gen.lib.Person.FEMALE:
rel_str = 'la matrigna'
else:
rel_str = 'uno dei genitori adottivi'
elif gender_b == gen.lib.Person.MALE:
rel_str = self.get_father(Ga, step, inlaw)
elif gender_b == gen.lib.Person.FEMALE:
rel_str = self.get_mother(Ga, step, inlaw)
else:
rel_str = self.get_parent_unknown(Ga, step, inlaw)
elif Ga == 0:
if Gb == 1 and inlaw and not step:
if gender_b == gen.lib.Person.MALE:
rel_str = 'il genero'
elif gender_b == gen.lib.Person.FEMALE:
rel_str = 'la nuora'
else:
rel_str = 'genero/nuora'
elif gender_b == gen.lib.Person.MALE:
rel_str = self.get_son(Gb, step, inlaw)
else:
rel_str = self.get_daughter(Gb, step, inlaw)
elif Gb == 1:
if Ga == 1 and inlaw and not step:
if gender_b == gen.lib.Person.MALE:
rel_str = 'il cognato'
elif gender_b == gen.lib.Person.FEMALE:
rel_str = 'la cognata'
else:
rel_str = 'il cognato/a'
if gender_b == gen.lib.Person.MALE:
rel_str = self.get_uncle(Ga, step, inlaw)
else:
rel_str = self.get_aunt(Ga, step, inlaw)
elif Ga == 1:
if gender_b == gen.lib.Person.MALE:
rel_str = self.get_nephew(Gb-1, step, inlaw)
else:
rel_str = self.get_niece(Gb-1, step, inlaw)
else:
if gender_b == gen.lib.Person.MALE:
rel_str = self.get_male_cousin(Gb-1, Ga-1, step, inlaw)
else:
rel_str = self.get_female_cousin(Gb-1, Ga-1, step, inlaw)
return rel_str
def get_sibling_relationship_string(self, sib_type, gender_a, gender_b,
in_law_a=False, in_law_b=False):
""" Determine the string giving the relation between two siblings of
type sib_type.
Eg: b is the brother of a
Here 'brother' is the string we need to determine
For italian, we need to determine 'the brother'
This method gives more details about siblings than
get_single_relationship_string can do.
"""
if in_law_a or in_law_b :
inlaw = self.INLAW
else:
inlaw = ''
if sib_type == self.NORM_SIB or sib_type == self.UNKNOWN_SIB:
if not inlaw:
if gender_b == gen.lib.Person.MALE:
rel_str = self.get_uncle(1, '', '')
else:
rel_str = self.get_aunt(1, '', '')
else:
if gender_b == gen.lib.Person.MALE:
rel_str = 'il cognato'
elif gender_b == gen.lib.Person.FEMALE:
rel_str = 'la cognata'
else:
rel_str = 'il cognato/a'
elif sib_type == self.HALF_SIB_FATHER \
or sib_type == self.HALF_SIB_MOTHER \
or sib_type == self.STEP_SIB:
#Italian has no difference between half and step sibling!
if not inlaw:
if gender_b == gen.lib.Person.MALE:
rel_str = 'il fratellastro'
elif gender_b == gen.lib.Person.FEMALE:
rel_str = 'la sorellastra'
else:
rel_str = 'il fratellastro/sorellastra'
else:
if gender_b == gen.lib.Person.MALE:
rel_str = 'il fratellastro acquisito'
elif gender_b == gen.lib.Person.FEMALE:
rel_str = 'la sorellastra acquisita'
else:
rel_str = 'il fratellastro/sorellastra acquisito/a'
return rel_str
#-------------------------------------------------------------------------
#
# Function registration
#
#-------------------------------------------------------------------------
pmgr = PluginManager.get_instance()
pmgr.register_relcalc(RelationshipCalculator,
["it", "IT", "it_IT", "it_IT@euro", "it_IT.utf8"])
if __name__ == "__main__":
# Test function. Call it as follows from the command line (so as to find
# imported modules):
# export PYTHONPATH=/path/to/gramps/src
# python src/plugins/rel_it.py
"""TRANSLATORS, copy this if statement at the bottom of your
rel_xx.py module, and test your work with:
python src/plugins/rel_xx.py
"""
from Relationship import test
rc = RelationshipCalculator()
test(rc, True)
# Local variables:
# buffer-file-coding-system: utf-8
# End:

565
src/plugins/rel/rel_nl.py Normal file
View File

@@ -0,0 +1,565 @@
# -*- coding: utf-8 -*-
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2003-2005 Donald N. Allingham
# Copyright (C) 2008 Brian G. Matherly
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id$
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
import gen.lib
import Relationship
from gen.plug import PluginManager
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
_removed_level = [ " ",
" eerste",
" tweede",
" derde",
" vierde",
" vijfde",
" zesde",
" zevende",
" achtste",
" negende",
" tiende",
" elfde",
" twaalfde",
" dertiende",
" veertiende",
" vijftiende",
" zestiende",
" zeventiende",
" achttiende",
" negentiende",
" twintigste",
" eenentwintigste",
" tweeëntwintigste",
" drieëntwingste",
" vierentwingste",
" vijfentwintigste",
" zesentwintigste",
" zevenentwintigste",
" achtentwintigste",
" negenentwintigste",
" dertigste" ]
_parents_level = [ "",
"ouders",
"grootouders",
"overgrootouders",
"betovergrootouders",
"oudouders",
"oudgrootouders",
"oudovergrootouders",
"oudbetovergrootouders",
"stamouders",
"stamgrootouders", # gen 10
"stamovergrootouders",
"stambetovergrootouders",
"stamoudouders",
"stamoudgrootouders",
"stamoudovergrootouders",
"stamoudbetovergrootouders",
"edelouders",
"edelgrootoders",
"edelovergrootoudouders",
"edelbetovergrootouders", # gen 20
"edeloudouders",
"edeloudgrootouders",
"edeloudvergrootouders",
"edeloudbetovergrootouders",
"edelstamouders",
"edelstamgrootouders",
"edelstamovergrootouders",
"edelstambetovergrootouders",
"edelstamoudouders" ]
_father_level = [ "",
"%s%svader",
"%s%sgrootvader",
"%s%sovergrootvader",
"%s%sbetovergrootvader",
"%s%soudvader (generatie 5)",
"%s%soudgrootvader (generatie 6)",
"%s%soudovergrootvader (generatie 7)",
"%s%soudbetovergrootvader (generatie 8)",
"%s%sstamvader (generatie 9)",
"%s%sstamgrootvader (generatie 10)",
"%s%sstamovergrootvader (generatie 11)",
"%s%sstambetovergrootvader (generatie 12)",
"%s%sstamoudvader (generatie 13)",
"%s%sstamoudgrootvader (generatie 14)",
"%s%sstamoudovergrootvader (generatie 15)",
"%s%sstamoudbetovergrootvader (generatie 16)",
"%s%sedelvader (generatie 17)",
"%s%sedelgrootvader (generatie 18)",
"%s%sedelovergrootoudvader (generatie 19)",
"%s%sedelbetovergrootvader (generatie 20)",
"%s%sedeloudvader (generatie 21)",
"%s%sedeloudgrootvader (generatie 22)",
"%s%sedeloudvergrootvader (generatie 23)",
"%s%sedeloudbetovergrootvader (generatie 24)",
"%s%sedelstamvader (generatie 25)",
"%s%sedelstamgrootvader (generatie 26)",
"%s%sedelstamovergrootvader (generatie 27)",
"%s%sedelstambetovergrootvader (generatie 28)",
"%s%sedelstamoudvader (generatie 29)" ]
_mother_level = [ "",
"%s%smoeder",
"%s%sgrootmoeder",
"%s%sovergrootmoeder",
"%s%sbetovergrootmoeder",
"%s%soudmoeder (generatie 5)",
"%s%soudgrootmoeder (generatie 6)",
"%s%soudovergrootmoeder (generatie 7)",
"%s%soudbetovergrootmoeder (generatie 8)",
"%s%sstammoeder (generatie 9)",
"%s%sstamgrootmoeder (generatie 10)",
"%s%sstamovergrootmoeder (generatie 11)",
"%s%sstambetovergrootmoeder (generatie 12)",
"%s%sstamoudmoeder (generatie 13)",
"%s%sstamoudgrootmoeder (generatie 14)",
"%s%sstamoudovergrootmoeder (generatie 15)",
"%s%sstamoudbetovergrootmoeder (generatie 16)",
"%s%sedelmoeder (generatie 17)",
"%s%sedelgrootmoeder (generatie 18)",
"%s%sedelovergrootoudmoeder (generatie 19)",
"%s%sedelbetovergrootmoeder (generatie 20)",
"%s%sedeloudmoeder (generatie 21)",
"%s%sedeloudgrootmoeder (generatie 22)",
"%s%sedeloudvergrootmoeder (generatie 23)",
"%s%sedeloudbetovergrootmoeder (generatie 24)",
"%s%sedelstammoeder (generatie 25)",
"%s%sedelstamgrootmoeder (generatie 26)",
"%s%sedelstamovergrootmoeder (generatie 27)",
"%s%sedelstambetovergrootmoeder (generatie 28)",
"%s%sedelstamoudmoeder (generatie 29)" ]
_ouder_level = [ "",
"%s%souder ",
"%s%sgrootouder",
"%s%sovergrootouder",
"%s%sbetovergrootouder",
"%s%soudouder (generatie 5)",
"%s%soudgrootouder (generatie 6)",
"%s%soudovergrootouder (generatie 7)",
"%s%soudbetovergrootouder (generatie 8)",
"%s%sstamouder (generatie 9)",
"%s%sstamgrootouder (generatie 10)",
"%s%sstamovergrootouder (generatie 11)",
"%s%sstambetovergrootouder (generatie 12)",
"%s%sstamoudouder (generatie 13)",
"%s%sstamoudgrootouder (generatie 14)",
"%s%sstamoudovergrootouder (generatie 15)",
"%s%sstamoudbetovergrootouder (generatie 16)",
"%s%sedelouder (generatie 17)",
"%s%sedelgrootouder (generatie 18)",
"%s%sedelovergrootoudouder (generatie 19)",
"%s%sedelbetovergrootouder (generatie 20)",
"%s%sedeloudouder (generatie 21)",
"%s%sedeloudgrootouder (generatie 22)",
"%s%sedeloudvergrootouder (generatie 23)",
"%s%sedeloudbetovergrootouder (generatie 24)",
"%s%sedelstamouder (generatie 25)",
"%s%sedelstamgrootouder (generatie 26)",
"%s%sedelstamovergrootouder (generatie 27)",
"%s%sedelstambetovergrootouder (generatie 28)",
"%s%sedelstamoudouder (generatie 29)" ]
_son_level = [ "",
"%s%szoon",
"%s%skleinzoon",
"%s%sachterkleinzoon",
"%s%sachterachterkleinzoon",
"%s%sachterachterachterkleinzoon"]
_daughter_level = [ "",
"%s%sdochter",
"%s%skleindochter",
"%s%sachterkleindochter",
"%s%sachterachterkleindochter",
"%s%sachterachterachterkleindochter"]
_kind_level = [ "",
"%s%skind",
"%s%skleinkind",
"%s%sachterkleinkind",
"%s%sachterachterkleinkind",
"%s%sachterachterachterkleinkind"]
_nephew_level = [ "",
"%s%sneef",
"%s%sachterneef",
"%s%sachterachterneef" ]
_niece_level = [ "",
"%s%snicht",
"%s%sachternicht",
"%s%sachterachternicht"]
_aunt_level = [ "",
"%s%stante",
"%s%sgroottante",
"%s%sovergroottante",
"%s%sbetovergroottante",
"%s%soudtante"]
_uncle_level = [ "",
"%s%soom",
"%s%sgrootoom",
"%s%sovergrootoom",
"%s%sbetovergrootoom",
"%s%soudoom"]
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
class RelationshipCalculator(Relationship.RelationshipCalculator):
#sibling strings
STEP= 'stief'
HALF = 'half'
INLAW='aangetrouwde '
def __init__(self):
Relationship.RelationshipCalculator.__init__(self)
def get_parents(self, level):
if level > len(_parents_level)-1:
return "verre voorouders (%d generaties)" % level
else:
return _parents_level[level]
def _get_father(self, level, step='', inlaw=''):
"""Internal Dutch method to create relation string
"""
if level > len(_father_level)-1:
return "verre %s%svoorvader (%d generaties)" % (inlaw, step, level)
else:
return _father_level[level] % (inlaw, step)
def _get_son(self, level, step='', inlaw=''):
"""Internal Dutch method to create relation string
"""
if level < len(_son_level):
return _son_level[level] % (inlaw, step)
else:
return "verre %s%sachterkleinzoon (%d generaties)" % (inlaw,
step, level)
def _get_mother(self,level, step='', inlaw=''):
"""Internal Dutch method to create relation string
"""
if level > len(_mother_level)-1:
return "verre %s%svoormoeder (%d generaties)" % (inlaw, step, level)
else:
return _mother_level[level] % (inlaw, step)
def _get_daughter(self, level, step='', inlaw=''):
"""Internal Dutch method to create relation string
"""
if level > len(_daughter_level)-1:
return "verre %s%sachterkleindochter (%d generaties)" % (inlaw,
step, level)
else:
return _daughter_level[level] % (inlaw, step)
def _get_parent_unknown(self, level, step='', inlaw=''):
"""Internal Dutch method to create relation string
"""
if level > len(_ouder_level)-1:
return "verre %s%svoorouder (%d generaties)" % (inlaw, step, level)
elif level == 1:
return _mother_level[level] % (inlaw, step) + ' of ' + \
_father_level[level] % (inlaw, step)
else:
return _ouder_level[level] % (inlaw, step)
def _get_child_unknown(self, level, step='', inlaw=''):
"""Internal Dutch method to create relation string
"""
if level > len(_kind_level)-1:
return "ver %s%sachterkleinkind (%d generaties)" % (inlaw, step,
level)
else:
return _kind_level[level] % (inlaw, step)
def _get_aunt(self, level, removed, step='', inlaw=''):
"""Internal Dutch method to create relation string
"""
if removed == 1 and level < len(_aunt_level):
return _aunt_level[level] % (inlaw, step)
elif removed == 1:
return "verre %s%stante (%d generaties)" % (inlaw, step, level)
elif level > len(_aunt_level)-1 and removed > len(_removed_level) -1:
return "verre %s%stante (%d generaties, %d graden)" % (inlaw, step,
level, removed)
elif level > len(_aunt_level)-1:
return "verre %s%stante van de%s graad (%d generaties)" % (inlaw,
step, _removed_level[removed], level)
else:
return _aunt_level[level] % (inlaw, step) \
+ _removed_level[removed] + " graad"
def _get_uncle(self, level, removed, step='', inlaw=''):
"""Internal Dutch method to create relation string
"""
if removed == 1 and level < len(_uncle_level):
return _uncle_level[level] % (inlaw, step)
elif removed == 1:
return "verre %s%soom (%d generaties)" % (inlaw, step, level)
elif level > len(_uncle_level)-1 and removed > len(_removed_level) -1:
return "verre %s%soom (%d generaties, %d graden)" % (inlaw, step,
level, removed)
elif level > len(_uncle_level)-1:
return "verre %s%soom van de%s graad (%d generaties)" % (inlaw,
step, _removed_level[removed], level)
else:
return _uncle_level[level] % (inlaw, step) \
+ _removed_level[removed] + " graad"
def _get_sibling(self, level, step='', inlaw=''):
"""overwrite of English method to return unknown gender sibling
"""
assert(level == 1)
return self._get_male_cousin(0, step=step, inlaw=inlaw) + ' of ' \
+ self._get_female_cousin(0, step=step, inlaw=inlaw)
def _get_nephew(self, level, removed=1, step='', inlaw=''):
"""Internal Dutch method to create relation string
"""
if removed == 1 and level < len(_nephew_level):
return _nephew_level[level] % (inlaw, step)
elif removed == 1:
return "verre %s%sneef (%d generaties)" % (inlaw, step, level)
elif level > len(_nephew_level)-1 and removed > len(_removed_level) -1:
return "verre %s%sneef (%d generaties, %d graden)" % (inlaw, step,
level, removed)
elif level > len(_nephew_level)-1:
return "verre %s%sneef van de%s graad (%d generaties)" % (inlaw, step,
_removed_level[removed], level)
else:
return _nephew_level[level] % (inlaw, step) \
+ _removed_level[removed] + " graad"
def _get_niece(self, level, removed=1, step='', inlaw=''):
"""Internal Dutch method to create relation string
"""
if removed == 1 and level < len(_niece_level):
return _niece_level[level] % (inlaw, step)
elif removed == 1:
return "verre %s%snicht (%d generaties)" % (inlaw, step, level)
elif level > len(_niece_level)-1 and removed > len(_removed_level) -1:
return "verre %s%snicht (%d generaties, %d graden)" % (inlaw, step,
level, removed)
elif level > len(_niece_level)-1:
return "verre %s%snicht van de%s graad (%d generaties)"% (inlaw,
step, _removed_level[removed], level)
else:
return _niece_level[level] % (inlaw, step) \
+ _removed_level[removed] + " graad"
def _get_male_cousin(self, removed, step='', inlaw=''):
"""Specific Dutch thing, the nieces/nephews on same level are called
going sideways in a branch as the nieces/newphews going downward
from your brother/sisters. This used to be called "kozijn"
"""
removed = removed - 1
if removed > len(_removed_level)-1:
return "verre %s%sneef (kozijn, %d graden)" % (inlaw, step,
removed)
elif removed == 0:
return "%s%sbroer" % (inlaw, step)
else:
return "%s%sneef (kozijn)" % (inlaw, step) \
+_removed_level[removed] + " graad"
def _get_female_cousin(self, removed, step='', inlaw=''):
"""Specific Dutch thing, the nieces/nephews on same level are called
going sideways in a branch as the nieces/newphews going downward
from your brother/sisters. This used to be called "kozijn"
"""
removed = removed - 1
if removed > len(_removed_level)-1:
return "verre %s%snicht (kozijn, %d graden)" % (inlaw, step,
removed)
elif removed == 0:
return "%s%szus" % (inlaw, step)
else:
return "%s%snicht (kozijn)" % (inlaw, step) \
+ _removed_level[removed] + " graad"
def get_single_relationship_string(self, Ga, Gb, gender_a, gender_b,
reltocommon_a, reltocommon_b,
only_birth=True,
in_law_a=False, in_law_b=False):
"""
Return a string representing the relationship between the two people,
see english method, eg b is father of a
"""
if only_birth:
step = ''
else:
step = self.STEP
if in_law_a or in_law_b :
inlaw = self.INLAW
else:
inlaw = ''
rel_str = "verre %s%sfamilie" % (inlaw, step)
if Gb == 0:
#b is ancestor
if Ga == 0:
rel_str = 'zelfde persoon'
elif Ga == 1 and inlaw and not step:
if gender_b == gen.lib.Person.MALE:
rel_str = 'schoonvader'
elif gender_b == gen.lib.Person.FEMALE:
rel_str = 'schoonmoeder'
else:
rel_str = 'schoonouder'
elif gender_b == gen.lib.Person.MALE:
rel_str = self._get_father(Ga, step, inlaw)
elif gender_b == gen.lib.Person.FEMALE:
rel_str = self._get_mother(Ga, step, inlaw)
else:
rel_str = self._get_parent_unknown(Ga, step, inlaw)
elif Ga == 0:
#a is descendant
if Gb == 1 and inlaw and not step:
if gender_b == gen.lib.Person.MALE:
rel_str = 'schoonzoon'
elif gender_b == gen.lib.Person.FEMALE:
rel_str = 'schoondochter'
else:
rel_str = 'schoonzoon of -dochter'
elif Gb == 1 and inlaw and step:
#inlaw stepchild
if gender_b == gen.lib.Person.MALE:
rel_str = 'aangetrouwde stiefzoon'
elif gender_b == gen.lib.Person.FEMALE:
rel_str = 'aangetrouwde stiefdochter'
else:
rel_str = 'aangetrouwde stiefzoon of dochter'
elif gender_b == gen.lib.Person.MALE:
rel_str = self._get_son(Gb, step, inlaw)
elif gender_b == gen.lib.Person.FEMALE:
rel_str = self._get_daughter(Gb, step, inlaw)
else:
rel_str = self._get_child_unknown(Gb, step, inlaw)
elif Ga > Gb:
#b is higher in the branch, in english uncle/aunt or
#cousin up, in dutch always 'oom/tante'
if gender_b == gen.lib.Person.MALE:
rel_str = self._get_uncle(Ga - Gb, Gb, step, inlaw)
else:
rel_str = self._get_aunt(Ga - Gb, Gb, step, inlaw)
elif Ga < Gb:
#b is lower in the branch, in english niece/nephew or
#cousin down, in dutch always 'neef/nicht'
if gender_b == gen.lib.Person.MALE:
rel_str = self._get_nephew(Gb - Ga, Ga, step, inlaw)
else:
rel_str = self._get_niece(Gb - Ga, Ga, step, inlaw)
else:
# people on the same level Ga == Gb
if gender_b == gen.lib.Person.MALE:
rel_str = self._get_male_cousin(Ga, step, inlaw)
else:
rel_str = self._get_female_cousin(Ga, step, inlaw)
return rel_str
def get_sibling_relationship_string(self, sib_type, gender_a, gender_b,
in_law_a=False, in_law_b=False):
""" Determine the string giving the relation between two siblings of
type sib_type.
Eg: b is the brother of a
Here 'brother' is the string we need to determine
This method gives more details about siblings than
get_single_relationship_string can do.
DIFFERENT HELPER FUNCTIONS THAN ENGLISH
"""
if sib_type == self.NORM_SIB or sib_type == self.UNKNOWN_SIB:
typestr = ''
elif sib_type == self.HALF_SIB_FATHER \
or sib_type == self.HALF_SIB_MOTHER:
typestr = self.HALF
elif sib_type == self.STEP_SIB:
typestr = self.STEP
if in_law_a or in_law_b :
inlaw = self.INLAW
else:
inlaw = ''
if inlaw and not typestr:
if gender_b == gen.lib.Person.MALE:
rel_str = 'schoonbroer'
elif gender_b == gen.lib.Person.FEMALE:
rel_str = 'schoonzus'
else:
rel_str = 'schoonzus/broer'
else:
if gender_b == gen.lib.Person.MALE:
rel_str = self._get_male_cousin(1, typestr, inlaw)
else:
rel_str = self._get_female_cousin(1, typestr, inlaw)
return rel_str
#-------------------------------------------------------------------------
#
# Register this class with the Plugins system
#
#-------------------------------------------------------------------------
pmgr = PluginManager.get_instance()
pmgr.register_relcalc(RelationshipCalculator,
["nl", "NL", "nl_NL", "nl_BE", "nederlands", "Nederlands", "nl_NL.UTF8",
"nl_BE.UTF8","nl_NL@euro", "nl_NL.UTF8@euro","nl_BE@euro",
"dutch","Dutch", "nl_NL.UTF-8", "nl_BE.UTF-8","nl_NL.utf-8",
"nl_BE.utf-8","nl_NL.utf8", "nl_BE.UTF-8", "nl_BE.UTF8@euro"])
if __name__ == "__main__":
# Test function. Call it as follows from the command line (so as to find
# imported modules):
# export PYTHONPATH=/path/to/gramps/src
# python src/plugins/rel_nl.py
"""TRANSLATORS, copy this if statement at the bottom of your
rel_xx.py module, and test your work with:
python src/plugins/rel_xx.py
"""
from Relationship import test
rc = RelationshipCalculator()
test(rc, True)

280
src/plugins/rel/rel_no.py Normal file
View File

@@ -0,0 +1,280 @@
# -*- coding: utf-8 -*-
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2003-2005 Donald N. Allingham
# Copyright (C) 2008 Brian G. Matherly
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id$
# Written by Alex Roitman, largely based on Relationship.py by Don Allingham
# and on valuable input from Frode Jemtland
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
import gen.lib
import Relationship
import types
from gen.plug import PluginManager
#-------------------------------------------------------------------------
#
# Norwegian-specific definitions of relationships
#
#-------------------------------------------------------------------------
_cousin_level = [ "", "", #brother/sister, fetter/kusine -- these are taken care of separately
"tremenning", "firemenning", "femmenning",
"seksmenning", "sjumenning", "åttemenning",
"nimenning", "timenning", "elvemenning",
"tolvmenning", "tretenmenning", "fjortenmenning",
"femtenmenning", "sekstenmenning", "syttenmenning",
"attenmenning", "nittenmenning", "tyvemenning" ]
_cousin_terms = _cousin_level + ["fetter","kusine"]
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
class RelationshipCalculator(Relationship.RelationshipCalculator):
def __init__(self):
Relationship.RelationshipCalculator.__init__(self)
def get_parents(self,level):
if level == 0:
return "forelder"
else:
return "ane i %d-te generationen" % (level+1)
def get_cousin(self,level):
if level>len(_cousin_level)-1:
# FIXME: use Norwegian term term here,
# UPDATED by Frode: unsure about the expretion "en fjern slektning", should it be just "fjern slektning".
# Need to see it used in the program to get the understanding.
return "en fjern slektning"
else:
return _cousin_level[level]
def pair_up(self,rel_list):
result = []
item = ""
for word in rel_list[:]:
if not word:
continue
if word in _cousin_terms:
if item:
result.append(item)
item = ""
result.append(word)
continue
if item:
if word == 'sønne':
word = 'sønn'
result.append(item + word)
item = ""
else:
item = word
if item:
result.append(item)
gen_result = [ item + 's' for item in result[0:-1] ]
return ' '.join(gen_result+result[-1:])
def get_direct_ancestor(self,person,rel_string):
result = []
for ix in range(len(rel_string)):
if rel_string[ix] == 'f':
result.append('far')
else:
result.append('mor')
return self.pair_up(result)
def get_direct_descendant(self,person,rel_string):
result = []
for ix in range(len(rel_string)-2,-1,-1):
if rel_string[ix] == 'f':
result.append('sønne')
else:
result.append('datter')
if person.get_gender() == gen.lib.Person.MALE:
result.append('sønn')
else:
result.append('datter')
return self.pair_up(result)
def get_ancestors_cousin(self,person,rel_string_long,rel_string_short):
result = []
removed = len(rel_string_long)-len(rel_string_short)
level = len(rel_string_short)-1
for ix in range(removed):
if rel_string_long[ix] == 'f':
result.append('far')
else:
result.append('mor')
if level > 1:
result.append(self.get_cousin(level))
elif person.get_gender() == gen.lib.Person.MALE:
result.append('fetter')
else:
result.append('kusine')
main_string = self.get_two_way_rel(person,rel_string_short,rel_string_long)
aux_string = self.pair_up(result)
return "%s (%s)" % (main_string,aux_string)
def get_cousins_descendant(self,person,rel_string_long,rel_string_short):
result = []
aux_string = ""
removed = len(rel_string_long)-len(rel_string_short)-1
level = len(rel_string_short)-1
if level > 1: # Cousin terms without gender
result.append(self.get_cousin(level))
elif level == 1: # gender-dependent fetter/kusine
if rel_string_long[removed] == 'f':
result.append('fetter')
else:
result.append('kusine')
elif rel_string_long[removed] == 'f':
result.append('bror')
else:
result.append('søster')
for ix in range(removed-1,-1,-1):
if rel_string_long[ix] == 'f':
result.append('sønn')
else:
result.append('datter')
if person.get_gender() == gen.lib.Person.MALE:
result.append('sønn')
else:
result.append('datter')
main_string = self.get_two_way_rel(person,rel_string_long,rel_string_short)
if level:
aux_string = " (%s)" % self.pair_up(result)
return "%s%s" % (main_string,aux_string)
def get_ancestors_brother(self,rel_string):
result = []
for ix in range(len(rel_string)-1):
if rel_string[ix] == 'f':
result.append('far')
else:
result.append('mor')
result.append('bror')
return self.pair_up(result)
def get_ancestors_sister(self,rel_string):
result = []
for ix in range(len(rel_string)-1):
if rel_string[ix] == 'f':
result.append('far')
else:
result.append('mor')
result.append('søster')
return self.pair_up(result)
def get_two_way_rel(self,person,first_rel_string,second_rel_string):
result = []
for ix in range(len(second_rel_string)-1):
if second_rel_string[ix] == 'f':
result.append('far')
else:
result.append('mor')
if len(first_rel_string)>1:
if first_rel_string[-2] == 'f':
result.append('bror')
else:
result.append('søster')
for ix in range(len(first_rel_string)-3,-1,-1):
if first_rel_string[ix] == 'f':
result.append('sønne')
else:
result.append('datter')
if person.get_gender() == gen.lib.Person.MALE:
result.append('sønn')
else:
result.append('datter')
else:
if person.get_gender() == gen.lib.Person.MALE:
result.append('bror')
else:
result.append('søster')
return self.pair_up(result)
def get_relationship(self,db, orig_person, other_person):
"""
Return a string representing the relationshp between the two people,
along with a list of common ancestors (typically father,mother)
Special cases: relation strings "", "undefined" and "spouse".
"""
if orig_person is None:
return ("undefined",[])
if orig_person.get_handle() == other_person.get_handle():
return ('', [])
is_spouse = self.is_spouse(db, orig_person, other_person)
if is_spouse:
return (is_spouse,[])
#get_relationship_distance changed, first data is relation to
#orig person, apperently secondRel in this function
(secondRel,firstRel,common) = \
self.get_relationship_distance(db, orig_person, other_person)
if isinstance(common, basestring):
return (common,[])
elif common:
person_handle = common[0]
else:
return ("",[])
if not firstRel:
if not secondRel:
return ('',common)
else:
return (self.get_direct_ancestor(other_person,secondRel),common)
elif not secondRel:
return (self.get_direct_descendant(other_person,firstRel),common)
elif len(firstRel) == 1:
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_ancestors_brother(secondRel),common)
else:
return (self.get_ancestors_sister(secondRel),common)
elif len(secondRel) >= len(firstRel):
return (self.get_ancestors_cousin(other_person,secondRel,firstRel),common)
else:
return (self.get_cousins_descendant(other_person,firstRel,secondRel),common)
#-------------------------------------------------------------------------
#
# Register this class with the Plugins system
#
#-------------------------------------------------------------------------
pmgr = PluginManager.get_instance()
pmgr.register_relcalc(RelationshipCalculator,
["nb","nn","no", "nb_NO","nn_NO","no_NO","nb_NO.UTF8","nn_NO.UTF8","no_NO.UTF8",
"nb_NO.UTF-8","nn_NO.UTF-8","no_NO.UTF-8",
"nb_NO.utf-8","nn_NO.utf-8","no_NO.utf-8",
"nb_NO.iso88591","nn_NO.iso88591","no_NO.iso88591",
"nynorsk","Nynorsk"])

913
src/plugins/rel/rel_pl.py Normal file
View File

@@ -0,0 +1,913 @@
# -*- coding: utf-8 -*-
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2003-2005 Donald N. Allingham
# Copyright (C) 2008 Brian G. Matherly
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Rewritten in 2008 for 3.x version by Łukasz Rymarczyk
# Written in 2007 by Piotr Czubaszek, largely based on rel_de.py by Alex Roitman.
# PL: Po objaśnienia oznaczania relacji zobacz Relationship.py
# EN: For more information see Relationship.py
#
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
import gen.lib
import Relationship
import types
from gettext import gettext as _
from gen.plug import PluginManager
#-------------------------------------------------------------------------
#
# Polish-specific definitions of relationships
#
#-------------------------------------------------------------------------
# określa liczebnik porządkowy
_level_name = [ "pierwszego", "drugiego", "trzeciego", "czwartego", "piątego",
"szóstego", "siódmego", "ósmego", "dziewiątego", "dziesiątego",
"jedenastego", "dwunastego","trzynastego", "czternastego", "piętnastego",
"szesnastego", "siedemnastego", "osiemnastego","dziewiętnastego", "dwudziestego", ]
_father_level = [ "",
"ojciec",
"dziadek",
"pradziadek",
"prapradziadek",
"praprapradziadek",
"prapraprapradziadek",
"praprapraprapradziadek",
"prapraprapraprapradziadek",
"praprapraprapraprapradziadek",
"prapraprapraprapraprapradziadek",
]
_mother_level = [ "",
"matka",
"babcia",
"prababcia",
"praprababcia",
"prapraprababcia",
"praprapraprababcia",
"prapraprapraprababcia",
"praprapraprapraprababcia",
"prapraprapraprapraprababcia",
"praprapraprapraprapraprababcia",
]
_son_level = [ "",
"syn",
"wnuk",
"prawnuk",
"praprawnuk",
"prapraprauwnuk",
"praprapraprauwnuk",
"prapraprapraprawnuk",
"praprapraprapraprawnuk",
"prapraprapraprapraprawnuk",
"praprapraprapraprapraprawnuk",
]
_daughter_level = [ "",
"córka",
"wnuczka",
"prawnuczka",
"praprawnuczka",
"prapraprauwnuczka",
"praprapraprauwnuczka",
"prapraprapraprawnuczka",
"praprapraprapraprawnuczka",
"prapraprapraprapraprawnuczka",
"praprapraprapraprapraprawnuczka",
]
_sister_level_of_male = [ "", "siostra", "ciotka stryjeczna",
"babcia stryjeczna",
"prababcia stryjeczna",
"praprababcia stryjeczna",
"prapraprababcia stryjeczna",
"praprapraprababcia stryjeczna",
"prapraprapraprababcia stryjeczna",
"praprapraprapraprababcia stryjeczna",
"prapraprapraprapraprababcia stryjeczna",
"praprapraprapraprapraprababcia stryjeczna",
]
_sister_level_of_female = [ "", "siostra", "ciotka",
"babcia cioteczna",
"prababcia cioteczna",
"praprababcia cioteczna",
"prapraprababcia cioteczna",
"praprapraprababcia cioteczna",
"prapraprapraprababcia cioteczna",
"praprapraprapraprababcia cioteczna",
"prapraprapraprapraprababcia cioteczna",
"praprapraprapraprapraprababcia cioteczna",
]
_brother_level_of_male = [ "", "brat", "stryj",
"dziadek stryjeczny",
"pradziadek stryjeczny",
"prapradziadek stryjeczny",
"praprapradziadek stryjeczny",
"prapraprapradziadek stryjeczny",
"praprapraprapradziadek stryjeczny",
"prapraprapraprapradziadek stryjeczny",
"praprapraprapraprapradziadek stryjeczny",
"prapraprapraprapraprapradziadek stryjeczny",
]
_brother_level_of_female = [ "", "brat", "wuj",
"dziadek cioteczny",
"pradziadek cioteczny",
"prapradziadek cioteczny",
"praprapradziadek cioteczny",
"prapraprapradziadek cioteczny",
"praprapraprapradziadek cioteczny",
"prapraprapraprapradziadek cioteczny",
"praprapraprapraprapradziadek cioteczny",
"prapraprapraprapraprapradziadek cioteczny",
]
_nephew_level_of_brothers_son = [ "", "bratanek",
"syn bratanka",
"wnuk bratanka",
"prawnuk bratanka",
"praprawnuk bratanka",
"prapraprawnuk bratanka",
"praprapraprawnuk bratanka",
"prapraprapraprawnuk bratanka",
"praprapraprapraprawnuk bratanka",
"prapraprapraprapraprawnuk bratanka",
]
_nephew_level_of_brothers_daughter = [ "", "bratanica",
"syn bratanicy",
"wnuk bratanicy",
"prawnuk bratanicy",
"praprawnuk bratanicy",
"prapraprawnuk bratanicy",
"praprapraprawnuk bratanicy",
"prapraprapraprawnuk bratanicy",
"praprapraprapraprawnuk bratanicy",
"prapraprapraprapraprawnuk bratanicy",
"praprapraprapraprapraprawnuk bratanicy",
]
_nephew_level_of_sisters_son = [ "", "siostrzeniec",
"syn siostrzeńca",
"wnuk siostrzeńca",
"prawnuk siostrzeńca",
"praprawnuk siostrzeńca",
"prapraprawnuk siostrzeńca",
"praprapraprawnuk siostrzeńca",
"prapraprapraprawnuk siostrzeńca",
"praprapraprapraprawnuk siostrzeńca",
"prapraprapraprapraprawnuk siostrzeńca",
]
_nephew_level_of_sisters_daughter = [ "", "siostrzenica",
"syn siostrzenicy",
"wnuk siostrzenicy",
"prawnuk siostrzenicy",
"praprawnuk siostrzenicy",
"prapraprawnuk siostrzenicy",
"praprapraprawnuk siostrzenicy",
"prapraprapraprawnuk siostrzenicy",
"praprapraprapraprawnuk siostrzenicy",
"prapraprapraprapraprawnuk siostrzenicy",
]
_niece_level_of_brothers_son = [ "", "bratanica",
"córka bratanka",
"wnuczka bratanka",
"prawnuczka bratanka",
"praprawnuczka bratanka",
"prapraprawnuczka bratanka",
"praprapraprawnuczka bratanka",
"prapraprapraprawnuczka bratanka",
"praprapraprapraprawnuczka bratanka",
]
_niece_level_of_brothers_daughter = [ "", "bratanica",
"córka bratanicy",
"wnuczka bratanicy",
"prawnuczka bratanicy",
"praprawnuczka bratanicy",
"prapraprawnuczka bratanicy",
"praprapraprawnuczka bratanicy",
"prapraprapraprawnuczka bratanicy",
"praprapraprapraprawnuczka bratanicy",
]
_niece_level_of_sisters_son = [ "", "siostrzenica",
"córka siostrzeńca",
"wnuczka siostrzeńca",
"prawnuczka siostrzeńca",
"praprawnuczka siostrzeńca",
"prapraprawnuczka siostrzeńca",
"praprapraprawnuczka siostrzeńca",
"prapraprapraprawnuczka siostrzeńca",
"praprapraprapraprawnuczka siostrzeńca",
]
_niece_level_of_sisters_daughter = [ "", "siostrzenica",
"córka siostrzenicy",
"wnuczka siostrzenicy",
"prawnuczka siostrzenicy",
"praprawnuczka siostrzenicy",
"prapraprawnuczka siostrzenicy",
"praprapraprawnuczka siostrzenicy",
"prapraprapraprawnuczka siostrzenicy",
"praprapraprapraprawnuczka siostrzenicy",
]
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
class RelationshipCalculator(Relationship.RelationshipCalculator):
def __init__(self):
Relationship.RelationshipCalculator.__init__(self)
#--------------------------------------------------
#
#
#
#--------------------------------------------------
def get_son(self, level, inlaw=''):
"""
Podaje tekst zawierający informację, jak bardzo potomek męski
(np. syn) jest spokrewniony do danej osoby
"""
# Określ, czy osoba jest przybraną, czy rodzoną
if inlaw == '':
t_inlaw =""
else:
t_inlaw ="przybrany "
# TODO: dodać rozpoznawanie pasierb/pasierbica
if level >= 0 and level < len(_son_level):
return t_inlaw +_son_level[level]
elif level >= len(_son_level) \
and (level - 1) < len(_level_name):
return t_inlaw + \
"potomek męski %s pokolenia" % _level_name[level - 1]
else:
return t_inlaw + \
"potomek męski w %d pokoleniu" % level
def get_daughter(self, level, inlaw=''):
"""
Podaje tekst zawierający informację, jak bardzo potomek żeński
(np. córka) jest spokrewniony do danej osoby
"""
# Określ, czy osoba jest przybraną, czy rodzoną
# + stwórz obie formy (męską i żeńską)
if inlaw == '':
t_inlaw =""
t_inlawM =""
else:
t_inlaw ="przybrana "
t_inlawM ="przybrany "
# TODO: dodać rozpoznawanie pasierb/pasierbica
if level >= 0 and level < len(_daughter_level):
return t_inlaw + _daughter_level[level]
elif level >= len(_daughter_level) \
and (level - 1) < len(_level_name):
return t_inlawM + \
"potomek żeński %s pokolenia" % _level_name[level - 1]
else:
return t_inlawM + \
"potomek żeński w %d pokoleniu" % level
def get_child_unknown(self, level, inlaw=''):
"""
Podaje tekst zawierający informację, jak bardzo potomek
o nieokreślonej płci jest spokrewniony dodanej osoby
"""
# Określ, czy osoba jest przybraną, czy rodzoną
if inlaw == '':
t_inlaw =""
else:
t_inlaw ="przybrany "
if level == 1:
if inlaw == '' :
return "dziecko"
else:
return "przybrane dziecko"
elif level >= 1 and (level - 1) < len(_level_name):
return t_inlaw + "potomek %s pokolenia" % _level_name[level - 1]
else:
return t_inlaw + "potomek w %d pokoleniu" % level
def get_sword_distaff(self, level, reltocommon, spacebefore = ""):
"""
PL: Generuje relację po mieczu/po kądzieli
EN: Generate relation 'by sword' or 'by distaff', polish specific
"""
if level <=1:
return ""
elif level == 2:
# dziadek/babcia
if reltocommon[0] == self.REL_FATHER:
# ze strony rodzonego ojca
return spacebefore + "po mieczu"
elif reltocommon[0] == self.REL_MOTHER:
# ze strony rodzonej matki
return spacebefore + "po kądzieli"
else:
# relacja inna niż rodzona
return ""
elif level == 3:
# pradziadek/prababcia
if (reltocommon[0] == self.REL_FATHER) \
& (reltocommon[1] == self.REL_FATHER):
# pradziadek od dziadka ze strony ojca
return spacebefore + "podwójnego miecza"
elif (reltocommon[0] == self.REL_FATHER) \
& (reltocommon[1] == self.REL_MOTHER):
# pradziadek od babci ze strony ojca
return spacebefore + "raz po mieczu, dalej po kądzieli"
elif (reltocommon[0] == self.REL_MOTHER) \
& (reltocommon[1] == self.REL_FATHER):
# pradziadek od dziadka ze strony matki
return spacebefore + "raz po kądzieli, dalej po mieczu"
elif (reltocommon[0] == self.REL_MOTHER) \
& (reltocommon[1] == self.REL_MOTHER):
# pradziadek od babci ze strony matki
return spacebefore + "podwójnej kądzieli"
else:
# relacja inna niż rodzona
return ""
elif level == 4:
# prapradziadek/praprababcia
if (reltocommon[0] == self.REL_FATHER) \
& (reltocommon[1] == self.REL_FATHER) \
& (reltocommon[2] == self.REL_FATHER):
# tzw. linia męska
return spacebefore + "potrójnego miecza"
if (reltocommon[0] == self.REL_FATHER) \
& (reltocommon[1] == self.REL_FATHER) \
& (reltocommon[2] == self.REL_FATHER):
# tzw. linia żeńska
return spacebefore + "potrójnego miecza"
else:
return ""
else:
return ""
def get_father(self, level, reltocommon, inlaw=''):
"""
Podaje tekst zawierający informację, jak bardzo przodek męski
(np. ojciec) jest spokrewniony do danej osoby
"""
if inlaw == '':
t_inlaw =""
else:
t_inlaw ="przybrany "
if level >= 0 and level < len(_father_level):
# Jeśli znasz bezpośrednią nazwę relacji, to ją zastosuj
if level == 1:
# ojciec
return t_inlaw + _father_level[level]
elif (level >= 2) & (level <= 4):
# dziadek, pradziadek, prapradziadek
return t_inlaw + _father_level[level] \
+ self.get_sword_distaff(level, reltocommon, ' ')
else:
return t_inlaw + _father_level[level]
elif level >= len(_father_level) \
and (level - 1) < len(_level_name):
# jeśli istnieje liczebnik dla danej liczby
return t_inlaw + \
"przodek męski %s pokolenia" % (_level_name[level - 1])
else:
# dla pozostałych przypadków wypisz relację liczbowo
return t_inlaw + \
"przodek męski w %d pokoleniu" % level
def get_mother(self, level, reltocommon, inlaw=''):
"""
Podaje tekst zawierający informację, jak bardzo przodek żeński
(np. matka) jest spokrewniony do danej osoby
"""
if inlaw == '':
t_inlaw =""
else:
t_inlaw ="przybrana "
if level >= 0 and level < len(_mother_level):
# Jeśli znasz bezpośrednią nazwę relacji, to ją zastosuj
if level == 1:
# matka
return t_inlaw + _mother_level[level]
elif (level >= 2) & (level <= 4):
# babcia, prababcia, praprababcia
return t_inlaw + _mother_level[level] \
+ self.get_sword_distaff(level, reltocommon, ' ')
else:
return t_inlaw + _mother_level[level]
elif level >= len(_mother_level) \
and (level - 1) < len(_level_name):
# jeśli istnieje liczebnik dla danej liczby
return t_inlaw + \
"przodek żeński %s pokolenia" % (_level_name[level - 1])
else:
# dla pozostałych przypadków wypisz relację liczbowo
return t_inlaw +"przodek żeński w %d pokoleniu" % level
def get_parent_unknown(self, level, inlaw=''):
"""
Podaje tekst zawierający informację, jak bardzo przodek
o nieokreślonej płci jest spokrewniony dodanej osoby
"""
if inlaw == '':
t_inlaw =""
else:
t_inlaw ="przybrany "
if level == 1:
return t_inlaw + "rodzic"
elif level > 1 and (level - 1) < len(_level_name):
if (level >= 2) & (level <= 4):
# babcia, prababcia, praprababcia
# (albo dziadek, pradziadek, prapradziadek)
tmp = t_inlaw +\
"przodek %s pokolenia" % (_level_name[level - 1])
# TODO: try to recognize a gender...
return tmp
# + self.get_sword_distaff(level, reltocommon, ' ')
else:
return t_inlaw + \
"przodek %s pokolenia" % (_level_name[level - 1])
else:
return t_inlaw +"przodek w %d pokoleniu" % level
def get_single_relationship_string(self, Ga, Gb, gender_a, gender_b,
reltocommon_a, reltocommon_b,
only_birth=True,
in_law_a=False, in_law_b=False):
"""
Provide a string that describes the relationsip between a person, and
another person. E.g. "grandparent" or "child".
"""
if only_birth:
step = ''
else:
step = self.STEP
if in_law_a or in_law_b :
inlaw = self.INLAW
else:
inlaw = ''
# b is the same person as a
if Ga == Gb == 0:
rel_str = 'ta sama osoba'
elif Ga == 0:
# b is son/descendant of a
if gender_b == gen.lib.Person.MALE:
if inlaw and Gb == 1 and not step:
rel_str = "zięć"
else:
rel_str = self.get_son(Gb, inlaw)
elif gender_b == gen.lib.Person.FEMALE:
if inlaw and Gb == 1 and not step:
rel_str = "synowa"
else:
rel_str = self.get_daughter(Gb, inlaw)
else:
rel_str = self.get_child_unknown(Gb, inlaw)
elif Gb == 0:
# b is parent/grand parent of a
if gender_b == gen.lib.Person.MALE:
if inlaw and Gb == 1 and not step:
# TODO: znaleźć odpowiedniki w zależności czy to syn/córka
rel_str = "teść"
else:
rel_str = self.get_father(Ga, reltocommon_a, inlaw)
elif gender_b == gen.lib.Person.FEMALE:
if inlaw and Gb == 1 and not step:
# TODO: znaleźć odpowiedniki w zależności czy to syn/córka
rel_str = "teściowa"
else:
rel_str = self.get_mother(Ga, reltocommon_a, inlaw)
else:
rel_str = self.get_parent_unknown(Ga, inlaw)
elif Ga == Gb == 1:
# rodzeństwo
if gender_b == gen.lib.Person.MALE:
if inlaw and not step:
rel_str = "brat przyrodni"
else:
rel_str = "brat rodzony"
elif gender_b == gen.lib.Person.FEMALE:
if inlaw and not step:
rel_str = "siostra przyrodnia"
else:
rel_str = "siostra rodzony"
else:
rel_str = "brat/siostra"
elif Gb == 1 and Ga > 1:
# Przyjmij, że nie rozróżniamy osób prawnie i nieprawnie przybranych...
if Ga == 2:
# rodzeństwo rodziców
# brat ojca, czyli stryj
if (gender_b == gen.lib.Person.MALE) \
& (reltocommon_a[0] == self.REL_FATHER):
rel_str = "stryj"
# siostra ojca, czyli ciotka ???
elif (gender_b == gen.lib.Person.FEMALE) \
& (reltocommon_a[0] == self.REL_FATHER):
rel_str = "ciotka (tzw. stryjna)"
# brat matki, czyli wuj/wujek
elif (gender_b == gen.lib.Person.MALE) \
& (reltocommon_a[0] == self.REL_MOTHER):
rel_str = "wuj (wujek)"
# siostra matki, czyli ciotka
elif (gender_b == gen.lib.Person.FEMALE) \
& (reltocommon_a[0] == self.REL_MOTHER):
rel_str = "ciotka"
else:
rel_str = "brat lub siostra rodzica"
elif Ga == 3:
# rodzeństwo dziadków rodziców osoby sprawdzanej
# rodzeństwo dziadka po mieczu (ojca ojca)
if (reltocommon_a[0] == self.REL_FATHER) \
& (reltocommon_a[1] == self.REL_FATHER):
if (gender_b == gen.lib.Person.MALE):
rel_str = "dziadek stryjeczny (tzw przestryj, stary stryj)"
elif (gender_b == gen.lib.Person.FEMALE):
rel_str = "babcia stryjeczna"
else:
rel_str = "rodzeństwo przodka w 2 pokoleniu"
# rodzeństwo babki po mieczu (matki ojca)
elif (reltocommon_a[0] == self.REL_FATHER) \
& (reltocommon_a[1] == self.REL_MOTHER):
# TODO: Należy sprawdzić, czy w staropolszczyźnie nie ma
# dokładniejszych określeń dla tego typu relacji
# TODO: EN: Try to check, whether in old polish language
# are more specific word for this kind of relation
if (gender_b == gen.lib.Person.MALE):
rel_str = "dziadek stryjeczny (tzw przestryj, stary stryj)"
elif (gender_b == gen.lib.Person.FEMALE):
rel_str = "babcia stryjeczna"
else:
rel_str = "rodzeństwo przodka w 2 pokoleniu"
# rodzeństwo dziadka po kądzieli (ojca matki)
elif (reltocommon_a[0] == self.REL_MOTHER) \
& (reltocommon_a[1] == self.REL_FATHER):
# TODO: Należy sprawdzić, czy w staropolszczyźnie nie ma
# dokładniejszych określeń dla tego typu relacji
# TODO: EN: Try to check, whether in old polish language
# are more specific word for this kind of relation
if (gender_b == gen.lib.Person.MALE):
rel_str = "dziadek cioteczny (starop. prapociot)"
elif (gender_b == gen.lib.Person.FEMALE):
rel_str = "babcia cioteczna (starop. praciota)"
else:
rel_str = "rodzeństwo przodka w 2 pokoleniu"
# rodzeństwo babki po kądzieli (matki matki)
elif (reltocommon_a[0] == self.REL_MOTHER) \
& (reltocommon_a[1] == self.REL_MOTHER):
# TODO: Należy sprawdzić, czy w staropolszczyźnie nie ma
# dokładniejszych określeń dla tego typu relacji
# TODO: EN: Try to check, whether in old polish language
# are more specific word for this kind of relation
if (gender_b == gen.lib.Person.MALE):
rel_str = "dziadek cioteczny (starop. prapociot)"
elif (gender_b == gen.lib.Person.FEMALE):
rel_str = "babcia cioteczna (starop. praciota)"
else:
rel_str = "rodzeństwo przodka w 2 pokoleniu"
else:
if (gender_b == gen.lib.Person.MALE):
rel_str = "rodzeństwo dziadka"
elif (gender_b == gen.lib.Person.FEMALE):
rel_str = "rodzeństwo babci"
else:
rel_str = "rodzeństwo przodka w 2 pokoleniu"
elif Ga > 3:
# pradziadkowie... (grandparents)
if (gender_b == gen.lib.Person.MALE) \
& (reltocommon_a[0] == self.REL_FATHER):
if Ga >= 0 and Ga < len(_brother_level_of_male):
rel_str = _brother_level_of_male[Ga]
else:
rel_str = "rodzeństwo przodka męskiego %d pokolenia" % Ga
elif (gender_b == gen.lib.Person.FEMALE) \
& (reltocommon_a[0] == self.REL_FATHER):
if Ga >= 0 and Ga < len(_sister_level_of_male):
rel_str = _sister_level_of_male[Ga]
else:
rel_str = "rodzeństwo przodka żeńskiego %d pokolenia" % Ga
elif (gender_b == gen.lib.Person.MALE) \
& (reltocommon_a[0] == self.REL_MOTHER):
if Ga >= 0 and Ga < len(_brother_level_of_female):
rel_str = _brother_level_of_male[Ga]
else:
rel_str = "rodzeństwo przodka męskiego %d pokolenia" % Ga
elif (gender_b == gen.lib.Person.FEMALE) \
& (reltocommon_a[0] == self.REL_MOTHER):
if Ga >= 0 and Ga < len(_sister_level_of_female):
rel_str = _sister_level_of_male[Ga]
else:
rel_str = "rodzeństwo przodka żeńskiego %d pokolenia" % Ga
else:
rel_str = "rodzeństwo przodka %d pokolenia" % Ga
else:
# A program should never goes there, but...
rel_str = "Relacja nie określona"
elif Ga ==1 and Gb > 1:
# syn brata
if (gender_b == gen.lib.Person.MALE) \
& (reltocommon_b[0] == self.REL_FATHER):
if Gb < len(_nephew_level_of_brothers_son):
rel_str = _nephew_level_of_brothers_son[Gb]
else:
rel_str = "męski potomek w %d pokoleniu brata" % Gb
# córka brata
elif (gender_b == gen.lib.Person.FEMALE) \
& (reltocommon_b[0] == self.REL_FATHER):
if Gb < len(_nephew_level_of_brothers_daughter):
rel_str = _nephew_level_of_brothers_daughter[Gb]
else:
rel_str = "żeński potomek w %d pokoleniu brata" % Gb
# syn siostry
if (gender_b == gen.lib.Person.MALE) \
& (reltocommon_b[0] == self.REL_MOTHER):
if Gb < len(_nephew_level_of_sisters_son):
rel_str = _nephew_level_of_sisters_son[Gb]
else:
rel_str = "męski potomek w %d pokoleniu brata" % Gb
# córka siostry
elif (gender_b == gen.lib.Person.FEMALE) \
& (reltocommon_b[0] == self.REL_MOTHER):
if Gb < len(_nephew_level_of_sisters_daughter):
rel_str = _nephew_level_of_sisters_daughter[Gb]
else:
rel_str = "żeński potomek w %d pokoleniu brata" % Gb
# potomek brata
elif (reltocommon_b[0] == self.REL_FATHER):
rel_str = "potomek w %d pokoleniu brata" % Gb
# potomek brata
elif (reltocommon_b[0] == self.REL_MOTHER):
rel_str = "potomek w %d pokoleniu brata" % Gb
else :
rel_str = "potomek w %d pokoleniu rodzeństwa" % Gb
elif Ga > 1 and Gb > 1:
if (gender_b == gen.lib.Person.MALE):
if Ga==2 and Gb==2:
rel_str = "kuzyn"
else:
rel_str = "daleki kuzyn (%d. stopień pokrewieństwa)" % (Ga+Gb)
elif (gender_b == gen.lib.Person.FEMALE):
if Ga==2 and Gb==2:
rel_str = "kuzynka"
else:
rel_str = "daleka kuzynka (%d. stopień pokrewieństwa)" % (Ga+Gb)
else:
if Ga==2 and Gb==2:
rel_str = "kuzyn(ka)"
else:
rel_str = "daleki członek rodziny (%d. stopień pokrewieństwa)" % (Ga+Gb)
else:
# A program should never goes there, but...
rel_str ="nieokreślony stopień pokrewieństwa"
return rel_str
def get_sibling_relationship_string(self, sib_type, gender_a, gender_b,
in_law_a=False, in_law_b=False):
if in_law_a or in_law_b :
inlaw = self.INLAW
else:
inlaw = ''
if sib_type == self.NORM_SIB:
if not inlaw:
if gender_b == gen.lib.Person.MALE:
rel_str = 'brat (rodzony)'
elif gender_b == gen.lib.Person.FEMALE:
rel_str = 'siostra (rodzona)'
else:
rel_str = 'brat lub siostra (rodzeni)'
else:
if gender_b == gen.lib.Person.MALE:
# TODO: znaleźć odpowiednik
rel_str = "brat (pasierb)"
elif gender_b == gen.lib.Person.FEMALE:
# TODO: znaleźć odpowiednik
rel_str = "siostra (pasierbica)"
else:
# TODO: znaleźć odpowiednik
rel_str = "brat lub siostra (pasierb/pasierbica)"
elif sib_type == self.UNKNOWN_SIB:
if not inlaw:
if gender_b == gen.lib.Person.MALE:
rel_str = 'brat'
elif gender_b == gen.lib.Person.FEMALE:
rel_str = 'siostra'
else:
rel_str = 'brat lub siostra'
else:
if gender_b == gen.lib.Person.MALE:
# TODO: znaleźć odpowiednik
rel_str = "brat (brat/szwagier)"
elif gender_b == gen.lib.Person.FEMALE:
# TODO: znaleźć odpowiednik
rel_str = "siostra (bratowa/szwagierka)"
else:
# TODO: znaleźć odpowiednik
rel_str = "brat lub siostra (szwagier/szagierka)"
elif sib_type == self.HALF_SIB_FATHER:
if gender_b == gen.lib.Person.MALE:
rel_str = "brat przyrodni"
elif gender_b == gen.lib.Person.FEMALE:
rel_str = "siostra przyrodnia"
else:
rel_str = "brat/siostra przyrodni"
elif sib_type == self.HALF_SIB_MOTHER:
if gender_b == gen.lib.Person.MALE:
rel_str = "brat przyrodni"
elif gender_b == gen.lib.Person.FEMALE:
rel_str = "siostra przyrodnia"
else:
rel_str = "brat/siostra przyrodni"
elif sib_type == self.STEP_SIB:
if gender_b == gen.lib.Person.MALE:
rel_str = "brat przyrodni"
elif gender_b == gen.lib.Person.FEMALE:
rel_str = "siostra przyrodnia"
else:
rel_str = "brat lub siostra przyrodnia"
else:
rel_str = "nieokreślona relacja rodzeństwa"
return rel_str
#-------------------------------------------------------------------------
#
# Register this class with the Plugins system
#
#-------------------------------------------------------------------------
pmgr = PluginManager.get_instance()
pmgr.register_relcalc(RelationshipCalculator,
["pl", "PL", "pl_PL", "polski", "Polski",
"pl_PL.UTF-8", "pl_PL.UTF8", "pl_PL.utf-8", "pl_PL.utf8",
"pl_PL.iso-8859-2", "pl_PL.iso8859-2",
"pl_PL.cp1250", "pl_PL.cp-1250"] )
if __name__ == "__main__":
# Test function. Call it as follows from the command line (so as to find
# imported modules):
# export PYTHONPATH=/path/to/gramps/src
# python src/plugins/rel_pl.py
"""TRANSLATORS, copy this if statement at the bottom of your
rel_xx.py module, and test your work with:
python src/plugins/rel_xx.py
"""
from Relationship import test
rc = RelationshipCalculator()
test(rc, True)
# Local variables:
# buffer-file-coding-system: utf-8

334
src/plugins/rel/rel_pt.py Normal file
View File

@@ -0,0 +1,334 @@
# -*- coding: utf-8 -*-
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2003-2005 Donald N. Allingham
# Copyright (C) 2008 Brian G. Matherly
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Portuguese version by Duarte Loreto <happyguy_pt@hotmail.com>, 2007.
# Based on the Spanish version by Julio Sanchez <julio.sanchez@gmail.com>
# $Id:rel_pt.py 9912 2008-01-22 09:17:46Z acraphae $
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
import gen.lib
import Relationship
import types
from gettext import gettext as _
from gen.plug import PluginManager
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
_level_name_male = [ "", "primeiro", "segundo", "terceiro", "quarto", "quinto",
"sexto", "sétimo", "oitavo", "nono", "décimo", "décimo-primeiro",
"décimo-segundo", "décimo-terceiro", "décimo-quarto", "décimo-quinto",
"décimo-sexto", "décimo-sétimo", "décimo-oitavo", "décimo-nono",
"vigésimo", ]
# Short forms (in apocope) used before names
_level_name_male_a = [ "", "primeiro", "segundo", "terceiro", "quarto", "quinto",
"sexto", "sétimo", "oitavo", "nono", "décimo", "décimo-primeiro",
"décimo-segundo", "décimo-terceiro", "décimo-quarto", "décimo-quinto",
"décimo-sexto", "décimo-sétimo", "décimo-oitavo", "décimo-nono",
"vigésimo"]
_level_name_female = [ "", "primeira", "segunda", "terceira", "quarta", "quinta",
"sexta", "sétima", "oitava", "nona", "décima", "décima-primeira",
"décima-segunda", "décima-terceira", "décima-quarta", "décima-quinta",
"décima-sexta", "décima-sétima", "décima-oitava", "décima-nona",
"vigésima"]
_level_name_plural = [ "", "primeiros", "segundos", "terceiros", "quartos",
"quintos", "sextos", "sétimos", "oitavos", "nonos",
"décimos", "décimos-primeiros", "décimos-segundos", "décimos-terceiros",
"décimos-quartos", "décimos-quintos", "décimos-sextos",
"décimos-sétimos", "décimos-oitavos", "décimos-nonos",
"vigésimos", ]
# This plugin tries to be flexible and expect little from the following
# tables. Ancestors are named from the list for the first generations.
# When this list is not enough, ordinals are used based on the same idea,
# i.e. bisavô is 'segundo avô' and so on, that has been the
# traditional way in Portuguese. When we run out of ordinals we resort to
# Nº notation, that is sort of understandable if in context.
# There is a specificity for pt_BR where they can use "tataravô" instead
# of "tetravô", being both forms correct for pt_BR but just "tetravô"
# correct for pt. Translation keeps "tetravô".
_parents_level = [ "", "pais", "avós", "bisavós", "trisavós",
"tetravós"]
_father_level = [ "", "pai", "avô", "bisavô", "trisavô",
"tetravô"]
_mother_level = [ "", "mãe", "avó", "bisavó", "trisavó",
"tetravó"]
# Higher-order terms (after "tetravô") are not standard in Portuguese.
# Check http://www.geneall.net/P/forum_msg.php?id=136774 that states
# that although some people may use other greek-prefixed forms for
# higher levels, both pt and pt_BR correct form is to use, after
# "tetravô", the "quinto avô", "sexto avô", etc.
_son_level = [ "", "filho", "neto", "bisneto",
"trisneto", ]
_daughter_level = [ "", "filha", "neta", "bisneta",
"trisneta", ]
_sister_level = [ "", "irmã", "tia", "tia avó", ]
_brother_level = [ "", "irmão", "tio", "tio avô", ]
_nephew_level = [ "", "sobrinho", "sobrinho neto", "sobrinho bisneto", ]
_niece_level = [ "", "sobrinha", "sobrinha neta", "sobrinha bisneta", ]
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
class RelationshipCalculator(Relationship.RelationshipCalculator):
def __init__(self):
Relationship.RelationshipCalculator.__init__(self)
def get_male_cousin(self,level):
if level<len(_level_name_male):
return "%s primo" % (_level_name_male[level])
else:
return "%dº primo" % level
def get_female_cousin(self,level):
if level<len(_level_name_female):
return "%s prima" % (_level_name_female[level])
else:
return "%dª prima" % level
def get_distant_uncle(self,level):
if level<len(_level_name_male):
return "%s tio" % (_level_name_male[level])
else:
return "%dº tio" % level
def get_distant_aunt(self,level):
if level<len(_level_name_female):
return "%s tia" % (_level_name_female[level])
else:
return "%dª tia" % level
def get_distant_nephew(self,level):
if level<len(_level_name_male):
return "%s sobrinho" % (_level_name_male[level])
else:
return "%dº sobrinho" % level
def get_distant_nieve(self,level):
if level<len(_level_name_female):
return "%s sobrinha" % (_level_name_female[level])
else:
return "%dª sobrinha" % level
def get_male_relative(self,level1,level2):
if level1<len(_level_name_male_a):
level1_str = _level_name_male_a[level1]
else:
level1_str = "%dº" % level1
if level2<len(_level_name_male_a):
level2_str = _level_name_male_a[level2]
else:
level2_str = "%dº" % level2
level = level1 + level2
if level<len(_level_name_male_a):
level_str = _level_name_male_a[level]
else:
level_str = "%dº" % level
return "parente em %s grau (%s com %s)" % (level_str,level1_str,level2_str)
def get_female_relative(self,level1,level2):
return self.get_male_relative(level1,level2)
def get_parents(self,level):
if level<len(_parents_level):
return _parents_level[level]
elif (level-1)<len(_level_name_plural):
return "%s avós" % (_level_name_plural[level-1])
else:
return "%dº avós" % (level-1)
def get_father(self,level):
if level<len(_father_level):
return _father_level[level]
elif (level-1)<len(_level_name_male_a):
return "%s avô" % (_level_name_male_a[level-1])
else:
return "%dº avô" % (level-1)
def get_son(self,level):
if level<len(_son_level):
return _son_level[level]
elif (level-1)<len(_level_name_male_a):
return "%s neto" % (_level_name_male_a[level-1])
else:
return "%dº neto" % (level-1)
def get_mother(self,level):
if level<len(_mother_level):
return _mother_level[level]
elif (level-1)<len(_level_name_female):
return "%s avó" % (_level_name_female[level-1])
else:
return "%dª avó" % (level-1)
def get_daughter(self,level):
if level<len(_daughter_level):
return _daughter_level[level]
elif (level-1)<len(_level_name_female):
return "%s neta" % (_level_name_female[level-1])
else:
return "%dª neta" % (level-1)
def get_aunt(self,level):
if level<len(_sister_level):
return _sister_level[level]
elif (level-2)<len(_level_name_female):
return "%s tia avó" % (_level_name_female[level-2])
else:
return "%dª tia avó" % (level-2)
def get_uncle(self,level):
if level<len(_brother_level):
return _brother_level[level]
elif (level-2)<len(_level_name_male_a):
return "%s tio avô" % (_level_name_male_a[level-2])
else:
return "%dº tio avô" % (level-2)
def get_nephew(self,level):
if level<len(_nephew_level):
return _nephew_level[level]
elif (level-1)<len(_level_name_male_a):
return "%s sobrinho neto" % (_level_name_male_a[level-1])
else:
return "%dº sobrinho neto" % (level-1)
def get_niece(self,level):
if level<len(_niece_level):
return _niece_level[level]
elif (level-1)<len(_level_name_female):
return "%s sobrinha neta" % (_level_name_female[level-1])
else:
return "%dª sobrinha neta" % (level-1)
def get_relationship(self, orig_person, other_person):
"""
returns a string representing the relationshp between the two people,
along with a list of common ancestors (typically father,mother)
"""
if orig_person is None:
return ("indefinido",[])
if orig_person.get_handle() == other_person.get_handle():
return ('', [])
is_spouse = self.is_spouse(orig_person, other_person)
if is_spouse:
return (is_spouse,[])
#get_relationship_distance changed, first data is relation to
#orig person, apperently secondRel in this function
(secondRel,firstRel,common) = self.get_relationship_distance(orig_person, other_person)
if isinstance(common, basestring):
return (common,[])
elif common:
person_handle = common[0]
else:
return ("",[])
firstRel = len(firstRel)
secondRel = len(secondRel)
if firstRel == 0:
if secondRel == 0:
return ('',common)
elif other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_father(secondRel),common)
else:
return (self.get_mother(secondRel),common)
elif secondRel == 0:
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_son(firstRel),common)
else:
return (self.get_daughter(firstRel),common)
elif firstRel == 1:
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_uncle(secondRel),common)
else:
return (self.get_aunt(secondRel),common)
elif secondRel == 1:
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_nephew(firstRel-1),common)
else:
return (self.get_niece(firstRel-1),common)
elif firstRel == secondRel == 2:
if other_person.get_gender() == gen.lib.Person.MALE:
return ('primo irmão',common)
else:
return ('prima irmã',common)
elif firstRel == secondRel:
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_male_cousin(firstRel-1),common)
else:
return (self.get_female_cousin(firstRel-1),common)
elif firstRel == secondRel+1:
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_distant_nephew(secondRel),common)
else:
return (self.get_distant_niece(secondRel),common)
elif firstRel+1 == secondRel:
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_distant_uncle(firstRel),common)
else:
return (self.get_distant_aunt(firstRel),common)
else:
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_male_relative(firstRel,secondRel),common)
else:
return (self.get_female_relative(firstRel,secondRel),common)
#-------------------------------------------------------------------------
#
# Register this function with the Plugins system
#
#-------------------------------------------------------------------------
pmgr = PluginManager.get_instance()
pmgr.register_relcalc(RelationshipCalculator,
["pt","PT","pt_PT","pt_BR","portugues","Portugues","pt_PT.UTF8","pt_BR.UTF8",
"pt_PT@euro","pt_PT.UTF8@euro","pt_PT.UTF-8","pt_BR.UTF-8",
"pt_PT.utf-8","pt_BR.utf-8","pt_PT.utf8","pt_BR.utf8"])

270
src/plugins/rel/rel_ru.py Normal file
View File

@@ -0,0 +1,270 @@
# -*- coding: utf-8 -*-
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2003-2005 Donald N. Allingham
# Copyright (C) 2008 Brian G. Matherly
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id:rel_ru.py 9912 2008-01-22 09:17:46Z acraphae $
# Written by Alex Roitman, largely based on Relationship.py by Don Allingham.
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
import gen.lib
import Relationship
import types
from gen.plug import PluginManager
#-------------------------------------------------------------------------
#
# Russian-specific definitions of relationships
#
#-------------------------------------------------------------------------
_parents_level = [ "", "родители",
"дедушки/бабушки", "прадедушки/прабабушки", "прапрадедушки/прапрабабушки",
]
_male_cousin_level = [
"", "двоюродный", "троюродный", "четвероюродный",
"пятиюродный", "шестиюродный", "семиюродный", "восьмиюродный",
"девятиюродный", "десятиюродный", "одиннацатиюродный", "двенадцатиюродный",
"тринадцатиюродный", "четырнадцатиюродный", "пятнадцатиюродный", "шестнадцатиюродный",
"семнадцатиюродный", "восемнадцатиюродный", "девятнадцатиюродный","двадцатиюродный" ]
_female_cousin_level = [
"", "двоюродная", "троюродная", "четвероюродная",
"пятиюродная", "шестиюродная", "семиюродная", "восьмиюродная",
"девятиюродная", "десятиюродная", "одиннацатиюродная", "двенадцатиюродная",
"тринадцатиюродная", "четырнадцатиюродная", "пятнадцатиюродная", "шестнадцатиюродная",
"семнадцатиюродная", "восемнадцатиюродная", "девятнадцатиюродная","двадцатиюродная" ]
_junior_male_removed_level = [
"брат", "племянник", "внучатый племянник", "правнучатый племянник",
"праправнучатый племянник", "прапраправнучатый племянник",
"прапрапраправнучатый племянник" ]
_junior_female_removed_level = [
"сестра", "племянница", "внучатая племянница", "правнучатая племянница",
"праправнучатая племянница", "прапраправнучатая племянница",
"прапрапраправнучатая племянница" ]
_senior_male_removed_level = [
"", "дядя", "дед", "прадед", "прапрадед", "прапрапрадед","прапрапрапрадед" ]
_senior_female_removed_level = [
"", "тетка", "бабка", "прабабка", "прапрабабка", "прапрапрабабка","прапрапрапрабабка" ]
_father_level = [
"", "отец", "дед", "прадед", "прапрадед", "прапрапрадед", "прапрапрапрадед" ]
_mother_level = [
"", "мать", "бабка", "прабабка", "прапрабабка", "прапрапрабабка", "прапрапрапрабабка" ]
_son_level = [
"", "сын", "внук", "правнук", "праправнук", "прапраправнук", "прапрапраправнук" ]
_daughter_level = [
"", "дочь", "внучка", "правнучка", "праправнучка", "прапраправнучка",
"прапрапраправнучка" ]
_sister_level = [
"", "сестра", "тетка", "двоюродная бабка", "двоюродная прабабка",
"двоюродная прапрабабка", "двоюродная прапрапрабабка", "двоюродная прапрапрапрабабка" ]
_brother_level = [
"", "брат", "дядя", "двоюродный дед", "двоюродный прадед",
"двоюродный прапрадед", "двоюродный прапрапрадед", "двоюродный прапрапрапрадед" ]
_nephew_level = [
"", "племянник", "внучатый племянник", "правнучатый племянник",
"праправнучатый племянник", "прапраправнучатый племянник",
"прапрапраправнучатый племянник" ]
_niece_level = [
"", "племянница", "внучатая племянница", "правнучатая племянница",
"праправнучатая племянница", "прапраправнучатая племянница",
"прапрапраправнучатая племянница" ]
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
class RelationshipCalculator(Relationship.RelationshipCalculator):
def __init__(self):
Relationship.RelationshipCalculator.__init__(self)
def get_parents(self,level):
if level>len(_parents_level)-1:
return "дальние родственники"
else:
return _parents_level[level]
def get_junior_male_cousin(self,level,removed):
if removed > len(_junior_male_removed_level)-1 or level>len(_male_cousin_level)-1:
return "дальний родственник"
else:
return "%s %s" % (_male_cousin_level[level],_junior_male_removed_level[removed])
def get_senior_male_cousin(self,level,removed):
if removed > len(_senior_male_removed_level)-1 or level>len(_male_cousin_level)-1:
return "дальний родственник"
else:
return "%s %s" % (_male_cousin_level[level],_senior_male_removed_level[removed])
def get_junior_female_cousin(self,level,removed):
if removed > len(_junior_female_removed_level)-1 or level>len(_male_cousin_level)-1:
return "дальняя родственница"
else:
return "%s %s" % (_female_cousin_level[level],_junior_female_removed_level[removed])
def get_senior_female_cousin(self,level,removed):
if removed > len(_senior_female_removed_level)-1 or level>len(_male_cousin_level)-1:
return "дальняя родственница"
else:
return "%s %s" % (_female_cousin_level[level],_senior_female_removed_level[removed])
def get_father(self,level):
if level>len(_father_level)-1:
return "дальний предок"
else:
return _father_level[level]
def get_son(self,level):
if level>len(_son_level)-1:
return "дальний потомок"
else:
return _son_level[level]
def get_mother(self,level):
if level>len(_mother_level)-1:
return "дальний предок"
else:
return _mother_level[level]
def get_daughter(self,level):
if level>len(_daughter_level)-1:
return "дальний потомок"
else:
return _daughter_level[level]
def get_aunt(self,level):
if level>len(_sister_level)-1:
return "дальний предок"
else:
return _sister_level[level]
def get_uncle(self,level):
if level>len(_brother_level)-1:
return "дальний предок"
else:
return _brother_level[level]
def get_nephew(self,level):
if level>len(_nephew_level)-1:
return "дальний потомок"
else:
return _nephew_level[level]
def get_niece(self,level):
if level>len(_niece_level)-1:
return "дальний потомок"
else:
return _niece_level[level]
def get_relationship(self,db, orig_person, other_person):
"""
Return a string representing the relationshp between the two people,
along with a list of common ancestors (typically father,mother)
Special cases: relation strings "", "undefined" and "spouse".
"""
if orig_person is None:
return ("undefined",[])
if orig_person.get_handle() == other_person.get_handle():
return ('', [])
is_spouse = self.is_spouse(db, orig_person, other_person)
if is_spouse:
return (is_spouse,[])
#get_relationship_distance changed, first data is relation to
#orig person, apperently secondRel in this function
(secondRel,firstRel,common) = \
self.get_relationship_distance(db, orig_person, other_person)
if isinstance(common, basestring):
return (common,[])
elif common:
person_handle = common[0]
else:
return ("",[])
firstRel = len(firstRel)
secondRel = len(secondRel)
if firstRel == 0:
if secondRel == 0:
return ('',common)
elif other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_father(secondRel),common)
else:
return (self.get_mother(secondRel),common)
elif secondRel == 0:
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_son(firstRel),common)
else:
return (self.get_daughter(firstRel),common)
elif firstRel == 1:
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_uncle(secondRel),common)
else:
return (self.get_aunt(secondRel),common)
elif secondRel == 1:
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_nephew(firstRel-1),common)
else:
return (self.get_niece(firstRel-1),common)
elif secondRel > firstRel:
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_senior_male_cousin(firstRel-1,secondRel-firstRel),common)
else:
return (self.get_senior_female_cousin(firstRel-1,secondRel-firstRel),common)
else:
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_junior_male_cousin(secondRel-1,firstRel-secondRel),common)
else:
return (self.get_junior_female_cousin(secondRel-1,firstRel-secondRel),common)
#-------------------------------------------------------------------------
#
# Register this class with the Plugins system
#
#-------------------------------------------------------------------------
pmgr = PluginManager.get_instance()
pmgr.register_relcalc(RelationshipCalculator,
["ru","RU","ru_RU","koi8r","ru_koi8r","russian","Russian","ru_RU.koi8r","ru_RU.KOI8-R","ru_RU.utf8","ru_RU.UTF8", "ru_RU.utf-8","ru_RU.UTF-8","ru_RU.iso88595","ru_RU.iso8859-5","ru_RU.iso-8859-5"])

234
src/plugins/rel/rel_sk.py Normal file
View File

@@ -0,0 +1,234 @@
# -*- coding: utf-8 -*-
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2003-2005 Donald N. Allingham
# Copyright (C) 2008 Brian G. Matherly
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id:rel_sk.py 9912 2008-01-22 09:17:46Z acraphae $
# Slovak terms added by Lubo Vasko
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
import gen.lib
import Relationship
import types
from gen.plug import PluginManager
#-------------------------------------------------------------------------
#
#Slovak-specific definitions of relationships
#
#-------------------------------------------------------------------------
_level_name = [ "", "prvého", "druhého", "tretieho", "štvrtého", "piateho", "šiesteho",
"siedmeho", "ôsmeho", "deviateho", "desiateho", "jedenásteho", "dvanásteho",
"trinásteho", "štrnásteho", "pätnásteho", "šestnásteho",
"sedemnásteho", "osemnásteho", "devätnásteho", "dvadsiateho", "dvadsiatehoprvého", "dvadsiatehodruhého",
"dvadsiatehotretieho", "dvadsiatehoštvrtého","dvadsiatehopiateho","dvadsiatehošiesteho","dvadsiatehosiedmeho",
"dvadsiatehoôsmeho","dvadsiatehodeviateho","tridsiateho" ]
_parents_level = [ "", "rodičia", "starí rodičia", "prarodičia",
"vzdialení príbuzní", ]
_father_level = [ "", "otec", "starý otec", "prastarý otec", "prapredok", ]
_mother_level = [ "", "matka", "stará matka", "prastará matka", "prapredok", ]
_son_level = [ "", "syn", "vnuk", "pravnuk", ]
_daughter_level = [ "", "dcéra", "vnučka", "pravnučka", ]
_sister_level = [ "", "sestra", "teta", "prateta", "praprateta", ]
_brother_level = [ "", "brat", "strýko", "prastrýko", "praprastrýko", ]
_nephew_level = [ "", "synovec", "prasynovec", "praprasynovec", ]
_niece_level = [ "", "neter", "praneter", "prapraneter", ]
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
class RelationshipCalculator(Relationship.RelationshipCalculator):
def __init__(self):
Relationship.RelationshipCalculator.__init__(self)
def get_male_cousin(self,level):
if level>len(_level_name)-1:
return "vzdialený príbuzný"
else:
return "bratranec %s stupňa" % (_level_name[level])
def get_female_cousin(self,level):
if level>len(_level_name)-1:
return "vzdialená príbuzná"
else:
return "sesternica %s stupňa" % (_level_name[level])
def get_parents(self,level):
if level>len(_parents_level)-1:
return "vzdialení príbuzní"
else:
return _parents_level[level]
def get_father(self,level):
if level>len(_father_level)-1:
return "vzdialený príbuzný"
else:
return _father_level[level]
def get_son(self,level):
if level>len(_son_level)-1:
return "vzdialený potomok"
else:
return _son_level[level]
def get_mother(self,level):
if level>len(_mother_level)-1:
return "vzdialený predok"
else:
return _mother_level[level]
def get_daughter(self,level):
if level>len(_daughter_level)-1:
return "vzdialený potomok"
else:
return _daughter_level[level]
def get_aunt(self,level):
if level>len(_sister_level)-1:
return "vzdialený predok"
else:
return _sister_level[level]
def get_uncle(self,level):
if level>len(_brother_level)-1:
return "vzdialený predok"
else:
return _brother_level[level]
def get_nephew(self,level):
if level>len(_nephew_level)-1:
return "vzdialený potomok"
else:
return _nephew_level[level]
def get_niece(self,level):
if level>len(_niece_level)-1:
return "vzdialený potomok"
else:
return _niece_level[level]
def get_relationship(self,db, orig_person, other_person):
"""
Return a string representing the relationshp between the two people,
along with a list of common ancestors (typically father,mother)
Special cases: relation strings "", "undefined" and "spouse".
"""
if orig_person is None:
return ("undefined",[])
if orig_person.get_handle() == other_person.get_handle():
return ('', [])
is_spouse = self.is_spouse(db, orig_person, other_person)
if is_spouse:
return (is_spouse,[])
#get_relationship_distance changed, first data is relation to
#orig person, apperently secondRel in this function
(secondRel,firstRel,common) = \
self.get_relationship_distance(db, orig_person, other_person)
if isinstance(common, basestring):
return (common,[])
elif common:
person_handle = common[0]
else:
return ("",[])
firstRel = len(firstRel)
secondRel = len(secondRel)
if firstRel == 0:
if secondRel == 0:
return ('',common)
elif other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_father(secondRel),common)
else:
return (self.get_mother(secondRel),common)
elif secondRel == 0:
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_son(firstRel),common)
else:
return (self.get_daughter(firstRel),common)
elif firstRel == 1:
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_uncle(secondRel),common)
else:
return (self.get_aunt(secondRel),common)
elif secondRel == 1:
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_nephew(firstRel-1),common)
else:
return (self.get_niece(firstRel-1),common)
elif firstRel == secondRel == 2:
if other_person.get_gender() == gen.lib.Person.MALE:
return ('vlastný bratranec',common)
else:
return ('vlastná sesternica',common)
elif firstRel == 3 and secondRel == 2:
if other_person.get_gender() == gen.lib.Person.MALE:
return ('bratranec druhého stupňa',common)
else:
return ('sesternica druhého stupňa',common)
elif firstRel == 2 and secondRel == 3:
if other_person.get_gender() == gen.lib.Person.MALE:
return ('bratranec druhého stupňa',common)
else:
return ('sesternica druhého stupňa',common)
else:
if other_person.get_gender() == gen.lib.Person.MALE:
if firstRel+secondRel>len(_level_name)-1:
return (self.get_male_cousin(firstRel+secondRel),common)
else:
return ('vzdialený bratranec',common)
else:
if firstRel+secondRel>len(_level_name)-1:
return (self.get_female_cousin(firstRel+secondRel),common)
else:
return ('vzdialená sesternica',common)
#-------------------------------------------------------------------------
#
# Register this class with the Plugins system
#
#-------------------------------------------------------------------------
pmgr = PluginManager.get_instance()
pmgr.register_relcalc(RelationshipCalculator,
["sk", "SK", "sk_SK", "slovensky", "slovak", "Slovak", "sk_SK.UTF8", "sk_SK.UTF-8", "sk_SK.utf-8", "sk_SK.utf8"])

546
src/plugins/rel/rel_sv.py Normal file
View File

@@ -0,0 +1,546 @@
# -*- coding: utf-8 -*-
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2003-2006 Donald N. Allingham
# Copyright (C) 2008 Brian G. Matherly
# Copyright (C) 2008 Peter G. LAndgren
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id$
# Written by Alex Roitman, largely based on Relationship.py by Don Allingham
# and on valuable input from Jens Arvidsson
# Updated to 3.0 by Peter Landgren 2007-12-30.
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
import gen.lib
import Relationship
from gen.plug import PluginManager
#-------------------------------------------------------------------------
#
# Swedish-specific definitions of relationships
#
#-------------------------------------------------------------------------
_cousin_level = [ "", "kusin",
u"tremänning", u"fyrmänning", u"femmänning",
u"sexmänning", u"sjumänning", u"åttamänning",
u"niomänning", u"tiomänning", u"elvammänning",
u"tolvmänning", u"trettonmänning", u"fjortonmänning",
u"femtonmänning", u"sextonmänning", u"sjuttonmänning",
u"artonmänning", u"nittonmänning", u"tjugomänning",
u"tjugoettmänning", u"tjugotvåmänning", u"tjugotremänning",
u"tjugofyramänning",u"tjugofemmänning",u"tjugoexmänning",
u"tjugosjumänning",u"tjugoåttamänning",u"tjugoniomänning",
u"trettiomänning" ]
_children_level = 20
_level_name = [ "", u"första",
u"andra", u"tredje", u"fjärde", u"femte",
u"sjätte", u"sjunde", u"åttonde", u"nionde",
u"tionde", u"elfte", u"tolfte", u"trettonde",
u"fjortonde", u"femtonde", u"sextonde", u"sjuttonde",
u"artonde", u"nittonde", u"tjugonde" ]
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
class RelationshipCalculator(Relationship.RelationshipCalculator):
#sibling strings
STEP = 'styv'
HALF = 'halv'
#in-law string
INLAW = 'ingift '
def __init__(self):
Relationship.RelationshipCalculator.__init__(self)
def _get_cousin(self, level, step, inlaw):
if level > len(_cousin_level)-1:
return u"avlägset släkt"
else:
result = inlaw + _cousin_level[level]
# Indicate step relations) by adding ' [styv]'
if step:
result = result + ' [styv]'
return result
def pair_up(self, rel_list, step):
result = []
item = ""
for word in rel_list[:]:
if not word:
continue
if word.replace(' [styv]', '') in _cousin_level:
if item:
result.append(item)
item = ""
result.append(word)
continue
if item:
if word == 'syster':
item = item[0:-1]
word = 'ster'
elif word == 'dotter' and item == 'bror':
item = 'brors'
result.append(item + word)
item = ""
else:
item = word
if item:
result.append(item)
gen_result = [ item + 's' for item in result[0:-1] ]
gen_result = ' '.join(gen_result+result[-1:])
# Indicate step relations) by adding ' [styv]' if not already added.
if len(rel_list)>1 and step != '' and not gen_result.rfind(' [styv]'):
gen_result = gen_result + ' [styv]'
return gen_result
def _get_direct_ancestor(self, person_gender, rel_string, step, inlaw):
result = []
for ix in range(len(rel_string)):
if rel_string[ix] == 'f':
result.append('far')
else:
result.append('mor')
if person_gender == gen.lib.Person.MALE:
result[-1] = 'far'
if person_gender == gen.lib.Person.FEMALE:
result[-1] = 'mor'
if person_gender == gen.lib.Person.UNKNOWN:
result[-1] = u'förälder'
if step != '' and len(result)==1:
#Preceed with step prefix of father/mother
result[0] = self.STEP + result[0]
if inlaw != '':
#Preceed with inlaw prefix
result[-1] = u'svär' + result[-1]
if len(result)>1 and len(result) % 2 == 0 and \
(person_gender == gen.lib.Person.UNKNOWN or inlaw != ''):
# Correct string "-2" with genitive s and add a space to get
# correct Swedish, if even number in result
result[-2] = result[-2] + 's '
return self.pair_up(result, step)
def _get_direct_descendant(self, person_gender, rel_string, step, inlaw):
result = []
for ix in range(len(rel_string)-2, -1, -1):
if rel_string[ix] == 'f':
result.append('son')
else:
result.append('dotter')
if person_gender == gen.lib.Person.MALE:
result.append('son')
elif person_gender == gen.lib.Person.FEMALE:
result.append('dotter')
else:
if person_gender == gen.lib.Person.UNKNOWN and inlaw == '':
result.append('barn')
if person_gender == gen.lib.Person.UNKNOWN and inlaw != '':
result.append('-son/dotter')
if step != '' and len(result)==1:
result[0] = self.STEP + result[0]
if inlaw != '':
#Preceed with inlaw prefix
result[-1] = u'svär' + result[-1]
if len(result)>1 and len(result) % 2 == 0 and \
(person_gender == gen.lib.Person.UNKNOWN or inlaw != ''):
# Correct string "-2" with genitive s and add a space to get
# correct Swedish, if even number in result
result[-2] = result[-2] + 's '
return self.pair_up(result, step)
def _get_ancestors_cousin(self, rel_string_long, rel_string_short, step, inlaw):
result = []
removed = len(rel_string_long)-len(rel_string_short)
level = len(rel_string_short)-1
for ix in range(removed):
if rel_string_long[ix] == 'f':
result.append('far')
else:
result.append('mor')
if inlaw != '' :
inlaw = 'ingifta '
result.append(self._get_cousin(level, step, inlaw))
if step != '' and len(result)==1:
result[0] = self.STEP + result[0]
return self.pair_up(result, step)
def _get_cousins_descendant(self, person_gender, rel_string_long, rel_string_short, step, inlaw):
result = []
removed = len(rel_string_long)-len(rel_string_short)-1
level = len(rel_string_short)-1
if level:
result.append(self._get_cousin(level, step, inlaw))
elif rel_string_long[removed] == 'f':
result.append('bror')
else:
result.append('syster')
for ix in range(removed-1, -1, -1):
if rel_string_long[ix] == 'f':
result.append('son')
else:
result.append('dotter')
if person_gender == gen.lib.Person.MALE:
result.append('son')
elif person_gender == gen.lib.Person.FEMALE:
result.append('dotter')
else:
if person_gender == gen.lib.Person.UNKNOWN and inlaw == '':
result.append('barn')
if person_gender == gen.lib.Person.UNKNOWN and inlaw != '':
result.append('-son/dotter')
if step != '' and len(result) == 1:
result[0] = self.STEP + result[0]
if inlaw != '':
#Preceed with inlaw prefix
result[-1] = u'svär' + result[-1]
if len(result)>1 and len(result) % 2 == 0 and \
(person_gender == gen.lib.Person.UNKNOWN or inlaw != ''):
# Correct string "-2" with genitive s and add a space to get
# correct Swedish, if even number in result
result[-2] = result[-2] + 's '
return self.pair_up(result, step)
def _get_ancestors_brother(self, rel_string, person_gender, step, inlaw):
result = []
for ix in range(len(rel_string)-1):
if rel_string[ix] == 'f':
result.append('far')
else:
result.append('mor')
result.append('bror')
if person_gender == gen.lib.Person.UNKNOWN: result[-1] = 'syskon'
if step != '' and len(result)==1:
result[0] = self.STEP + result[0]
if inlaw != '':
#Preceed with inlaw prefix
result[-1] = u'svåger'
if inlaw != '' and person_gender == gen.lib.Person.UNKNOWN:
#Preceed with inlaw prefix
result[-1] = u'svåger/svägerska'
if len(result)>1 and len(result) % 2 == 0 and \
(person_gender == gen.lib.Person.UNKNOWN or inlaw != ''):
# Correct string "-2" with genitive s and add a space to get
# correct Swedish, if even number in result
result[-2] = result[-2] + 's '
return self.pair_up(result, step)
def _get_ancestors_sister(self, rel_string, step, inlaw):
result = []
for ix in range(len(rel_string)-1):
if rel_string[ix] == 'f':
result.append('far')
else:
result.append('mor')
result.append('syster')
if step != '' and len(result)==1:
result[0] = self.STEP + result[0]
if inlaw != '' :
#Preceed with inlaw prefix
result[-1] = u'svägerska'
if len(result)>1 and len(result) % 2 == 0 and inlaw != '':
# Correct string "-2" with genitive s and add a space to get
# correct Swedish, if even number in result
result[-2] = result[-2] + 's '
return self.pair_up(result, step)
def get_sibling_relationship_string(self, sib_type, gender_a, gender_b,
in_law_a=False, in_law_b=False):
""" Determine the string giving the relation between two siblings of
type sib_type.
Eg: b is the brother of a
Here 'brother' is the string we need to determine
This method gives more details about siblings than
get_single_relationship_string can do.
DON'T TRANSLATE THIS PROCEDURE IF LOGIC IS EQUAL IN YOUR LANGUAGE,sib_type
AND SAME METHODS EXIST (get_uncle, get_aunt, get_sibling)
"""
if sib_type == self.NORM_SIB or sib_type == self.UNKNOWN_SIB:
typestr = ''
elif sib_type == self.HALF_SIB_MOTHER \
or sib_type == self.HALF_SIB_FATHER:
typestr = self.HALF
elif sib_type == self.STEP_SIB:
typestr = self.STEP
if gender_b == gen.lib.Person.MALE:
rel_str = "bror"
elif gender_b == gen.lib.Person.FEMALE:
rel_str = "syster"
else:
rel_str = "syskon"
return typestr + rel_str
# kinship report
def _get_cousin_kinship(self, Ga):
rel_str = self._get_cousin(Ga-1, False, '')
if Ga == 2 :
rel_str = rel_str + "er"
else:
rel_str = rel_str + "ar"
return rel_str
def get_plural_relationship_string(self, Ga, Gb):
"""
Provide a string that describes the relationsip between a person, and
a group of people with the same relationship. E.g. "grandparents" or
"children".
Ga and Gb can be used to mathematically calculate the relationship.
See the Wikipedia entry for more information:
http://en.wikipedia.org/wiki/Cousin#Mathematical_definitions
@param Ga: The number of generations between the main person and the
common ancestor.
@type Ga: int
@param Gb: The number of generations between the group of people and the
common ancestor
@type Gb: int
@returns: A string describing the relationship between the person and
the group.
@rtype: str
"""
rel_str = u"avlägsna släktingar"
if Ga == 0:
result = []
# These are descendants
if Gb < _children_level:
for AntBarn in range(Gb):
result.append("barn")
rel_str = self.pair_up(result,'')
else:
rel_str = u"avlägsna ättlingar"
elif Gb == 0:
# These are parents/grand parents
if Ga < len(_level_name):
if Ga == 1:
rel_str = u"föräldrar"
else:
rel_str = u"far- och morföräldrar i %s generationen" % _level_name[Ga]
else:
rel_str = u"avlägsna förfäder"
elif Gb == 1:
# These are siblings/aunts/uncles
if Ga < len(_level_name):
if Ga == 1:
rel_str = "syskon"
else:
rel_str = u"förfäders syskon i %s generationen" % _level_name[Ga-1]
else:
rel_str = u"avlägsna farbröder/morbröder/fastrar/mostrar"
elif Ga == 1:
# These are nieces/nephews
if Gb < len(_level_name):
result = []
result.append("syskonbarn")
for AntBarn in range(Gb-2):
result.append("barn")
rel_str = self.pair_up(result,'')
else:
rel_str = u"avlägsna brorsöner/systersöner/brorsdöttrar/systerdöttrar"
elif Ga > 1 and Ga == Gb:
# These are cousins in the same generation
rel_str = self._get_cousin_kinship(Ga)
elif Ga > 1 and Ga > Gb:
# These are cousins in different generations with the second person
# being in a higher generation from the common ancestor than the
# first person.
if Gb <= len(_level_name):
rel_str = u"förfäders " + self._get_cousin_kinship(Ga) + \
" i "+ _level_name[Gb] + " generationen"
else:
rel_str = u"avlägsna kusiner"
elif Gb > 1 and Gb > Ga:
# These are cousins in different generations with the second person
# being in a lower generation from the common ancestor than the
# first person.
if Ga <= len(_level_name):
result = []
result.append(self._get_cousin(Ga-1, False, ''))
for AntBarn in range(Gb-Ga):
result.append("barn")
rel_str = self.pair_up(result,'')
else:
rel_str = u"avlägsna kusiner"
return rel_str
def get_single_relationship_string(self, Ga, Gb, gender_a, gender_b,
reltocommon_a, reltocommon_b,
only_birth=True,
in_law_a=False, in_law_b=False):
"""
Provide a string that describes the relationsip between a person, and
another person. E.g. "grandparent" or "child".
To be used as: 'person b is the grandparent of a', this will
be in translation string :
'person b is the %(relation)s of a'
Note that languages with gender should add 'the' inside the
translation, so eg in french:
'person b est %(relation)s de a'
where relation will be here: le grandparent
Ga and Gb can be used to mathematically calculate the relationship.
See the Wikipedia entry for more information:
http://en.wikipedia.org/wiki/Cousin#Mathematical_definitions
Some languages need to know the specific path to the common ancestor.
Those languages should use reltocommon_a and reltocommon_b which is
a string like 'mfmf'. The possible string codes are:
REL_MOTHER # going up to mother
REL_FATHER # going up to father
REL_MOTHER_NOTBIRTH # going up to mother, not birth relation
REL_FATHER_NOTBIRTH # going up to father, not birth relation
REL_FAM_BIRTH # going up to family (mother and father)
REL_FAM_NONBIRTH # going up to family, not birth relation
REL_FAM_BIRTH_MOTH_ONLY # going up to fam, only birth rel to mother
REL_FAM_BIRTH_FATH_ONLY # going up to fam, only birth rel to father
Prefix codes are stripped, so REL_FAM_INLAW_PREFIX is not present.
If the relation starts with the inlaw of the person a, then 'in_law_a'
is True, if it starts with the inlaw of person b, then 'in_law_b' is
True.
Also REL_SIBLING (# going sideways to sibling (no parents)) is not
passed to this routine. The collapse_relations changes this to a
family relation.
Hence, calling routines should always strip REL_SIBLING and
REL_FAM_INLAW_PREFIX before calling get_single_relationship_string()
Note that only_birth=False, means that in the reltocommon one of the
NOTBIRTH specifiers is present.
The REL_FAM identifiers mean that the relation is not via a common
ancestor, but via a common family (note that that is not possible for
direct descendants or direct ancestors!). If the relation to one of the
parents in that common family is by birth, then 'only_birth' is not
set to False. The only_birth() method is normally used for this.
@param Ga: The number of generations between the main person and the
common ancestor.
@type Ga: int
@param Gb: The number of generations between the other person and the
common ancestor
@type Gb: int
@param gender_a : gender of person a
@type gender_a: int gender
@param gender_b : gender of person b
@type gender_b: int gender
@param reltocommon_a : relation path to common ancestor or common
Family for person a.
Note that length = Ga
@type reltocommon_a: str
@param reltocommon_b : relation path to common ancestor or common
Family for person b.
Note that length = Gb
@type reltocommon_b: str
@param in_law_a : True if path to common ancestors is via the partner
of person a
@type in_law_a: bool
@param in_law_b : True if path to common ancestors is via the partner
of person b
@type in_law_b: bool
@param only_birth : True if relation between a and b is by birth only
False otherwise
@type only_birth: bool
@returns: A string describing the relationship between the two people
@rtype: str
NOTE: 1/the self.REL_SIBLING should not be passed to this routine,
so we should not check on it. All other self.
2/for better determination of siblings, use if Ga=1=Gb
get_sibling_relationship_string
"""
if only_birth:
step = ''
else:
step = self.STEP
if in_law_a or in_law_b :
inlaw = self.INLAW
else:
inlaw = ''
rel_str = u"avlägsen %s-släkting eller %s släkting" % (step, inlaw)
if Ga == 0:
# b is descendant of a
if Gb == 0 :
rel_str = 'samma person'
else:
rel_str = self._get_direct_descendant(gender_b, reltocommon_b, step, inlaw)
elif Gb == 0:
# b is parents/grand parent of a
rel_str = self._get_direct_ancestor(gender_b, reltocommon_a, step, inlaw)
elif Gb == 1:
# b is sibling/aunt/uncle of a
# handles brother and unknown gender as second person,
# shows up in "testing unknown cousins same generation"
if gender_b == gen.lib.Person.MALE or gender_b == gen.lib.Person.UNKNOWN:
rel_str = self._get_ancestors_brother(reltocommon_a, gender_b, step, inlaw)
elif gender_b == gen.lib.Person.FEMALE:
rel_str = self._get_ancestors_sister(reltocommon_a, step, inlaw)
elif Ga == Gb:
# a and b cousins in the same generation
rel_str = self._get_cousin(Ga-1, step, inlaw)
elif Ga > Gb:
# These are cousins in different generations with the second person
# being in a higher generation from the common ancestor than the
# first person.
rel_str = self._get_ancestors_cousin(reltocommon_a, reltocommon_b, step, inlaw)
elif Gb > Ga:
# These are cousins in different generations with the second person
# being in a lower generation from the common ancestor than the
# first person.
rel_str = self._get_cousins_descendant(gender_b, reltocommon_b, reltocommon_a, step, inlaw)
return rel_str
#-------------------------------------------------------------------------
#
# Register this class with the Plugins system
#
#-------------------------------------------------------------------------
pmgr = PluginManager.get_instance()
pmgr.register_relcalc(RelationshipCalculator,
["sv","SV","sv_SE","swedish","Swedish","sv_SE.UTF8","sv_SE@euro","sv_SE.UTF8@euro",
"svenska","Svenska", "sv_SE.UTF-8", "sv_SE.utf-8", "sv_SE.utf8"])
if __name__ == "__main__":
# Test function. Call it as follows from the command line (so as to find
# imported modules):
# export PYTHONPATH=/path/to/gramps/src
# python src/plugins/rel_fr.py
# (Above not needed here)
"""TRANSLATORS, copy this if statement at the bottom of your
rel_xx.py module, and test your work with:
python src/plugins/rel_xx.py
"""
from Relationship import test
rc = RelationshipCalculator()
test(rc, True)