/usr/share/pyshared/quodlibet/util/i18n.py is in exfalso 3.0.2-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | # Copyright 2006 Joe Wreschnig
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation
import __builtin__
import gettext
import os
class GlibTranslations(gettext.GNUTranslations):
"""Provide a glib-like translation API for Python.
This class adds support for qgettext (and uqgettext) mirroring
glib's Q_ macro, which allows for disambiguation of identical
source strings. It also installs N_, Q_, and ngettext into the
__builtin__ namespace.
It can also be instantiated and used with any valid MO files
(though it won't be able to translate anything, of course).
"""
def __init__(self, fp=None):
self.path = (fp and fp.name) or ""
self._catalog = {}
self.plural = lambda n: n != 1
gettext.GNUTranslations.__init__(self, fp)
def qgettext(self, msgid):
msgstr = self.gettext(msgid)
if msgstr == msgid:
try:
return msgstr.split("|", 1)[1]
except IndexError:
return msgstr
else:
return msgstr
def uqgettext(self, msgid):
msgstr = self.ugettext(msgid)
if msgstr == msgid:
try:
return msgstr.split(u"|", 1)[1]
except IndexError:
return msgstr
else:
return msgstr
def install(self, unicode=False):
# set by tests
if "QUODLIBET_NO_TRANS" in os.environ:
return
if unicode:
_ = self.ugettext
_Q = self.uqgettext
ngettext = self.ungettext
_N = unicode
else:
_ = self.gettext
_Q = self.qgettext
ngettext = self.ngettext
_N = lambda s: s
test_key = "QUODLIBET_TEST_TRANS"
if test_key in os.environ:
text = os.environ[test_key]
def wrap(f):
def g(*args):
return text + f(*args) + text
return g
_ = wrap(_)
_Q = wrap(_Q)
_N = wrap(_N)
ngettext = wrap(ngettext)
__builtin__.__dict__["_"] = _
__builtin__.__dict__["Q_"] = _Q
__builtin__.__dict__["N_"] = _N
__builtin__.__dict__["ngettext"] = ngettext
|