Mercurial > hg
changeset 7650:85ae7aaf08e9
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.
author | Martin Geisler <mg@daimi.au.dk> |
---|---|
date | Thu, 15 Jan 2009 00:12:35 +0100 |
parents | a489e3a94443 |
children | 5b5036ef847a |
files | mercurial/i18n.py |
diffstat | 1 files changed, 15 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/i18n.py Thu Jan 15 00:11:54 2009 +0100 +++ b/mercurial/i18n.py Thu Jan 15 00:12:35 2009 +0100 @@ -7,7 +7,20 @@ of the GNU General Public License, incorporated herein by reference. """ -import gettext -t = gettext.translation('hg', fallback=1) +import gettext, sys, os + +# modelled after templater.templatepath: +if hasattr(sys, 'frozen'): + module = sys.executable +else: + module = __file__ + +base = os.path.dirname(module) +for dir in ('.', '..'): + localedir = os.path.normpath(os.path.join(base, dir, 'locale')) + if os.path.isdir(localedir): + break + +t = gettext.translation('hg', localedir, fallback=True) gettext = t.gettext _ = gettext