mercurial/i18n.py
changeset 43077 687b865b95ad
parent 43076 2372284d9457
child 43089 c59eb1560c44
equal deleted inserted replaced
43076:2372284d9457 43077:687b865b95ad
    24     module = pycompat.fsencode(__file__)
    24     module = pycompat.fsencode(__file__)
    25 
    25 
    26 _languages = None
    26 _languages = None
    27 if (
    27 if (
    28     pycompat.iswindows
    28     pycompat.iswindows
    29     and 'LANGUAGE' not in encoding.environ
    29     and b'LANGUAGE' not in encoding.environ
    30     and 'LC_ALL' not in encoding.environ
    30     and b'LC_ALL' not in encoding.environ
    31     and 'LC_MESSAGES' not in encoding.environ
    31     and b'LC_MESSAGES' not in encoding.environ
    32     and 'LANG' not in encoding.environ
    32     and b'LANG' not in encoding.environ
    33 ):
    33 ):
    34     # Try to detect UI language by "User Interface Language Management" API
    34     # Try to detect UI language by "User Interface Language Management" API
    35     # if no locale variables are set. Note that locale.getdefaultlocale()
    35     # if no locale variables are set. Note that locale.getdefaultlocale()
    36     # uses GetLocaleInfo(), which may be different from UI language.
    36     # uses GetLocaleInfo(), which may be different from UI language.
    37     # (See http://msdn.microsoft.com/en-us/library/dd374098(v=VS.85).aspx )
    37     # (See http://msdn.microsoft.com/en-us/library/dd374098(v=VS.85).aspx )
    81             # goofy unicode docstrings in test
    81             # goofy unicode docstrings in test
    82             paragraphs = message.split(u'\n\n')
    82             paragraphs = message.split(u'\n\n')
    83         else:
    83         else:
    84             # should be ascii, but we have unicode docstrings in test, which
    84             # should be ascii, but we have unicode docstrings in test, which
    85             # are converted to utf-8 bytes on Python 3.
    85             # are converted to utf-8 bytes on Python 3.
    86             paragraphs = [p.decode("utf-8") for p in message.split('\n\n')]
    86             paragraphs = [p.decode("utf-8") for p in message.split(b'\n\n')]
    87         # Be careful not to translate the empty string -- it holds the
    87         # Be careful not to translate the empty string -- it holds the
    88         # meta data of the .po file.
    88         # meta data of the .po file.
    89         u = u'\n\n'.join([p and _ugettext(p) or u'' for p in paragraphs])
    89         u = u'\n\n'.join([p and _ugettext(p) or u'' for p in paragraphs])
    90         try:
    90         try:
    91             # encoding.tolocal cannot be used since it will first try to
    91             # encoding.tolocal cannot be used since it will first try to
   101     return cache[message]
   101     return cache[message]
   102 
   102 
   103 
   103 
   104 def _plain():
   104 def _plain():
   105     if (
   105     if (
   106         'HGPLAIN' not in encoding.environ
   106         b'HGPLAIN' not in encoding.environ
   107         and 'HGPLAINEXCEPT' not in encoding.environ
   107         and b'HGPLAINEXCEPT' not in encoding.environ
   108     ):
   108     ):
   109         return False
   109         return False
   110     exceptions = encoding.environ.get('HGPLAINEXCEPT', '').strip().split(',')
   110     exceptions = encoding.environ.get(b'HGPLAINEXCEPT', b'').strip().split(b',')
   111     return 'i18n' not in exceptions
   111     return b'i18n' not in exceptions
   112 
   112 
   113 
   113 
   114 if _plain():
   114 if _plain():
   115     _ = lambda message: message
   115     _ = lambda message: message
   116 else:
   116 else: