From 98d74306099d73a4e6765bf677207b240f82dd16 Mon Sep 17 00:00:00 2001 From: Georg Bauer Date: Thu, 29 Sep 2005 17:01:05 +0000 Subject: [PATCH] i18n patch - references #65 git-svn-id: http://code.djangoproject.com/svn/django/branches/i18n@726 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/bin/compile-messages.py | 24 +++ django/bin/make-messages.py | 47 +++++ django/conf/admin_templates/index.html | 10 +- django/conf/locale/de/LC_MESSAGES/django.mo | Bin 0 -> 951 bytes django/conf/locale/de/LC_MESSAGES/django.po | 51 +++++ django/conf/settings.py | 7 + django/core/defaulttags.py | 43 +++++ django/core/validators.py | 2 +- django/middleware/locale.py | 38 ++++ django/utils/translation.py | 195 ++++++++++++++++++++ setup.py | 2 +- 11 files changed, 412 insertions(+), 7 deletions(-) create mode 100755 django/bin/compile-messages.py create mode 100755 django/bin/make-messages.py create mode 100644 django/conf/locale/de/LC_MESSAGES/django.mo create mode 100644 django/conf/locale/de/LC_MESSAGES/django.po create mode 100644 django/middleware/locale.py create mode 100644 django/utils/translation.py 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 -d " + 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) + diff --git a/django/conf/admin_templates/index.html b/django/conf/admin_templates/index.html index 7610b3a023..1a6949cf6c 100644 --- a/django/conf/admin_templates/index.html +++ b/django/conf/admin_templates/index.html @@ -23,13 +23,13 @@ {% endif %} {% if model.perms.add %} - Add + {% i18n _('Add') %} {% else %}   {% endif %} {% if model.perms.change %} - Change + {% i18n _('Change') %} {% else %}   {% endif %} @@ -47,12 +47,12 @@ {% block sidebar %}