summaryrefslogtreecommitdiff
path: root/django/bin
diff options
context:
space:
mode:
authorGeorg Bauer <gb@hugo.westfalen.de>2005-09-29 17:01:05 +0000
committerGeorg Bauer <gb@hugo.westfalen.de>2005-09-29 17:01:05 +0000
commit98d74306099d73a4e6765bf677207b240f82dd16 (patch)
tree062de72e915bce4475f5bf7470970cfb9cbee74e /django/bin
parenta60b2050c643314996434117892136fba8adb487 (diff)
i18n patch - references #65
git-svn-id: http://code.djangoproject.com/svn/django/branches/i18n@726 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/bin')
-rwxr-xr-xdjango/bin/compile-messages.py24
-rwxr-xr-xdjango/bin/make-messages.py47
2 files changed, 71 insertions, 0 deletions
diff --git a/django/bin/compile-messages.py b/django/bin/compile-messages.py
new file mode 100755
index 0000000000..0b5127f6b2
--- /dev/null
+++ b/django/bin/compile-messages.py
@@ -0,0 +1,24 @@
+#!/usr/bin/python
+
+import os
+import sys
+import getopt
+
+basedir = None
+
+if os.path.isdir(os.path.join('conf', 'locale')):
+ basedir = os.path.abspath(os.path.join('conf', 'locale'))
+elif os.path.isdir('locale'):
+ basedir = os.path.abspath('locale')
+else:
+ print "this script should be run from the django svn tree or your project or app tree"
+ sys.exit(1)
+
+for (dirpath, dirnames, filenames) in os.walk(basedir):
+ for file in filenames:
+ if file.endswith('.po'):
+ sys.stderr.write('processing file %s in %s\n' % (file, dirpath))
+ pf = os.path.splitext(os.path.join(dirpath, file))[0]
+ cmd = 'msgfmt -o %s.mo %s.po' % (pf, pf)
+ os.system(cmd)
+
diff --git a/django/bin/make-messages.py b/django/bin/make-messages.py
new file mode 100755
index 0000000000..e068382292
--- /dev/null
+++ b/django/bin/make-messages.py
@@ -0,0 +1,47 @@
+#!/usr/bin/python
+
+import os
+import sys
+import getopt
+
+basedir = None
+
+if os.path.isdir(os.path.join('conf', 'locale')):
+ basedir = os.path.abspath(os.path.join('conf', 'locale'))
+elif os.path.isdir('locale'):
+ basedir = os.path.abspath('locale')
+else:
+ print "this script should be run from the django svn tree or your project or app tree"
+ sys.exit(1)
+
+(opts, args) = getopt.getopt(sys.argv[1:], 'l:d:')
+
+lang = None
+domain = 'django'
+
+for o, v in opts:
+ if o == '-l':
+ lang = v
+ elif o == '-d':
+ domain = v
+
+if lang is None or domain is None:
+ print "usage: make-messages.py -l <language> -d <domain>"
+ sys.exit(1)
+
+basedir = os.path.join(basedir, lang, 'LC_MESSAGES')
+if not os.path.isdir(basedir):
+ os.makedirs(basedir)
+
+lf = os.path.join(basedir, '%s.po' % domain)
+
+for (dirpath, dirnames, filenames) in os.walk("."):
+ for file in filenames:
+ if file.endswith('.py') or file.endswith('.html'):
+ sys.stderr.write('processing file %s in %s\n' % (file, dirpath))
+ if os.path.isfile(lf):
+ cmd = 'xgettext -j -d %s -L Python -p %s %s' % (domain, basedir, os.path.join(dirpath, file))
+ else:
+ cmd = 'xgettext -d %s -L Python -p %s %s' % (domain, basedir, os.path.join(dirpath, file))
+ os.system(cmd)
+