/usr/share/pyshared/quodlibet/util/i18n.py is in exfalso 2.4-1.
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 | # 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
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, *args, **kwargs):
self._catalog = {}
self.plural = lambda n: n != 1
gettext.GNUTranslations.__init__(self, *args, **kwargs)
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):
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
__builtin__.__dict__["_"] = _
__builtin__.__dict__["Q_"] = _Q
__builtin__.__dict__["N_"] = _N
__builtin__.__dict__["ngettext"] = ngettext
|