def _(x): if x == '': # Workaround for gettext's behaviour on empty strings return '' result = gettext.lgettext(x) if isinstance(result, bytes): return result.decode(sys.getdefaultencoding()) else: return result
import os import six def _find_locale_files(): module_path = os.path.abspath(__file__) locale_path = os.path.join(os.path.dirname(module_path), 'locale') gettext.bindtextdomain("pykickstart", locale_path) gettext.textdomain("pykickstart") if six.PY3: import sys _find_locale_files() def _(x): if x == '': # Workaround for gettext's behaviour on empty strings return '' result = gettext.lgettext(x) if isinstance(result, bytes): return result.decode(sys.getdefaultencoding()) else: return result else: _find_locale_files() _ = lambda x: gettext.lgettext(x) if x != '' else ''
import ethtool PROGNAME = "system-config-network" log = LogFile(PROGNAME) try: locale.setlocale(locale.LC_ALL, "") except locale.Error, e: import os os.environ['LC_ALL'] = 'C' locale.setlocale(locale.LC_ALL, "") gettext.bind_textdomain_codeset(PROGNAME, locale.nl_langinfo(locale.CODESET)) gettext.bindtextdomain(PROGNAME, '/usr/share/locale') gettext.textdomain(PROGNAME) _ = lambda x: gettext.lgettext(x) __builtin__.__dict__['_'] = _ _kernel_version = None def kernel_version(): global _kernel_version if not _kernel_version: (sysname, nodename, release, version, machine) = os.uname() # pylint: disable-msg=W0612 if release.find("-") != -1: (ver, rel) = release.split("-", 1) # pylint: disable-msg=W0612 else: ver = release _kernel_version = ver.split(".", 4)
import getopt import shutil from yum import _, YumBase from yum.callbacks import DownloadBaseCallback # everything was ok RETURN_OK = 0 # serious problem, should be logged somewhere RETURN_FAILURE = 2 GETTEXT_PROGNAME = "abrt" import locale import gettext _ = lambda x: gettext.lgettext(x) def init_gettext(): try: locale.setlocale(locale.LC_ALL, "") except locale.Error: os.environ['LC_ALL'] = 'C' locale.setlocale(locale.LC_ALL, "") gettext.bind_textdomain_codeset(GETTEXT_PROGNAME, locale.nl_langinfo(locale.CODESET)) gettext.bindtextdomain(GETTEXT_PROGNAME, '/usr/share/locale') gettext.textdomain(GETTEXT_PROGNAME) verbose = 0 def log(fmt, *args): sys.stderr.write("%s\n" % (fmt % args))
# import gettext import os import six def _find_locale_files(): module_path = os.path.abspath(__file__) locale_path = os.path.join(os.path.dirname(module_path), 'locale') gettext.bindtextdomain("pykickstart", locale_path) gettext.textdomain("pykickstart") if six.PY3: import sys _find_locale_files() def _(x): if x == '': # Workaround for gettext's behaviour on empty strings return '' result = gettext.lgettext(x) if isinstance(result, bytes): return result.decode(sys.getdefaultencoding()) else: return result else: _find_locale_files() _ = lambda x: gettext.lgettext(x) if x else ''
import gettext x1 = gettext.gettext("gettext") x2 = gettext.lgettext("lgettext") m1 = gettext.gettext("""multi line string""") Z = 'Z' x5 = gettext.gettext(Z) # Ignored, must be string constants
def update_event(self, inp=-1): self.set_output_val(0, gettext.lgettext(self.input(0)))
# import gettext import os import six def _find_locale_files(): module_path = os.path.abspath(__file__) locale_path = os.path.join(os.path.dirname(module_path), 'locale') gettext.bindtextdomain("pykickstart", locale_path) gettext.textdomain("pykickstart") if six.PY3: import sys _find_locale_files() def _(x): if x == '': # Workaround for gettext's behaviour on empty strings return '' result = gettext.lgettext(x) if isinstance(result, bytes): return result.decode(sys.getdefaultencoding()) else: return result else: _find_locale_files() _ = lambda x: gettext.lgettext(x) if x != '' else ''