[PATCH 3 of 6] lookup .mo files in private locale directory
Martin Geisler
mg at daimi.au.dk
Sat Aug 23 13:37:22 UTC 2008
# HG changeset patch
# User Martin Geisler <mg at daimi.au.dk>
# Date 1219498339 -7200
# Node ID f8fd0cd27bfdc986fdb2ce7456cf8813d15a1dc3
# Parent 7ea3303bff81955423ffc2f985b77d21bd192484
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.
Updated setup.py to ship the xx.po and xx.mo files.
diff -r 7ea3303bff81 -r f8fd0cd27bfd mercurial/i18n.py
--- a/mercurial/i18n.py Sat Aug 23 15:32:19 2008 +0200
+++ b/mercurial/i18n.py Sat Aug 23 15:32:19 2008 +0200
@@ -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
diff -r 7ea3303bff81 -r f8fd0cd27bfd setup.py
--- a/setup.py Sat Aug 23 15:32:19 2008 +0200
+++ b/setup.py Sat Aug 23 15:32:19 2008 +0200
@@ -115,6 +115,12 @@
except ImportError:
pass
+data_files = []
+for root in ('templates', 'po', 'locale'):
+ for dir, dirs, files in os.walk(root):
+ data_files.append((os.path.join('mercurial', dir),
+ [os.path.join(dir, file_) for file_ in files]))
+
setup(name='mercurial',
version=mercurial.version.get_version(),
author='Matt Mackall',
@@ -125,9 +131,7 @@
scripts=scripts,
packages=packages,
ext_modules=ext_modules,
- data_files=[(os.path.join('mercurial', root),
- [os.path.join(root, file_) for file_ in files])
- for root, dirs, files in os.walk('templates')],
+ data_files=data_files,
cmdclass=cmdclass,
options=dict(py2exe=dict(packages=['hgext', 'email']),
bdist_mpkg=dict(zipdist=True,
More information about the Mercurial-devel
mailing list