feature request: 7963

https://gramps-project.org/bugs/view.php?id=7963
to add an optional [alternate name] on the $n and $s vars as follows:
$n[Married Name](regular format string)
$s[Also Known As](regular format string)
  Craig A.
This commit is contained in:
Craig J. Anderson 2014-08-09 11:30:21 -04:00
parent 86303f6116
commit 75f62ea5b9

View File

@ -149,11 +149,18 @@ class NameFormat(GenericFormat):
otherwise, parse through a format string and put the name parts in
"""
def get_name(self, person):
def get_name(self, person, aka):
""" A helper method for retrieving the person's name """
name = None
if person:
return person.get_primary_name()
return None
if aka is None:
name = person.get_primary_name()
else:
for names in person.get_alternate_names():
if names.get_type() == aka:
name = names
break
return name
def _default_format(self, name):
""" display the name as set in preferences """
@ -860,9 +867,9 @@ class VariableParse(object):
return
return place_f.parse_format(self.database, place)
def __parse_name(self, person):
def __parse_name(self, person, attrib_parse):
name_format = NameFormat(self._in, self._locale)
name = name_format.get_name(person)
name = name_format.get_name(person, attrib_parse.get_name())
return name_format.parse_format(name)
def __parse_id(self, first_class_object):
@ -912,10 +919,10 @@ class VariableParse(object):
if next_char == "n":
#Person's name
return self.__parse_name(self.friend.person)
return self.__parse_name(self.friend.person, attrib_parse)
elif next_char == "s":
#Souses name
return self.__parse_name(self.friend.spouse)
return self.__parse_name(self.friend.spouse, attrib_parse)
elif next_char == "i":
#Person's Id