From e46321a7c683d072c71e1cd3502aa0195374462f Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Mon, 20 Feb 2017 16:24:09 +0000 Subject: [PATCH] Move labels into schema --- gramps/gen/lib/citation.py | 57 +++++++++++----------- gramps/gen/lib/event.py | 58 +++++++++++----------- gramps/gen/lib/eventref.py | 32 +++++-------- gramps/gen/lib/family.py | 66 ++++++++++++------------- gramps/gen/lib/grampstype.py | 12 ++--- gramps/gen/lib/media.py | 68 +++++++++++--------------- gramps/gen/lib/name.py | 66 ++++++++++++------------- gramps/gen/lib/note.py | 34 ++++++------- gramps/gen/lib/person.py | 88 ++++++++++++++++------------------ gramps/gen/lib/place.py | 73 ++++++++++++++-------------- gramps/gen/lib/repo.py | 45 ++++++++--------- gramps/gen/lib/secondaryobj.py | 24 ---------- gramps/gen/lib/src.py | 60 +++++++++++------------ gramps/gen/lib/styledtext.py | 16 +++---- gramps/gen/lib/surname.py | 26 +++++----- gramps/gen/lib/tableobj.py | 7 --- gramps/gen/lib/tag.py | 31 +++++------- 17 files changed, 330 insertions(+), 433 deletions(-) diff --git a/gramps/gen/lib/citation.py b/gramps/gen/lib/citation.py index a6bae4cc9..3cf836698 100644 --- a/gramps/gen/lib/citation.py +++ b/gramps/gen/lib/citation.py @@ -44,6 +44,8 @@ from .datebase import DateBase from .tagbase import TagBase from .attrbase import SrcAttributeBase from .citationbase import IndirectCitationBase +from ..const import GRAMPS_LOCALE as glocale +_ = glocale.translation.gettext LOG = logging.getLogger(".citation") @@ -92,51 +94,46 @@ class Citation(MediaBase, NoteBase, SrcAttributeBase, IndirectCitationBase, from .date import Date return { "type": "object", + "title": _("Citation"), "properties": { "_class": {"enum": [cls.__name__]}, "handle": {"type": "string", - "maxLength": 50}, - "gramps_id": {"type": "string"}, - "date": {"oneOf": [{"type": "null"}, Date.get_schema()]}, - "page": {"type": "string"}, + "maxLength": 50, + "title": _("Handle")}, + "gramps_id": {"type": "string", + "title": _("Gramps ID")}, + "date": {"oneOf": [{"type": "null"}, Date.get_schema()], + "title": _("Date")}, + "page": {"type": "string", + "title": _("Page")}, "confidence": {"type": "integer", "minimum": 0, - "maximum": 4}, + "maximum": 4, + "title": _("Confidence")}, "source_handle": {"type": "string", - "maxLength": 50}, + "maxLength": 50, + "title": _("Source")}, "note_list": {"type": "array", "items": {"type": "string", - "maxLength": 50}}, + "maxLength": 50}, + "title": _("Notes")}, "media_list": {"type": "array", - "items": MediaRef.get_schema()}, + "items": MediaRef.get_schema(), + "title": _("Media")}, "srcattr_list": {"type": "array", - "items": SrcAttribute.get_schema()}, - "change": {"type": "integer"}, + "items": SrcAttribute.get_schema(), + "title": _("Source Attributes")}, + "change": {"type": "integer", + "title": _("Last changed")}, "tag_list": {"type": "array", "items": {"type": "string", - "maxLength": 50}}, - "private": {"type": "boolean"} + "maxLength": 50}, + "title": _("Tags")}, + "private": {"type": "boolean", + "title": _("Private")} } } - @classmethod - def get_labels(cls, _): - return { - "_class": _("Citation"), - "handle": _("Handle"), - "gramps_id": _("Gramps ID"), - "date": _("Date"), - "page": _("Page"), - "confidence": _("Confidence"), - "source_handle": _("Source"), - "note_list": _("Notes"), - "media_list": _("Media"), - "srcattribute_list": _("Source Attributes"), - "change": _("Last changed"), - "tag_list": _("Tags"), - "private": _("Private"), - } - def serialize(self, no_text_date=False): """ Convert the object to a serialized tuple of data. diff --git a/gramps/gen/lib/event.py b/gramps/gen/lib/event.py index 0dc1d8d5b..f82bc7c8e 100644 --- a/gramps/gen/lib/event.py +++ b/gramps/gen/lib/event.py @@ -46,6 +46,8 @@ from .datebase import DateBase from .placebase import PlaceBase from .tagbase import TagBase from .eventtype import EventType +from ..const import GRAMPS_LOCALE as glocale +_ = glocale.translation.gettext LOG = logging.getLogger(".citation") @@ -131,53 +133,47 @@ class Event(CitationBase, NoteBase, MediaBase, AttributeBase, from .mediaref import MediaRef return { "type": "object", + "title": _("Event"), "properties": { "_class": {"enum": [cls.__name__]}, "handle": {"type": "string", - "maxLength": 50}, - "gramps_id": {"type": "string"}, + "maxLength": 50, + "title": _("Handle")}, + "gramps_id": {"type": "string", + "title": _("Gramps ID")}, "type": EventType.get_schema(), - "date": {"oneOf": [{"type": "null"}, Date.get_schema()]}, - "description": {"type": "string"}, + "date": {"oneOf": [{"type": "null"}, Date.get_schema()], + "title": _("Date")}, + "description": {"type": "string", + "title": _("Description")}, "place": {"type": ["string", "null"], - "maxLength": 50}, + "maxLength": 50, + "title": _("Place")}, "citation_list": {"type": "array", "items": {"type": "string", - "maxLength": 50}}, + "maxLength": 50}, + "title": _("Citations")}, "note_list": {"type": "array", "items": {"type": "string", - "maxLength": 50}}, + "maxLength": 50}, + "title": _("Notes")}, "media_list": {"type": "array", - "items": MediaRef.get_schema()}, + "items": MediaRef.get_schema(), + "title": _("Media")}, "attribute_list": {"type": "array", - "items": Attribute.get_schema()}, - "change": {"type": "integer"}, + "items": Attribute.get_schema(), + "title": _("Media")}, + "change": {"type": "integer", + "title": _("Last changed")}, "tag_list": {"type": "array", "items": {"type": "string", - "maxLength": 50}}, - "private": {"type": "boolean"}, + "maxLength": 50}, + "title": _("Tags")}, + "private": {"type": "boolean", + "title": _("Private")}, } } - @classmethod - def get_labels(cls, _): - return { - "_class": _("Event"), - "handle": _("Handle"), - "gramps_id": _("Gramps ID"), - "type": _("Type"), - "date": _("Date"), - "description": _("Description"), - "place": _("Place"), - "citation_list": _("Citations"), - "note_list": _("Notes"), - "media_list": _("Media"), - "attribute_list": _("Attributes"), - "change": _("Last changed"), - "tag_list": _("Tags"), - "private": _("Private"), - } - def unserialize(self, data): """ Convert the data held in a tuple created by the serialize method diff --git a/gramps/gen/lib/eventref.py b/gramps/gen/lib/eventref.py index b64cf63eb..0b94ffbec 100644 --- a/gramps/gen/lib/eventref.py +++ b/gramps/gen/lib/eventref.py @@ -39,6 +39,8 @@ from .refbase import RefBase from .eventroletype import EventRoleType from .const import IDENTICAL, EQUAL, DIFFERENT from .citationbase import IndirectCitationBase +from ..const import GRAMPS_LOCALE as glocale +_ = glocale.translation.gettext #------------------------------------------------------------------------- # @@ -90,37 +92,25 @@ class EventRef(PrivacyBase, NoteBase, AttributeBase, RefBase, from .attribute import Attribute return { "type": "object", + "title": _("Event reference"), "properties": { "_class": {"enum": [cls.__name__]}, - "private": {"type": "boolean"}, + "private": {"type": "boolean", + "title": _("Private")}, "note_list": {"type": "array", "items": {"type": "string", - "maxLength": 50}}, + "maxLength": 50}, + "title": _("Notes")}, "attribute_list": {"type": "array", - "items": Attribute.get_schema()}, + "items": Attribute.get_schema(), + "title": _("Attributes")}, "ref": {"type": "string", - "maxLength": 50}, + "maxLength": 50, + "title": _("Event")}, "role": EventRoleType.get_schema(), } } - @classmethod - def get_labels(cls, _): - """ - Given a translation function, returns the labels for - each field of this object. - - :returns: Returns a dict containing the fields to labels. - :rtype: dict - """ - return { - "private": _("Private"), - "note_list": _("Notes"), - "attribute_list": _("Attributes"), - "ref": _("Event"), - "role": _("Role"), - } - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/family.py b/gramps/gen/lib/family.py index 29158a7ba..9557dfaf0 100644 --- a/gramps/gen/lib/family.py +++ b/gramps/gen/lib/family.py @@ -49,6 +49,8 @@ from .tagbase import TagBase from .childref import ChildRef from .familyreltype import FamilyRelType from .const import IDENTICAL, EQUAL, DIFFERENT +from ..const import GRAMPS_LOCALE as glocale +_ = glocale.translation.gettext LOG = logging.getLogger(".citation") @@ -140,61 +142,55 @@ class Family(CitationBase, NoteBase, MediaBase, AttributeBase, LdsOrdBase, from .attribute import Attribute return { "type": "object", + "title": _("Family"), "properties": { "_class": {"enum": [cls.__name__]}, "handle": {"type": "string", - "maxLength": 50}, - "gramps_id": {"type": "string"}, + "maxLength": 50, + "title": _("Handle")}, + "gramps_id": {"type": "string", + "title": _("Gramps ID")}, "father_handle": {"type": ["string", "null"], - "maxLength": 50}, + "maxLength": 50, + "title": _("Father")}, "mother_handle": {"type": ["string", "null"], - "maxLength": 50}, + "maxLength": 50, + "title": _("Mother")}, "child_ref_list": {"type": "array", - "items": ChildRef.get_schema()}, + "items": ChildRef.get_schema(), + "title": _("Children")}, "type": FamilyRelType.get_schema(), "event_ref_list": {"type": "array", - "items": EventRef.get_schema()}, + "items": EventRef.get_schema(), + "title": _("Events")}, "media_list": {"type": "array", - "items": MediaRef.get_schema()}, + "items": MediaRef.get_schema(), + "title": _("Media")}, "attribute_list": {"type": "array", - "items": Attribute.get_schema()}, + "items": Attribute.get_schema(), + "title": _("Attributes")}, "lds_ord_list": {"type": "array", - "items": LdsOrd.get_schema()}, + "items": LdsOrd.get_schema(), + "title": _("LDS ordinances")}, "citation_list": {"type": "array", "items": {"type": "string", - "maxLength": 50}}, + "maxLength": 50}, + "title": _("Citations")}, "note_list": {"type": "array", "items": {"type": "string", - "maxLength": 50}}, - "change": {"type": "integer"}, + "maxLength": 50}, + "title": _("Notes")}, + "change": {"type": "integer", + "title": _("Last changed")}, "tag_list": {"type": "array", "items": {"type": "string", - "maxLength": 50}}, - "private": {"type": "boolean"} + "maxLength": 50}, + "title": _("Tags")}, + "private": {"type": "boolean", + "title": _("Private")} } } - @classmethod - def get_labels(cls, _): - return { - "_class": _("Family"), - "handle": _("Handle"), - "gramps_id": _("Gramps ID"), - "father_handle": _("Father"), - "mother_handle": _("Mother"), - "child_ref_list": _("Children"), - "type": _("Relationship"), - "event_ref_list": _("Events"), - "media_list": _("Media"), - "attribute_list": _("Attributes"), - "lds_ord_list": _("LDS ordinances"), - "citation_list": _("Citations"), - "note_list": _("Notes"), - "change": _("Last changed"), - "tag_list": _("Tags"), - "private": _("Private"), - } - def unserialize(self, data): """ Convert the data held in a tuple created by the serialize method diff --git a/gramps/gen/lib/grampstype.py b/gramps/gen/lib/grampstype.py index a6dd7b721..e45e42fa3 100644 --- a/gramps/gen/lib/grampstype.py +++ b/gramps/gen/lib/grampstype.py @@ -218,20 +218,14 @@ class GrampsType(object, metaclass=GrampsTypeMeta): """ return { "type": "object", + "title": _("Type"), "properties": { "_class": {"enum": [cls.__name__]}, - "string": {"type": "string"}, + "string": {"type": "string", + "title": _("Type")}, } } - @classmethod - def get_labels(cls, _): - return { - "_class": _("Family Relationship"), - "value": _("Family Relationship"), - "string": _("Family Relationship"), - } - def unserialize(self, data): """Convert a serialized tuple of data to an object.""" self.__value, self.__string = data diff --git a/gramps/gen/lib/media.py b/gramps/gen/lib/media.py index e2c1dffc5..4040ca17c 100644 --- a/gramps/gen/lib/media.py +++ b/gramps/gen/lib/media.py @@ -45,6 +45,8 @@ from .notebase import NoteBase from .datebase import DateBase from .attrbase import AttributeBase from .tagbase import TagBase +from ..const import GRAMPS_LOCALE as glocale +_ = glocale.translation.gettext LOG = logging.getLogger(".citation") @@ -129,57 +131,45 @@ class Media(CitationBase, NoteBase, DateBase, AttributeBase, from .date import Date return { "type": "object", + "title": _("Media"), "properties": { "_class": {"enum": [cls.__name__]}, "handle": {"type": "string", - "maxLength": 50}, - "gramps_id": {"type": "string"}, - "path": {"type": "string"}, - "mime": {"type": "string"}, - "desc": {"type": "string"}, - "checksum": {"type": "string"}, + "maxLength": 50, + "title": _("Handle")}, + "gramps_id": {"type": "string", + "title": _("Gramps ID")}, + "path": {"type": "string", + "title": _("Path")}, + "mime": {"type": "string", + "title": _("MIME")}, + "desc": {"type": "string", + "title": _("Description")}, + "checksum": {"type": "string", + "title": _("Checksum")}, "attribute_list": {"type": "array", - "items": Attribute.get_schema()}, + "items": Attribute.get_schema(), + "title": _("Attributes")}, "citation_list": {"type": "array", "items": {"type": "string", - "maxLength": 50}}, + "maxLength": 50}, + "title": _("Citations")}, "note_list": {"type": "array", - "items": {"type": "string"}}, - "change": {"type": "integer"}, - "date": {"oneOf": [{"type": "null"}, Date.get_schema()]}, + "items": {"type": "string"}, + "title": _("Notes")}, + "change": {"type": "integer", + "title": _("Last changed")}, + "date": {"oneOf": [{"type": "null"}, Date.get_schema()], + "title": _("Date")}, "tag_list": {"type": "array", "items": {"type": "string", - "maxLength": 50}}, - "private": {"type": "boolean"} + "maxLength": 50}, + "title": _("Tags")}, + "private": {"type": "boolean", + "title": _("Private")} } } - @classmethod - def get_labels(cls, _): - """ - Given a translation function, returns the labels for - each field of this object. - - :returns: Returns a dict containing the fields to labels. - :rtype: dict - """ - return { - "_class": _("Media"), - "handle": _("Media"), - "gramps_id": _("Gramps ID"), - "path": _("Path"), - "mime": _("MIME"), - "desc": _("Description"), - "checksum": _("Checksum"), - "attribute_list": _("Attributes"), - "citation_list": _("Citations"), - "note_list": _("Notes"), - "change": _("Last changed"), - "date": _("Date"), - "tag_list": _("Tags"), - "private": _("Private"), - } - def unserialize(self, data): """ Convert the data held in a tuple created by the serialize method diff --git a/gramps/gen/lib/name.py b/gramps/gen/lib/name.py index e89421320..6a6d0791b 100644 --- a/gramps/gen/lib/name.py +++ b/gramps/gen/lib/name.py @@ -40,7 +40,7 @@ from .surnamebase import SurnameBase from .nametype import NameType from .const import IDENTICAL, EQUAL, DIFFERENT from .date import Date -from gramps.gen.const import GRAMPS_LOCALE as glocale +from ..const import GRAMPS_LOCALE as glocale _ = glocale.translation.gettext #------------------------------------------------------------------------- @@ -129,27 +129,6 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, CitationBase, NoteBase, self.group_as, self.sort_as, self.display_as, self.call, self.nick, self.famnick) - @classmethod - def get_labels(cls, _): - return { - "_class": _("Name"), - "private": _("Private"), - "citation_list": _("Citations"), - "note_list": _("Notes"), - "date": _("Date"), - "first_name": _("Given name"), - "surname_list": _("Surnames"), - "suffix": _("Suffix"), - "title": _("Title"), - "type": _("Type"), - "group_as": _("Group as"), - "sort_as": _("Sort as"), - "display_as": _("Display as"), - "call": _("Call name"), - "nick": _("Nick name"), - "famnick": _("Family nick name"), - } - @classmethod def get_schema(cls): """ @@ -161,28 +140,43 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, CitationBase, NoteBase, from .surname import Surname return { "type": "object", + "title": _("Name"), "properties": { "_class": {"enum": [cls.__name__]}, - "private": {"type": "boolean"}, + "private": {"type": "boolean", + "title": _("Private")}, "citation_list": {"type": "array", "items": {"type": "string", - "maxLength": 50}}, + "maxLength": 50}, + "title": _("Citations")}, "note_list": {"type": "array", "items": {"type": "string", - "maxLength": 50}}, - "date": {"oneOf": [{"type": "null"}, Date.get_schema()]}, - "first_name": {"type": "string"}, + "maxLength": 50}, + "title": _("Notes")}, + "date": {"oneOf": [{"type": "null"}, Date.get_schema()], + "title": _("Date")}, + "first_name": {"type": "string", + "title": _("Given name")}, "surname_list": {"type": "array", - "items": Surname.get_schema()}, - "suffix": {"type": "string"}, - "title": {"type": "string"}, + "items": Surname.get_schema(), + "title": _("Surnames")}, + "suffix": {"type": "string", + "title": _("Suffix")}, + "title": {"type": "string", + "title": _("Title")}, "type": NameType.get_schema(), - "group_as": {"type": "string"}, - "sort_as": {"type": "integer"}, - "display_as": {"type": "integer"}, - "call": {"type": "string"}, - "nick": {"type": "string"}, - "famnick": {"type": "string"} + "group_as": {"type": "string", + "title": _("Group as")}, + "sort_as": {"type": "integer", + "title": _("Sort as")}, + "display_as": {"type": "integer", + "title": _("Display as")}, + "call": {"type": "string", + "title": _("Call name")}, + "nick": {"type": "string", + "title": _("Nick name")}, + "famnick": {"type": "string", + "title": _("Family nick name")} } } diff --git a/gramps/gen/lib/note.py b/gramps/gen/lib/note.py index d7e19420e..b43c6c4f3 100644 --- a/gramps/gen/lib/note.py +++ b/gramps/gen/lib/note.py @@ -34,6 +34,8 @@ from .tagbase import TagBase from .notetype import NoteType from .styledtext import StyledText from .styledtexttagtype import StyledTextTagType +from ..const import GRAMPS_LOCALE as glocale +_ = glocale.translation.gettext #------------------------------------------------------------------------- # @@ -104,35 +106,29 @@ class Note(BasicPrimaryObject): """ return { "type": "object", + "title": _("Note"), "properties": { "_class": {"enum": [cls.__name__]}, "handle": {"type": "string", - "maxLength": 50}, - "gramps_id": {"type": "string"}, + "maxLength": 50, + "title": ("Handle")}, + "gramps_id": {"type": "string", + "title": _("Gramps ID")}, "text": StyledText.get_schema(), - "format": {"type": "integer"}, + "format": {"type": "integer", + "title": _("Format")}, "type": NoteType.get_schema(), - "change": {"type": "integer"}, + "change": {"type": "integer", + "title": _("Last changed")}, "tag_list": {"type": "array", "items": {"type": "string", - "maxLength": 50}}, - "private": {"type": "boolean"} + "maxLength": 50}, + "title": _("Tags")}, + "private": {"type": "boolean", + "title": _("Private")} } } - @classmethod - def get_labels(cls, _): - return { - "handle": _("Handle"), - "gramps_id": _("Gramps ID"), - "text": _("Text"), - "format": _("Format"), - "type": _("Type"), - "change": _("Last changed"), - "tag_list": _("Tags"), - "private": _("Private"), - } - def unserialize(self, data): """Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/person.py b/gramps/gen/lib/person.py index 693fd3775..00ec9462d 100644 --- a/gramps/gen/lib/person.py +++ b/gramps/gen/lib/person.py @@ -156,33 +156,6 @@ class Person(CitationBase, NoteBase, AttributeBase, MediaBase, [pr.serialize() for pr in self.person_ref_list] # 20 ) - @classmethod - def get_labels(cls, _): - return { - "handle": _("Handle"), - "gramps_id": _("Gramps ID"), - "gender": _("Gender"), - "primary_name": _("Primary name"), - "alternate_names": _("Alternate names"), - "death_ref_index": _("Death reference index"), - "birth_ref_index": _("Birth reference index"), - "event_ref_list": _("Event references"), - "family_list": _("Families"), - "parent_family_list": _("Parent families"), - "media_list": _("Media"), - "address_list": _("Addresses"), - "attribute_list": _("Attributes"), - "urls": _("Urls"), - "lds_ord_list": _("LDS ordinances"), - "citation_list": _("Citations"), - "note_list": _("Notes"), - "change": _("Last changed"), - "tag_list": _("Tags"), - "private": _("Private"), - "person_ref_list": _("Person references"), - "probably_alive": _("Probably alive"), - } - @classmethod def get_schema(cls): """ @@ -197,50 +170,71 @@ class Person(CitationBase, NoteBase, AttributeBase, MediaBase, from .ldsord import LdsOrd return { "type": "object", + "title": _("Person"), "properties": { "_class": {"enum": [cls.__name__]}, "handle": {"type": "string", - "maxLength": 50}, - "gramps_id": {"type": "string"}, + "maxLength": 50, + "title": _("Handle")}, + "gramps_id": {"type": "string", + "title": _("Gramps ID")}, "gender": {"type": "integer", "minimum": 0, - "maximum": 2}, + "maximum": 2, + "title": _("Gender")}, "primary_name": Name.get_schema(), "alternate_names": {"type": "array", - "items": Name.get_schema()}, - "death_ref_index": {"type": "integer"}, - "birth_ref_index": {"type": "integer"}, + "items": Name.get_schema(), + "title": _("Alternate names")}, + "death_ref_index": {"type": "integer", + "title": _("Death reference index")}, + "birth_ref_index": {"type": "integer", + "title": _("Birth reference index")}, "event_ref_list": {"type": "array", - "items": EventRef.get_schema()}, + "items": EventRef.get_schema(), + "title": _("Event references")}, "family_list": {"type": "array", "items": {"type": "string", - "maxLength": 50}}, + "maxLength": 50}, + "title": _("Families")}, "parent_family_list": {"type": "array", "items": {"type": "string", - "maxLength": 50}}, + "maxLength": 50}, + "title": _("Parent families")}, "media_list": {"type": "array", - "items": MediaRef.get_schema()}, + "items": MediaRef.get_schema(), + "title": _("Media")}, "address_list": {"type": "array", - "items": Address.get_schema()}, + "items": Address.get_schema(), + "title": _("Addresses")}, "attribute_list": {"type": "array", - "items": Attribute.get_schema()}, + "items": Attribute.get_schema(), + "title": _("Attributes")}, "urls": {"type": "array", - "items": Url.get_schema()}, + "items": Url.get_schema(), + "title": _("Urls")}, "lds_ord_list": {"type": "array", - "items": LdsOrd.get_schema()}, + "items": LdsOrd.get_schema(), + "title": _("LDS ordinances")}, "citation_list": {"type": "array", "items": {"type": "string", - "maxLength": 50}}, + "maxLength": 50}, + "title": _("Citations")}, "note_list": {"type": "array", "items": {"type": "string", - "maxLength": 50}}, - "change": {"type": "integer"}, + "maxLength": 50}, + "title": _("Notes")}, + "change": {"type": "integer", + "title": _("Last changed")}, "tag_list": {"type": "array", "items": {"type": "string", - "maxLength": 50}}, - "private": {"type": "boolean"}, + "maxLength": 50}, + "title": _("Tags")}, + "private": {"type": "boolean", + "title": _("Private")}, "person_ref_list": {"type": "array", - "items": PersonRef.get_schema()} + "items": PersonRef.get_schema(), + "title": _("Person references")} } } diff --git a/gramps/gen/lib/place.py b/gramps/gen/lib/place.py index a6301cc03..39b6c1ee3 100644 --- a/gramps/gen/lib/place.py +++ b/gramps/gen/lib/place.py @@ -41,6 +41,8 @@ from .mediabase import MediaBase from .urlbase import UrlBase from .tagbase import TagBase from .location import Location +from ..const import GRAMPS_LOCALE as glocale +_ = glocale.translation.gettext #------------------------------------------------------------------------- # @@ -118,28 +120,6 @@ class Place(CitationBase, NoteBase, MediaBase, UrlBase, PrimaryObject): self.change, TagBase.serialize(self), self.private) @classmethod - def get_labels(cls, _): - return { - "handle": _("Handle"), - "gramps_id": _("Gramps ID"), - "title": _("Title"), - "long": _("Longitude"), - "lat": _("Latitude"), - "placeref_list": _("Places"), - "name": _("Name"), - "alt_names": _("Alternate Names"), - "place_type": _("Type"), - "code": _("Code"), - "alt_loc": _("Alternate Locations"), - "urls": _("URLs"), - "media_list": _("Media"), - "citation_list": _("Citations"), - "note_list": _("Notes"), - "change": _("Last changed"), - "tag_list": _("Tags"), - "private": _("Private") - } - @classmethod def get_schema(cls): """ Returns the JSON Schema for this class. @@ -151,38 +131,55 @@ class Place(CitationBase, NoteBase, MediaBase, UrlBase, PrimaryObject): from .mediaref import MediaRef return { "type": "object", + "title": _("Place"), "properties": { "_class": {"enum": [cls.__name__]}, "handle": {"type": "string", - "maxLength": 50}, - "gramps_id": {"type": "string"}, - "title": {"type": "string"}, - "long": {"type": "string"}, - "lat": {"type": "string"}, + "maxLength": 50, + "title": _("Handle")}, + "gramps_id": {"type": "string", + "title": _("Gramps ID")}, + "title": {"type": "string", + "title": _("Title")}, + "long": {"type": "string", + "title": _("Longitude")}, + "lat": {"type": "string", + "title": _("Latitude")}, "placeref_list": {"type": "array", - "items": PlaceRef.get_schema()}, + "items": PlaceRef.get_schema(), + "title": _("Places")}, "name": PlaceName.get_schema(), "alt_names": {"type": "array", - "items": PlaceName.get_schema()}, + "items": PlaceName.get_schema(), + "title": _("Alternate Names")}, "place_type": PlaceType.get_schema(), - "code": {"type": "string"}, + "code": {"type": "string", + "title": _("Code")}, "alt_loc": {"type": "array", - "items": Location.get_schema()}, + "items": Location.get_schema(), + "title": _("Alternate Locations")}, "urls": {"type": "array", - "items": Url.get_schema()}, + "items": Url.get_schema(), + "title": _("URLs")}, "media_list": {"type": "array", - "items": MediaRef.get_schema()}, + "items": MediaRef.get_schema(), + "title": _("Media")}, "citation_list": {"type": "array", "items": {"type": "string", - "maxLength": 50}}, + "maxLength": 50}, + "title": _("Citations")}, "note_list": {"type": "array", "items": {"type": "string", - "maxLength": 50}}, - "change": {"type": "integer"}, + "maxLength": 50}, + "title": _("Notes")}, + "change": {"type": "integer", + "title": _("Last changed")}, "tag_list": {"type": "array", "items": {"type": "string", - "maxLength": 50}}, - "private": {"type": "boolean"} + "maxLength": 50}, + "title": _("Tags")}, + "private": {"type": "boolean", + "title": _("Private")} } } diff --git a/gramps/gen/lib/repo.py b/gramps/gen/lib/repo.py index 487b995f8..acc729d98 100644 --- a/gramps/gen/lib/repo.py +++ b/gramps/gen/lib/repo.py @@ -37,6 +37,8 @@ from .urlbase import UrlBase from .tagbase import TagBase from .repotype import RepositoryType from .citationbase import IndirectCitationBase +from ..const import GRAMPS_LOCALE as glocale +_ = glocale.translation.gettext #------------------------------------------------------------------------- # @@ -69,21 +71,6 @@ class Repository(NoteBase, AddressBase, UrlBase, IndirectCitationBase, UrlBase.serialize(self), self.change, TagBase.serialize(self), self.private) - @classmethod - def get_labels(cls, _): - return { - "handle": _("Handle"), - "gramps_id": _("Gramps ID"), - "type": _("Type"), - "name": _("Name"), - "note_list": _("Notes"), - "address_list": _("Addresses"), - "urls": _("URLs"), - "change": _("Last changed"), - "tag_list": _("Tags"), - "private": _("Private") - } - @classmethod def get_schema(cls): """ @@ -96,25 +83,35 @@ class Repository(NoteBase, AddressBase, UrlBase, IndirectCitationBase, from .url import Url return { "type": "object", + "title": _("Repository"), "properties": { "_class": {"enum": [cls.__name__]}, "handle": {"type": "string", - "maxLength": 50}, - "gramps_id": {"type": "string"}, + "maxLength": 50, + "title": _("Handle")}, + "gramps_id": {"type": "string", + "title": _("Gramps ID")}, "type": RepositoryType.get_schema(), - "name": {"type": "string"}, + "name": {"type": "string", + "title": _("Name")}, "note_list": {"type": "array", "items": {"type": "string", - "maxLength": 50}}, + "maxLength": 50}, + "title": _("Notes")}, "address_list": {"type": "array", - "items": Address.get_schema()}, + "items": Address.get_schema(), + "title": _("Addresses")}, "urls": {"type": "array", - "items": Url.get_schema()}, - "change": {"type": "integer"}, + "items": Url.get_schema(), + "title": _("URLs")}, + "change": {"type": "integer", + "title": _("Last changed")}, "tag_list": {"type": "array", "items": {"type": "string", - "maxLength": 50}}, - "private": {"type": "boolean"} + "maxLength": 50}, + "title": _("Tags")}, + "private": {"type": "boolean", + "title": _("Private")} } } diff --git a/gramps/gen/lib/secondaryobj.py b/gramps/gen/lib/secondaryobj.py index 4222f60ec..bc34bba47 100644 --- a/gramps/gen/lib/secondaryobj.py +++ b/gramps/gen/lib/secondaryobj.py @@ -69,27 +69,3 @@ class SecondaryObject(BaseObject): Should be overwritten by objects that inherit from this class. """ pass - - @classmethod - def get_labels(cls, _): - """ - Return labels. - """ - return {} - - def get_label(self, field, _): - """ - Get the associated label given a field name of this object. - """ - chain = field.split(".") - path = self - for part in chain[:-1]: - if hasattr(path, part): - path = getattr(path, part) - else: - path = path[int(part)] - labels = path.get_labels(_) - if chain[-1] in labels: - return labels[chain[-1]] - else: - raise Exception("%s has no such label: '%s'" % (self, field)) diff --git a/gramps/gen/lib/src.py b/gramps/gen/lib/src.py index 193a69ce9..49b2e315a 100644 --- a/gramps/gen/lib/src.py +++ b/gramps/gen/lib/src.py @@ -39,6 +39,8 @@ from .attrbase import SrcAttributeBase from .reporef import RepoRef from .const import DIFFERENT, EQUAL, IDENTICAL from .citationbase import IndirectCitationBase +from ..const import GRAMPS_LOCALE as glocale +_ = glocale.translation.gettext #------------------------------------------------------------------------- # @@ -79,24 +81,6 @@ class Source(MediaBase, NoteBase, SrcAttributeBase, IndirectCitationBase, TagBase.serialize(self), # 11 self.private) # 12 - @classmethod - def get_labels(cls, _): - return { - "handle": _("Handle"), - "gramps_id": _("Gramps ID"), - "title": _("Title"), - "author": _("Author"), - "pubinfo": _("Publication info"), - "note_list": _("Notes"), - "media_list": _("Media"), - "abbrev": _("Abbreviation"), - "change": _("Last changed"), - "srcattr_list": _("Source Attributes"), - "reporef_list": _("Repositories"), - "tag_list": _("Tags"), - "private": _("Private") - } - @classmethod def get_schema(cls): """ @@ -110,29 +94,43 @@ class Source(MediaBase, NoteBase, SrcAttributeBase, IndirectCitationBase, from .mediaref import MediaRef return { "type": "object", + "title": _("Source"), "properties": { "_class": {"enum": [cls.__name__]}, "handle": {"type": "string", - "maxLength": 50}, - "gramps_id": {"type": "string"}, - "title": {"type": "string"}, - "author": {"type": "string"}, - "pubinfo": {"type": "string"}, + "maxLength": 50, + "title": _("Handle")}, + "gramps_id": {"type": "string", + "title": _("Gramps ID")}, + "title": {"type": "string", + "title": _("Title")}, + "author": {"type": "string", + "title": _("Author")}, + "pubinfo": {"type": "string", + "title": _("Publication info")}, "note_list": {"type": "array", "items": {"type": "string", - "maxLength": 50}}, + "maxLength": 50}, + "title": _("Notes")}, "media_list": {"type": "array", - "items": MediaRef.get_schema()}, - "abbrev": {"type": "string"}, - "change": {"type": "integer"}, + "items": MediaRef.get_schema(), + "title": _("Media")}, + "abbrev": {"type": "string", + "title": _("Abbreviation")}, + "change": {"type": "integer", + "title": _("Last changed")}, "srcattr_list": {"type": "array", - "items": SrcAttribute.get_schema()}, + "items": SrcAttribute.get_schema(), + "title": _("Source Attributes")}, "reporef_list": {"type": "array", - "items": RepoRef.get_schema()}, + "items": RepoRef.get_schema(), + "title": _("Repositories")}, "tag_list": {"type": "array", "items": {"type": "string", - "maxLength": 50}}, - "private": {"type": "boolean"} + "maxLength": 50}, + "title": _("Tags")}, + "private": {"type": "boolean", + "title": _("Private")} } } diff --git a/gramps/gen/lib/styledtext.py b/gramps/gen/lib/styledtext.py index 5d57611a4..2fa6b06c6 100644 --- a/gramps/gen/lib/styledtext.py +++ b/gramps/gen/lib/styledtext.py @@ -28,6 +28,8 @@ # #------------------------------------------------------------------------- from .styledtexttag import StyledTextTag +from ..const import GRAMPS_LOCALE as glocale +_ = glocale.translation.gettext #------------------------------------------------------------------------- # @@ -299,21 +301,17 @@ class StyledText: """ return { "type": "object", + "title": _("Styled Text"), "properties": { "_class": {"enum": [cls.__name__]}, - "string": {"type": "string"}, + "string": {"type": "string", + "title": _("Text")}, "tags": {"type": "array", - "items": StyledTextTag.get_schema()} + "items": StyledTextTag.get_schema(), + "title": _("Styled Text Tags")} } } - @classmethod - def get_labels(cls, _): - return { - "string": _("Text"), - "tags": _("Styled Text Tags"), - } - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/surname.py b/gramps/gen/lib/surname.py index fe7c99592..ad45dff70 100644 --- a/gramps/gen/lib/surname.py +++ b/gramps/gen/lib/surname.py @@ -32,6 +32,8 @@ Surname class for Gramps. from .secondaryobj import SecondaryObject from .nameorigintype import NameOriginType from .const import IDENTICAL, EQUAL, DIFFERENT +from ..const import GRAMPS_LOCALE as glocale +_ = glocale.translation.gettext #------------------------------------------------------------------------- # @@ -82,27 +84,21 @@ class Surname(SecondaryObject): """ return { "type": "object", + "title": _("Surname"), "properties": { "_class": {"enum": [cls.__name__]}, - "surname": {"type": "string"}, - "prefix": {"type": "string"}, - "primary": {"type": "boolean"}, + "surname": {"type": "string", + "title": _("Surname")}, + "prefix": {"type": "string", + "title": _("Prefix")}, + "primary": {"type": "boolean", + "title": _("Primary")}, "origintype": NameOriginType.get_schema(), - "connector": {"type": "string"} + "connector": {"type": "string", + "title": _("Connector")} } } - @classmethod - def get_labels(cls, _): - return { - "_class": _("Surname"), - "surname": _("Surname"), - "prefix": _("Prefix"), - "primary": _("Primary"), - "origintype": _("Origin type"), - "connector": _("Connector") - } - def is_empty(self): """ Indicate if the surname is empty. diff --git a/gramps/gen/lib/tableobj.py b/gramps/gen/lib/tableobj.py index 7927ff00d..373bfb9d0 100644 --- a/gramps/gen/lib/tableobj.py +++ b/gramps/gen/lib/tableobj.py @@ -148,13 +148,6 @@ class TableObject(BaseObject): """ return self.handle - @classmethod - def get_labels(cls, _): - """ - Return labels. - """ - return {} - @classmethod def get_schema(cls): """ diff --git a/gramps/gen/lib/tag.py b/gramps/gen/lib/tag.py index af3c8228f..3f00b3c37 100644 --- a/gramps/gen/lib/tag.py +++ b/gramps/gen/lib/tag.py @@ -29,6 +29,8 @@ Tag object for Gramps. # #------------------------------------------------------------------------- from .tableobj import TableObject +from ..const import GRAMPS_LOCALE as glocale +_ = glocale.translation.gettext #------------------------------------------------------------------------- # @@ -110,32 +112,25 @@ class Tag(TableObject): """ return { "type": "object", + "title": _("Tag"), "properties": { "_class": {"enum": [cls.__name__]}, "handle": {"type": "string", - "maxLength": 50}, - "name": {"type": "string"}, + "maxLength": 50, + "title": _("Handle")}, + "name": {"type": "string", + "title": _("Name")}, "color": {"type": "string", - "maxLength": 13}, + "maxLength": 13, + "title": _("Color")}, "priority": {"type": "integer", - "minimum": 0}, - "change": {"type": "integer"} + "minimum": 0, + "title": _("Priority")}, + "change": {"type": "integer", + "title": _("Last changed")} } } - @classmethod - def get_labels(cls, _): - """ - Return the label for fields - """ - return { - "handle": _("Handle"), - "name": _("Name"), - "color": _("Color"), - "priority": _("Priority"), - "change": _("Last changed"), - } - def get_text_data_list(self): """ Return the list of all textual attributes of the object.