From 612b893956d184b3a9306b797180b12f122fa9fd Mon Sep 17 00:00:00 2001 From: Paul Franklin Date: Tue, 7 May 2013 18:59:43 +0000 Subject: [PATCH] better PEP-0008 (trans_text_ ==> trans_text) PEP-0008 reserves the use of a trailing underscore for names which conflict with Python keywords, which this doesn't. The goal is to have a permanent name which is unique across the gramps namespace, since it is defined (in po/genpot.sh and po/update_po.py) as a keyword to flag strings to be put into the translation "catalog" file (gramps.pot). The new keyword "trans_text" is still unique. (Also "_T_".) svn: r22201 --- gramps/gen/lib/eventtype.py | 6 +++--- gramps/gen/plug/report/endnotes.py | 8 ++++---- gramps/plugins/textreport/detancestralreport.py | 2 +- gramps/plugins/textreport/detdescendantreport.py | 2 +- gramps/plugins/textreport/indivcomplete.py | 2 +- po/genpot.sh | 2 +- po/update_po.py | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/gramps/gen/lib/eventtype.py b/gramps/gen/lib/eventtype.py index f776807b2..0865d3158 100644 --- a/gramps/gen/lib/eventtype.py +++ b/gramps/gen/lib/eventtype.py @@ -333,18 +333,18 @@ class EventType(GrampsType): return self.value == event_type[0][0] # first one, the code return False - def get_abbreviation(self, trans_text_=glocale.translation.sgettext): + def get_abbreviation(self, trans_text=glocale.translation.sgettext): """ Returns the abbreviation for this event. Uses the explicitly given abbreviations, or first letter of each word, or the first three letters. Appends a period after the abbreviation, but not if string is in _ABBREVIATIONS. - If trans_text_ is passed in (a glocale.translation.sgettext) + If trans_text is passed in (a GrampsLocale sgettext instance) then the translated abbreviation will be returned instead. """ if self.value in self._ABBREVIATIONS: - return trans_text_(self._ABBREVIATIONS[self.value]) + return trans_text(self._ABBREVIATIONS[self.value]) else: abbrev = cuni(self) if " " in abbrev: diff --git a/gramps/gen/plug/report/endnotes.py b/gramps/gen/plug/report/endnotes.py index 079ec6e01..4bbf93979 100644 --- a/gramps/gen/plug/report/endnotes.py +++ b/gramps/gen/plug/report/endnotes.py @@ -103,7 +103,7 @@ def cite_source(bibliography, database, obj): return txt def write_endnotes(bibliography, database, doc, printnotes=False, links=False, - trans_text_=glocale.translation.gettext): + trans_text=glocale.translation.gettext): """ Write all the entries in the bibliography as endnotes. @@ -118,14 +118,14 @@ def write_endnotes(bibliography, database, doc, printnotes=False, links=False, @type printnotes: bool @param links: Indicate if URL links should be makde 'clickable'. @type links: bool - @param trans_text_: allow deferred translation of "Endnotes" Endnotes-Header - @type trans_text_: a glocale.translation.gettext + @param trans_text: allow deferred translation of "Endnotes" Endnotes-Header + @type trans_text: a GrampsLocale gettext instance """ if bibliography.get_citation_count() == 0: return doc.start_paragraph('Endnotes-Header') - doc.write_text(trans_text_('Endnotes')) + doc.write_text(trans_text('Endnotes')) doc.end_paragraph() cindex = 0 diff --git a/gramps/plugins/textreport/detancestralreport.py b/gramps/plugins/textreport/detancestralreport.py index f254346a2..82f94c262 100644 --- a/gramps/plugins/textreport/detancestralreport.py +++ b/gramps/plugins/textreport/detancestralreport.py @@ -231,7 +231,7 @@ class DetAncestorReport(Report): # it ignores language set for Note type (use locale) endnotes.write_endnotes(self.bibli, self.database, self.doc, printnotes=self.inc_srcnotes, - trans_text_=self._) + trans_text=self._) def write_person(self, key): """Output birth, death, parentage, marriage and notes information """ diff --git a/gramps/plugins/textreport/detdescendantreport.py b/gramps/plugins/textreport/detdescendantreport.py index a8e280490..cf23b30c8 100644 --- a/gramps/plugins/textreport/detdescendantreport.py +++ b/gramps/plugins/textreport/detdescendantreport.py @@ -311,7 +311,7 @@ class DetDescendantReport(Report): # it ignores language set for Note type (use locale) endnotes.write_endnotes(self.bibli, self.database, self.doc, printnotes=self.inc_srcnotes, - trans_text_=self._) + trans_text=self._) def write_path(self, person): path = [] diff --git a/gramps/plugins/textreport/indivcomplete.py b/gramps/plugins/textreport/indivcomplete.py index 3b15ffa2f..5dfd7b50d 100644 --- a/gramps/plugins/textreport/indivcomplete.py +++ b/gramps/plugins/textreport/indivcomplete.py @@ -671,7 +671,7 @@ class IndivCompleteReport(Report): self.doc.page_break() Endnotes.write_endnotes(self.bibli, self.database, self.doc, printnotes=self.use_srcs_notes, - trans_text_=self._) + trans_text=self._) #------------------------------------------------------------------------ # diff --git a/po/genpot.sh b/po/genpot.sh index 9e074eff1..d6930cbff 100755 --- a/po/genpot.sh +++ b/po/genpot.sh @@ -4,5 +4,5 @@ # Make translation files # additional keywords must always be kept in sync with those in update_po.py -XGETTEXT_ARGS='--keyword=_T_ --keyword=trans_text_' \ +XGETTEXT_ARGS='--keyword=_T_ --keyword=trans_text' \ intltool-update -g gramps -o gramps.pot -p diff --git a/po/update_po.py b/po/update_po.py index 84fc500f5..61307befd 100644 --- a/po/update_po.py +++ b/po/update_po.py @@ -582,7 +582,7 @@ def retrieve(): os.system('''%(xgettext)s -j --directory=./ -d gramps ''' '''-L Python -o gramps.pot --files-from=python.txt ''' '''--keyword=_ --keyword=ngettext ''' - '''--keyword=_T_ --keyword=trans_text_ ''' + '''--keyword=_T_ --keyword=trans_text ''' '''--keyword=sgettext --from-code=UTF-8''' % {'xgettext': xgettextCmd} )