* src/Utils.py (strip_context): Add function.
svn: r4795
This commit is contained in:
parent
cf7ed2c8f9
commit
e47701ab02
@ -4,6 +4,7 @@
|
||||
|
||||
2005-06-05 Alex Roitman <shura@gramps-project.org>
|
||||
* configure.in: Bump up the version number.
|
||||
* src/Utils.py (strip_context): Add function.
|
||||
|
||||
2005-06-05 Don Allingham <don@gramps-project.org>
|
||||
* src/DateHandler.py: fixed initialization of parser class
|
||||
|
@ -27,6 +27,7 @@
|
||||
#-------------------------------------------------------------------------
|
||||
import os
|
||||
import locale
|
||||
from gettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -52,13 +53,6 @@ import GrampsMime
|
||||
import NameDisplay
|
||||
import Date
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# internationalization
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# modified flag
|
||||
@ -400,7 +394,7 @@ def search_for(name):
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Change label apperance
|
||||
# Change label appearance
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def bold_label(label,widget=None):
|
||||
@ -793,3 +787,26 @@ def get_type_converter_by_name(val_str):
|
||||
elif val_str in ('str','unicode'):
|
||||
return unicode
|
||||
return unicode
|
||||
|
||||
def strip_context(msgid,sep='|'):
|
||||
"""
|
||||
Strip the context used for resolving translation ambiguities.
|
||||
|
||||
The translation of msgid is returned unless the translation is
|
||||
not available and the msgid contains the separator. In that case,
|
||||
the returned value is the portion of msgid following the last
|
||||
separator. Default separator is '|'.
|
||||
|
||||
@param msgid: The string to translated.
|
||||
@type msgid: unicode
|
||||
@param sep: The separator marking the context.
|
||||
@type sep: unicode
|
||||
@return: Translation or the original with context stripped.
|
||||
@rtype: unicode
|
||||
|
||||
"""
|
||||
msgval = _(msgid)
|
||||
sep_idx = msgid.rfind(sep)
|
||||
if msgval == msgid and sep_idx != -1:
|
||||
msgval = msgid[sep_idx+1:]
|
||||
return msgval
|
||||
|
Loading…
Reference in New Issue
Block a user