From 5553c740927785e02ad728da4ba853021fb5225c Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Thu, 23 Jun 2005 03:09:57 +0000 Subject: [PATCH] * src/Relationship.py (is_spouse): return translated spouse name, based on gender and family relation. * src/plugins/rel_*.py (get_relationship): use new spouse scheme. svn: r4864 --- gramps2/ChangeLog | 3 +++ gramps2/src/Relationship.py | 27 ++++++++++++++++++--------- gramps2/src/plugins/rel_da.py | 10 ++++------ gramps2/src/plugins/rel_de.py | 7 ++++--- gramps2/src/plugins/rel_es.py | 10 ++++------ gramps2/src/plugins/rel_fi.py | 7 ++++--- gramps2/src/plugins/rel_fr.py | 8 +++----- gramps2/src/plugins/rel_hu.py | 12 ++++-------- gramps2/src/plugins/rel_it.py | 7 ++++--- gramps2/src/plugins/rel_no.py | 14 ++++---------- gramps2/src/plugins/rel_ru.py | 7 ++++--- gramps2/src/plugins/rel_sv.py | 10 ++++------ 12 files changed, 60 insertions(+), 62 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index c8817c688..cc5763db1 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -9,6 +9,9 @@ * src/FamilyView.py (remove_child_clicked): Prevent signal race. * NEWS: Update. * src/TarFile.py (extract_files): insert missing 'replace' call. + * src/Relationship.py (is_spouse): return translated spouse name, + based on gender and family relation. + * src/plugins/rel_*.py (get_relationship): use new spouse scheme. 2005-06-21 Don Allingham * src/GenericFilter.py: optimize a few filters diff --git a/gramps2/src/Relationship.py b/gramps2/src/Relationship.py index 6386d0f12..40b821363 100644 --- a/gramps2/src/Relationship.py +++ b/gramps2/src/Relationship.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2003-2004 Donald N. Allingham +# Copyright (C) 2003-2005 Donald N. Allingham # # 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 @@ -43,7 +43,7 @@ _level_name = [ "", "first", "second", "third", "fourth", "fifth", "sixth", _removed_level = [ "", " once removed", " twice removed", " three times removed", " four times removed", " five times removed", " six times removed", - " sevent times removed", " eight times removed", " nine times removed", + " sevent times removed", " eight times removed", " nine times removed", " ten times removed", " eleven times removed", " twelve times removed", " thirteen times removed", " fourteen times removed", " fifteen times removed", " sixteen times removed", " seventeen times removed", " eighteen times removed", @@ -240,12 +240,20 @@ class RelationshipCalculator: def is_spouse(self,orig,other): for f in orig.get_family_handle_list(): family = self.db.get_family_from_handle(f) - if family: - if other.get_handle() == family.get_father_handle() or other.get_handle() == family.get_mother_handle(): - return 1 + if family and other.get_handle() in [family.get_father_handle(), + family.get_mother_handle()]: + family_rel = family.get_relationship() + if other.get_gender() == RelLib.Person.MALE \ + and family_rel != RelLib.Family.CIVIL_UNION: + return _("husband") + elif other.get_gender() == RelLib.Person.FEMALE\ + and family_rel != RelLib.Family.CIVIL_UNION: + return _("wife") + else: + return _("partner") else: - return 0 - return 0 + return None + return None def get_relationship_distance(self,orig_person,other_person): """ @@ -304,8 +312,9 @@ class RelationshipCalculator: if orig_person.get_handle() == other_person.get_handle(): return ('', []) - if self.is_spouse(orig_person,other_person): - return ("spouse",[]) + is_spouse = self.is_spouse(orig_person,other_person) + if is_spouse: + return (is_spouse,[]) (firstRel,secondRel,common) = self.get_relationship_distance(orig_person,other_person) diff --git a/gramps2/src/plugins/rel_da.py b/gramps2/src/plugins/rel_da.py index 511be5e15..84d8d45f7 100644 --- a/gramps2/src/plugins/rel_da.py +++ b/gramps2/src/plugins/rel_da.py @@ -2,7 +2,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2003-2004 Donald N. Allingham +# Copyright (C) 2003-2005 Donald N. Allingham # # 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 @@ -147,11 +147,9 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): if orig_person.get_handle() == other_person.get_handle(): return ('', []) - if self.is_spouse(orig_person,other_person): - if other_person.get_gender() == RelLib.Person.MALE: - return ("ægtefælle",[]) - else: - return ("hustru",[]) + is_spouse = self.is_spouse(orig_person,other_person) + if is_spouse: + return (is_spouse,[]) (firstRel,secondRel,common) = self.get_relationship_distance(orig_person,other_person) diff --git a/gramps2/src/plugins/rel_de.py b/gramps2/src/plugins/rel_de.py index 2436547e4..5ac7cf874 100644 --- a/gramps2/src/plugins/rel_de.py +++ b/gramps2/src/plugins/rel_de.py @@ -2,7 +2,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2003-2004 Donald N. Allingham +# Copyright (C) 2003-2005 Donald N. Allingham # # 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 @@ -338,8 +338,9 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): if orig_person.get_handle() == other_person.get_handle(): return ('', []) - if self.is_spouse(orig_person,other_person): - return ("spouse",[]) + is_spouse = self.is_spouse(orig_person,other_person) + if is_spouse: + return (is_spouse,[]) (firstRel,secondRel,common) = self.get_relationship_distance(orig_person,other_person) diff --git a/gramps2/src/plugins/rel_es.py b/gramps2/src/plugins/rel_es.py index 93eee3062..d18ac6117 100644 --- a/gramps2/src/plugins/rel_es.py +++ b/gramps2/src/plugins/rel_es.py @@ -2,7 +2,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2003-2004 Donald N. Allingham +# Copyright (C) 2003-2005 Donald N. Allingham # # 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 @@ -254,11 +254,9 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): if orig_person.get_handle() == other_person.get_handle(): return ('', []) - if self.is_spouse(orig_person,other_person): - if other_person.get_gender() == RelLib.Person.MALE: - return ("marido",[]) - else: - return ("mujer",[]) + is_spouse = self.is_spouse(orig_person,other_person) + if is_spouse: + return (is_spouse,[]) (firstRel,secondRel,common) = self.get_relationship_distance(orig_person,other_person) diff --git a/gramps2/src/plugins/rel_fi.py b/gramps2/src/plugins/rel_fi.py index a3d2bc2f9..e057c9abd 100644 --- a/gramps2/src/plugins/rel_fi.py +++ b/gramps2/src/plugins/rel_fi.py @@ -2,7 +2,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2003-2004 Donald N. Allingham +# Copyright (C) 2003-2005 Donald N. Allingham # # 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 @@ -182,8 +182,9 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): if orig_person.get_handle() == other_person.get_handle(): return ('', []) - if self.is_spouse(orig_person,other_person): - return ("puoliso",[]) + is_spouse = self.is_spouse(orig_person,other_person) + if is_spouse: + return (is_spouse,[]) (firstRel,secondRel,common) = self.get_relationship_distance(orig_person,other_person) diff --git a/gramps2/src/plugins/rel_fr.py b/gramps2/src/plugins/rel_fr.py index 696b02c96..a184c57d3 100644 --- a/gramps2/src/plugins/rel_fr.py +++ b/gramps2/src/plugins/rel_fr.py @@ -154,11 +154,9 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): if orig_person.get_handle() == other_person.get_handle(): return ('', []) - if self.is_spouse(orig_person,other_person): - if other_person.get_gender() == RelLib.Person.MALE: - return ("le mari",[]) - else: - return ("la femme",[]) + is_spouse = self.is_spouse(orig_person,other_person) + if is_spouse: + return (is_spouse,[]) (firstRel,secondRel,common) = self.get_relationship_distance(orig_person,other_person) diff --git a/gramps2/src/plugins/rel_hu.py b/gramps2/src/plugins/rel_hu.py index cb9229cf3..17bf4d59c 100644 --- a/gramps2/src/plugins/rel_hu.py +++ b/gramps2/src/plugins/rel_hu.py @@ -2,7 +2,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2003-2004 Donald N. Allingham +# Copyright (C) 2003-2005 Donald N. Allingham # # 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 @@ -268,13 +268,9 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): if orig_person.get_handle() == other_person.get_handle(): return ('', []) - if self.is_spouse(orig_person,other_person): - if other_person.get_gender() == RelLib.Person.MALE: - #FIXME: husband - return ("spouse",[]) - else: - #FIXME: wife - return ("spouse",[]) + is_spouse = self.is_spouse(orig_person,other_person) + if is_spouse: + return (is_spouse,[]) if self.is_fathermother_in_law(other_person,orig_person): if other_person.getGender() == RelLib.Person.MALE: diff --git a/gramps2/src/plugins/rel_it.py b/gramps2/src/plugins/rel_it.py index 92dae1fe7..fc8db6c6d 100644 --- a/gramps2/src/plugins/rel_it.py +++ b/gramps2/src/plugins/rel_it.py @@ -2,7 +2,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2003-2004 Donald N. Allingham +# Copyright (C) 2003-2005 Donald N. Allingham # # 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 @@ -151,8 +151,9 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): if orig_person.get_handle() == other_person.get_handle(): return ('', []) - if self.is_spouse(orig_person,other_person): - return ("coniuge",[]) + is_spouse = self.is_spouse(orig_person,other_person) + if is_spouse: + return (is_spouse,[]) (firstRel,secondRel,common) = self.get_relationship_distance(orig_person,other_person) diff --git a/gramps2/src/plugins/rel_no.py b/gramps2/src/plugins/rel_no.py index 07ac52d12..61aa4d6d7 100644 --- a/gramps2/src/plugins/rel_no.py +++ b/gramps2/src/plugins/rel_no.py @@ -2,7 +2,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2003-2004 Donald N. Allingham +# Copyright (C) 2003-2005 Donald N. Allingham # # 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 @@ -232,15 +232,9 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): if orig_person.get_handle() == other_person.get_handle(): return ('', []) - if self.is_spouse(orig_person,other_person): - return ('spouse', []) -# FIXME: need Norwegian term for spouse. If gender-specific, use the code below. -# UPDATE by Frode: unsure about how it's included in the finished code, so I need -# to see this running to know if it is the right words to use. -# if other_person.get_gender() == RelLib.Person.MALE: -# return ("ektemann",[]) -# else: -# return ("hustru",[]) + is_spouse = self.is_spouse(orig_person,other_person) + if is_spouse: + return (is_spouse,[]) (firstRel,secondRel,common) = self.get_relationship_distance(orig_person,other_person) diff --git a/gramps2/src/plugins/rel_ru.py b/gramps2/src/plugins/rel_ru.py index 2e745fbd0..409412823 100644 --- a/gramps2/src/plugins/rel_ru.py +++ b/gramps2/src/plugins/rel_ru.py @@ -2,7 +2,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2003-2004 Donald N. Allingham +# Copyright (C) 2003-2005 Donald N. Allingham # # 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 @@ -206,8 +206,9 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): if orig_person.get_handle() == other_person.get_handle(): return ('', []) - if self.is_spouse(orig_person,other_person): - return ("spouse",[]) + is_spouse = self.is_spouse(orig_person,other_person) + if is_spouse: + return (is_spouse,[]) (firstRel,secondRel,common) = self.get_relationship_distance(orig_person,other_person) diff --git a/gramps2/src/plugins/rel_sv.py b/gramps2/src/plugins/rel_sv.py index 219706ad8..ac323e5d3 100644 --- a/gramps2/src/plugins/rel_sv.py +++ b/gramps2/src/plugins/rel_sv.py @@ -2,7 +2,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2003-2004 Donald N. Allingham +# Copyright (C) 2003-2005 Donald N. Allingham # # 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 @@ -187,11 +187,9 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): if orig_person.get_handle() == other_person.get_handle(): return ('', []) - if self.is_spouse(orig_person,other_person): - if other_person.get_gender() == RelLib.Person.MALE: - return ("make",[]) - else: - return ("maka",[]) + is_spouse = self.is_spouse(orig_person,other_person) + if is_spouse: + return (is_spouse,[]) (firstRel,secondRel,common) = self.get_relationship_distance(orig_person,other_person)