Mercurial > public > mercurial-scm > hg
diff mercurial/i18n.py @ 43076:2372284d9457
formatting: blacken the codebase
This is using my patch to black
(https://github.com/psf/black/pull/826) so we don't un-wrap collection
literals.
Done with:
hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**"' | xargs black -S
# skip-blame mass-reformatting only
# no-check-commit reformats foo_bar functions
Differential Revision: https://phab.mercurial-scm.org/D6971
author | Augie Fackler <augie@google.com> |
---|---|
date | Sun, 06 Oct 2019 09:45:02 -0400 |
parents | dd83aafdb64a |
children | 687b865b95ad |
line wrap: on
line diff
--- a/mercurial/i18n.py Sat Oct 05 10:29:34 2019 -0400 +++ b/mercurial/i18n.py Sun Oct 06 09:45:02 2019 -0400 @@ -24,17 +24,20 @@ module = pycompat.fsencode(__file__) _languages = None -if (pycompat.iswindows +if ( + pycompat.iswindows and 'LANGUAGE' not in encoding.environ and 'LC_ALL' not in encoding.environ and 'LC_MESSAGES' not in encoding.environ - and 'LANG' not in encoding.environ): + and 'LANG' not in encoding.environ +): # Try to detect UI language by "User Interface Language Management" API # if no locale variables are set. Note that locale.getdefaultlocale() # uses GetLocaleInfo(), which may be different from UI language. # (See http://msdn.microsoft.com/en-us/library/dd374098(v=VS.85).aspx ) try: import ctypes + langid = ctypes.windll.kernel32.GetUserDefaultUILanguage() _languages = [locale.windows_locale[langid]] except (ImportError, AttributeError, KeyError): @@ -43,6 +46,7 @@ _ugettext = None + def setdatapath(datapath): datapath = pycompat.fsdecode(datapath) localedir = os.path.join(datapath, r'locale') @@ -53,8 +57,10 @@ except AttributeError: _ugettext = t.gettext + _msgcache = {} # encoding: {message: translation} + def gettext(message): """Translate message. @@ -94,13 +100,17 @@ cache[message] = message return cache[message] + def _plain(): - if ('HGPLAIN' not in encoding.environ - and 'HGPLAINEXCEPT' not in encoding.environ): + if ( + 'HGPLAIN' not in encoding.environ + and 'HGPLAINEXCEPT' not in encoding.environ + ): return False exceptions = encoding.environ.get('HGPLAINEXCEPT', '').strip().split(',') return 'i18n' not in exceptions + if _plain(): _ = lambda message: message else: