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
This commit is contained in:
Paul Franklin 2013-05-07 18:59:43 +00:00
parent 6930887aa1
commit 612b893956
7 changed files with 12 additions and 12 deletions

View File

@ -333,18 +333,18 @@ class EventType(GrampsType):
return self.value == event_type[0][0] # first one, the code return self.value == event_type[0][0] # first one, the code
return False 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 Returns the abbreviation for this event. Uses the explicitly
given abbreviations, or first letter of each word, or the first given abbreviations, or first letter of each word, or the first
three letters. Appends a period after the abbreviation, three letters. Appends a period after the abbreviation,
but not if string is in _ABBREVIATIONS. 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. then the translated abbreviation will be returned instead.
""" """
if self.value in self._ABBREVIATIONS: if self.value in self._ABBREVIATIONS:
return trans_text_(self._ABBREVIATIONS[self.value]) return trans_text(self._ABBREVIATIONS[self.value])
else: else:
abbrev = cuni(self) abbrev = cuni(self)
if " " in abbrev: if " " in abbrev:

View File

@ -103,7 +103,7 @@ def cite_source(bibliography, database, obj):
return txt return txt
def write_endnotes(bibliography, database, doc, printnotes=False, links=False, 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. 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 @type printnotes: bool
@param links: Indicate if URL links should be makde 'clickable'. @param links: Indicate if URL links should be makde 'clickable'.
@type links: bool @type links: bool
@param trans_text_: allow deferred translation of "Endnotes" Endnotes-Header @param trans_text: allow deferred translation of "Endnotes" Endnotes-Header
@type trans_text_: a glocale.translation.gettext @type trans_text: a GrampsLocale gettext instance
""" """
if bibliography.get_citation_count() == 0: if bibliography.get_citation_count() == 0:
return return
doc.start_paragraph('Endnotes-Header') doc.start_paragraph('Endnotes-Header')
doc.write_text(trans_text_('Endnotes')) doc.write_text(trans_text('Endnotes'))
doc.end_paragraph() doc.end_paragraph()
cindex = 0 cindex = 0

View File

@ -231,7 +231,7 @@ class DetAncestorReport(Report):
# it ignores language set for Note type (use locale) # it ignores language set for Note type (use locale)
endnotes.write_endnotes(self.bibli, self.database, self.doc, endnotes.write_endnotes(self.bibli, self.database, self.doc,
printnotes=self.inc_srcnotes, printnotes=self.inc_srcnotes,
trans_text_=self._) trans_text=self._)
def write_person(self, key): def write_person(self, key):
"""Output birth, death, parentage, marriage and notes information """ """Output birth, death, parentage, marriage and notes information """

View File

@ -311,7 +311,7 @@ class DetDescendantReport(Report):
# it ignores language set for Note type (use locale) # it ignores language set for Note type (use locale)
endnotes.write_endnotes(self.bibli, self.database, self.doc, endnotes.write_endnotes(self.bibli, self.database, self.doc,
printnotes=self.inc_srcnotes, printnotes=self.inc_srcnotes,
trans_text_=self._) trans_text=self._)
def write_path(self, person): def write_path(self, person):
path = [] path = []

View File

@ -671,7 +671,7 @@ class IndivCompleteReport(Report):
self.doc.page_break() self.doc.page_break()
Endnotes.write_endnotes(self.bibli, self.database, self.doc, Endnotes.write_endnotes(self.bibli, self.database, self.doc,
printnotes=self.use_srcs_notes, printnotes=self.use_srcs_notes,
trans_text_=self._) trans_text=self._)
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #

View File

@ -4,5 +4,5 @@
# Make translation files # Make translation files
# additional keywords must always be kept in sync with those in update_po.py # 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 intltool-update -g gramps -o gramps.pot -p

View File

@ -582,7 +582,7 @@ def retrieve():
os.system('''%(xgettext)s -j --directory=./ -d gramps ''' os.system('''%(xgettext)s -j --directory=./ -d gramps '''
'''-L Python -o gramps.pot --files-from=python.txt ''' '''-L Python -o gramps.pot --files-from=python.txt '''
'''--keyword=_ --keyword=ngettext ''' '''--keyword=_ --keyword=ngettext '''
'''--keyword=_T_ --keyword=trans_text_ ''' '''--keyword=_T_ --keyword=trans_text '''
'''--keyword=sgettext --from-code=UTF-8''' % {'xgettext': xgettextCmd} '''--keyword=sgettext --from-code=UTF-8''' % {'xgettext': xgettextCmd}
) )