Commit Graph

25 Commits

Author SHA1 Message Date
timeless
0269e5f4a8 py3: handle ugettext + unicode in i18n 2016-03-29 17:22:08 +00:00
Gregory Szorc
2ca65f3329 i18n: use absolute_import 2015-08-08 19:28:49 -07:00
Augie Fackler
69caabb3af i18n: cache the result of every gettext call
In looking at profiler output for 'hg log' on mozilla-central, I
noticed we spent a _huge_ amount of time in gettext relative to what
it's doing. Caching provides a roughly 15% performance improvement
even on repositories as small as hg.

== hg repo on linux ==

Before:
  %   cumulative      self
 time    seconds   seconds  name
  5.05      0.19      0.19  i18n.py:62:gettext
  4.84      0.18      0.18  revlog.py:88:decompress
  2.95      0.17      0.11  changelog.py:201:node
  2.32      0.09      0.09  ui.py:577:write
  2.11      0.08      0.08  i18n.py:72:gettext
  2.11      0.08      0.08  obsolete.py:196:_fm0readmarkers
  1.89      0.07      0.07  obsolete.py:569:_load
  1.68      0.63      0.06  localrepo.py:29:__get__

real	0m4.026s
user	0m3.993s
sys	0m0.034s

After:
  %   cumulative      self
 time    seconds   seconds  name
  8.05      0.26      0.26  revlog.py:88:decompress
  2.68      0.22      0.09  color.py:395:write
  2.20      0.07      0.07  obsolete.py:196:_fm0readmarkers
  1.95      0.06      0.06  obsolete.py:174:_fm0readmarkers
  1.95      0.06      0.06  ui.py:577:write
  1.95      0.06      0.06  util.py:1228:datestr
  1.71      0.06      0.06  utf_8.py:16:decode
  1.71      0.06      0.06  revlog.py:273:__len__

real	0m3.519s
user	0m3.447s
sys	0m0.073s


== mozilla-central repo on linux ==
Before:
  %   cumulative      self
 time    seconds   seconds  name
  7.72      2.35      2.35  revlog.py:88:decompress
  4.46      1.36      1.36  i18n.py:62:gettext
  2.22      0.67      0.67  i18n.py:72:gettext
  2.19      1.14      0.67  changelog.py:201:node
  2.16      0.66      0.66  ui.py:577:write
  1.96      0.60      0.60  utf_8.py:16:decode
  1.93      1.97      0.59  color.py:395:write
  1.85      0.81      0.56  changelog.py:136:tip

real	0m30.822s
user	0m30.660s
sys	0m0.149s

After:
  %   cumulative      self
 time    seconds   seconds  name
  9.82      2.49      2.49  revlog.py:88:decompress
  2.67      1.31      0.68  localrepo.py:29:__get__
  2.57      0.65      0.65  utf_8.py:16:decode
  2.48      1.01      0.63  changelog.py:201:node
  2.10      0.82      0.53  changelog.py:136:tip
  2.01      0.51      0.51  ui.py:577:write
  1.91      0.49      0.49  util.py:1232:datestr
  1.85      1.65      0.47  color.py:395:write

real	0m25.619s
user	0m25.446s
sys	0m0.166s

== cpython repo on os x =
Before:
  %   cumulative      self
 time    seconds   seconds  name
  5.05      1.35      1.35  cmdutil.py:982:_show
  4.59      1.22      1.22  revlog.py:274:__len__
  3.98      1.06      1.06  i18n.py:62:gettext
  3.91      1.04      1.04  revlog.py:1016:revision
  3.68      0.98      0.98  revlog.py:337:parents
  3.45      0.92      0.92  revlog.py:88:decompress
  2.91      0.78      0.78  revlog.py:309:rev
  2.62      0.70      0.70  revlog.py:1033:revision

real	0m30.414s
user	0m28.145s
sys	0m0.541s



After:
  %   cumulative      self
 time    seconds   seconds  name
  7.98      1.66      1.66  cmdutil.py:982:_show
  6.83      1.42      1.42  changelog.py:46:decodeextra
  5.18      1.08      1.08  revlog.py:274:__len__
  3.94      0.82      0.82  revlog.py:1016:revision
  3.41      0.71      0.71  revlog.py:309:rev
  3.32      0.69      0.69  revlog.py:88:decompress
  2.99      0.63      0.62  revlog.py:1033:revision
  2.69      0.56      0.56  revlog.py:341:start

real	0m22.811s
user	0m21.883s
sys	0m0.397s
2014-10-17 13:52:10 -04:00
Mads Kiilerich
e49fb83975 i18n: use datapath for i18n like for templates and help
To avoid circular module dependencies we initialize i18n from util when
datapath is found.
2014-09-28 16:57:47 +02:00
Yuya Nishihara
cc6b6f4d1b i18n: detect UI language without POSIX-style locale variable on Windows (BC)
On Windows, it isn't common to set LANG environment variable. This patch makes
gettext honor Windows-style UI language [1] if no locale variables are set.

Because of this change, LANG=C or HGPLAIN must be set in order to disable
translation on non-English Windows.

 [1]: http://msdn.microsoft.com/en-us/library/dd374098(v=VS.85).aspx
2014-08-03 19:19:23 +09:00
Matt Mackall
36c70daf5c i18n: explicitly decode paragraphs
This was triggering an exception when the default encoding was disabled.
2014-06-12 14:40:45 -05:00
Augie Fackler
14695b388a i18n: use getattr instead of hasattr
Using getattr instead of util.safehasattr here to avoid adding another
dependency for i18n.
2011-07-25 20:46:30 -05:00
Brodie Rao
5f24d65643 HGPLAIN: allow exceptions to plain mode, like i18n, via HGPLAINEXCEPT
This makes it possible to gain the benefits of HGPLAIN for scripting
while preserving different behaviors like internationalization.
2011-01-05 00:18:36 +11:00
Martin Geisler
2493321650 i18n: fix translation of empty paragraphs 2010-06-19 19:16:11 +02:00
Wagner Bruna
3eefab1b9b i18n: translate each paragraph separately
Makes translation work easier by reducing message sizes and avoiding
invalidating whole messages on small changes or additions to the
original text.
2010-04-06 22:30:50 -03:00
Brodie Rao
48b845981a ui: add HGPLAIN environment variable for easier scripting
If HGPLAIN is set, the following settings are ignored when read from
hgrc files:

- ui.debug
- ui.fallbackencoding
- ui.quiet
- ui.traceback
- ui.verbose
- defaults.*

Localization is also disabled.

Equivalent options set via command line are honored.
2010-02-07 14:56:18 +01:00
Matt Mackall
595d66f424 Update license to GPLv2+ 2010-01-19 22:20:08 -06:00
Martin Geisler
3550fb27d7 i18n: remove unnecessary os.path.normpath call 2009-10-03 18:58:25 +02:00
Martin Geisler
147cf1b01f i18n: move unrelated line out of try-except block 2009-08-06 00:34:28 +02:00
Martin Geisler
a2c9777e20 i18n: updated outdated comment 2009-08-06 00:26:34 +02:00
Simon Heimberg
09ac1e6c92 separate import lines from mercurial and general python modules 2009-04-28 17:40:46 +02:00
Martin Geisler
8e4bc1e9ad put license and copyright info into comment blocks 2009-04-26 01:13:08 +02:00
Martin Geisler
750183bdad updated license to be explicit about GPL version 2 2009-04-26 01:08:54 +02:00
Matt Mackall
642f4d7151 move encoding bits from util to encoding
In addition to cleaning up util, this gets rid of some circular dependencies.
2009-04-03 14:51:48 -05:00
Martin Geisler
7f3f8dbbe2 i18n: encode output in user's local encoding
This makes the translated output obey the HGENCODING environment
variable or the preferred encoding as set by the LANG or LC_ALL
environment variables.

Python 2.4 has a lgettext method which is similar, except that it
doesn't know about HGENCODING or the settings in .hgrc.
2009-01-15 00:14:36 +01:00
Martin Geisler
b8064b97f3 i18n: lookup .mo files in private locale/ directory
This default is to look for /usr/share/locale/xx/LC_MESSAGES/hg.mo for
language xx, but this code will instead do the lookup from locale/ or
mercurial/locale/ relative to the root of the Mercurial source tree.
2009-01-15 00:12:35 +01:00
Matt Mackall
d1c48b4dad Enable gettext translations
The new demandimport eliminates most of the gettext performance hit of
importing gettext, which was doubling the run time for 'hg'.

Now, with 'hg tip':

dummy: .09530s no translations: .09638s translations: .09755s
2006-12-14 17:32:00 -06:00
Vadim Gelfer
dc377b58c1 update copyrights. 2006-08-12 12:30:02 -07:00
Benoit Boissinot
912c1aa6a3 use a dummy function for gettext
import gettext is really slow, until we figure out a solution
we use identity for gettext
2005-10-18 18:38:04 -07:00
Benoit Boissinot
e38e94088a i18n first part: make '_' available for files who need it 2005-10-18 18:37:48 -07:00