2005-12-06 12:08:09 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2006-03-17 01:54:27 +05:30
|
|
|
# Copyright (C) 2000-2006 Donald N. Allingham
|
2005-12-06 12:08:09 +05:30
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
# $Id:TransUtils.py 9912 2008-01-22 09:17:46Z acraphae $
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2007-09-10 08:33:46 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Provide translation assistance
|
2007-09-10 08:33:46 +05:30
|
|
|
"""
|
|
|
|
|
2006-03-17 01:54:27 +05:30
|
|
|
from gettext import gettext
|
|
|
|
|
2007-09-10 08:33:46 +05:30
|
|
|
def sgettext(msgid, sep='|'):
|
2005-12-06 12:08:09 +05:30
|
|
|
"""
|
|
|
|
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
|
|
|
|
|
|
|
|
"""
|
2006-03-17 01:54:27 +05:30
|
|
|
msgval = gettext(msgid)
|
|
|
|
if msgval == msgid:
|
|
|
|
sep_idx = msgid.rfind(sep)
|
2005-12-06 12:08:09 +05:30
|
|
|
msgval = msgid[sep_idx+1:]
|
|
|
|
return msgval
|