changeset 179ca9915658 in /home/hg/repos/gajim
details:http://hg.gajim.org/gajim?cmd=changeset;node=179ca9915658
description: Refactored the Q_ translation function
diffstat:
src/common/i18n.py | 33 +++++++++++++++++++--------------
1 files changed, 19 insertions(+), 14 deletions(-)
diffs (43 lines):
diff -r 5724fd1f28bd -r 179ca9915658 src/common/i18n.py
--- a/src/common/i18n.py Tue Apr 06 18:05:06 2010 +0000
+++ b/src/common/i18n.py Wed Apr 07 04:09:58 2010 +0300
@@ -67,20 +67,25 @@
else:
_translation = gettext.NullTranslations()
-def Q_(s):
- # Qualified translatable strings
- # Some strings are too ambiguous to be easily translated.
- # so we must use as:
- # s = Q_('?vcard:Unknown')
- # widget.set_text(s)
- # Q_() removes the ?vcard:
- # but gettext while parsing the file detects ?vcard:Unknown as a whole string.
- # translator can either put the ?vcard: part or no (easier for him or her to no)
- # nothing fails
- s = _(s)
- if s[0] == '?':
- s = s[s.find(':')+1:] # remove ?abc: part
- return s
+def Q_(text):
+ """
+ Translate the given text, optionally qualified with a special
+ construction, which will help translators to disambiguate between
+ same terms, but in different contexts.
+
+ When translated text is returned - this rudimentary construction
+ will be stripped off, if it's present.
+
+ Here is the construction to use:
+ Q_("?vcard:Unknown")
+
+ Everything between ? and : - is the qualifier to convey the context
+ to the translators. Everything after : - is the text itself.
+ """
+ text = _(text)
+ if text.startswith('?'):
+ qualifier, text = text.split(':', 1)
+ return text
def ngettext(s_sing, s_plural, n, replace_sing = None, replace_plural = None):
"""