diff --git a/gramps/gen/lib/place.py b/gramps/gen/lib/place.py index 1bd9fd750..36ea6d02f 100644 --- a/gramps/gen/lib/place.py +++ b/gramps/gen/lib/place.py @@ -472,6 +472,35 @@ class Place(CitationBase, NoteBase, MediaBase, UrlBase, PrimaryObject): if placeref.ref == old_handle: placeref.ref = new_handle + def get_alternative_names(self): + """ + Return a list of alternative names for the current Place. + + :returns: Returns the alternative names for the Place + :rtype: list of strings + """ + return self.alt_names + + def set_alternative_names(self, name_list): + """ + Replace the current alternative names list with the new one. + + :param name_list: The list of names to assign to the Place's internal + list. + :type name_list: list of strings + """ + self.alt_names = name_list + + def add_alternative_name(self, name): + """ + Add a name to the alternative names list. + + :param name: name to add + :type name: string + """ + if name not in self.alt_names: + self.alt_names.append(name) + def get_alternate_locations(self): """ Return a list of alternate :class:`~.location.Location` objects the diff --git a/gramps/plugins/export/exportxml.py b/gramps/plugins/export/exportxml.py index fa06a69f4..b592daf88 100644 --- a/gramps/plugins/export/exportxml.py +++ b/gramps/plugins/export/exportxml.py @@ -1200,7 +1200,9 @@ class GrampsXmlWriter(UpdateCallback): self.write_line_nofix("pname", name, index+1) self.write_line_nofix("type", ptype, index+1) self.write_line_nofix("code", code, index+1) - + for name in place.get_alternative_names(): + self.write_line("alt_name", name, index+1) + longitude = self.fix(place.get_longitude()) lat = self.fix(place.get_latitude()) if longitude or lat: diff --git a/gramps/plugins/importer/importxml.py b/gramps/plugins/importer/importxml.py index 1a9cec365..e02f79dd5 100644 --- a/gramps/plugins/importer/importxml.py +++ b/gramps/plugins/importer/importxml.py @@ -626,6 +626,7 @@ class GrampsParser(UpdateCallback): #other "address": (self.start_address, self.stop_address), "addresses": (None, None), + "alt_name": (None, self.stop_alt_name), "childlist": (None, None), "attribute": (self.start_attribute, self.stop_attribute), "attr_type": (None, self.stop_attr_type), @@ -2583,6 +2584,9 @@ class GrampsParser(UpdateCallback): def stop_code(self, tag): self.placeobj.code = tag + def stop_alt_name(self, tag): + self.placeobj.add_alternative_name(tag) + def stop_placeobj(self, *tag): self.db.commit_place(self.placeobj, self.trans, self.placeobj.get_change_time())