/usr/lib/python3/dist-packages/udiskie/locale.py is in udiskie 1.7.3-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 | """
I18n utilities.
"""
from __future__ import absolute_import
from __future__ import unicode_literals
import gettext
__all__ = ['_']
class Translator(object):
"""
Simple translation and message formatting utility.
"""
@classmethod
def create(cls, domain, localedir=None, languages=None):
"""
Create a new translator for the given domain.
Arguments are as in ``gettext.translation``.
"""
t = gettext.translation(domain, localedir, languages, fallback=True)
try:
# on python2 we want the unicode version:
g = t.ugettext
except AttributeError:
# which is the default in python3:
g = t.gettext
return cls(g)
def __init__(self, gettext):
"""Initialize a translator with the given gettext function."""
self._gettext = gettext
def __call__(self, text, *args, **kwargs):
"""Translate and then and format the text with ``str.format``."""
msg = self._gettext(text)
if args or kwargs:
return msg.format(*args, **kwargs)
else:
return msg
_ = Translator.create('udiskie')
|