mirror of
https://github.com/django/django.git
synced 2025-04-26 10:14:36 +00:00
Changed unique-messages.py, compile-messages.py and make-messages.py to use 'if name == main' so they can be imported and won't mess up utilities such as pychecker
git-svn-id: http://code.djangoproject.com/svn/django/trunk@2056 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
2e0fc1ff95
commit
ce40c4a9e2
@ -4,17 +4,18 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import getopt
|
import getopt
|
||||||
|
|
||||||
basedir = None
|
def compile_messages():
|
||||||
|
basedir = None
|
||||||
|
|
||||||
if os.path.isdir(os.path.join('conf', 'locale')):
|
if os.path.isdir(os.path.join('conf', 'locale')):
|
||||||
basedir = os.path.abspath(os.path.join('conf', 'locale'))
|
basedir = os.path.abspath(os.path.join('conf', 'locale'))
|
||||||
elif os.path.isdir('locale'):
|
elif os.path.isdir('locale'):
|
||||||
basedir = os.path.abspath('locale')
|
basedir = os.path.abspath('locale')
|
||||||
else:
|
else:
|
||||||
print "this script should be run from the django svn tree or your project or app tree"
|
print "this script should be run from the django svn tree or your project or app tree"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
for (dirpath, dirnames, filenames) in os.walk(basedir):
|
for (dirpath, dirnames, filenames) in os.walk(basedir):
|
||||||
for file in filenames:
|
for file in filenames:
|
||||||
if file.endswith('.po'):
|
if file.endswith('.po'):
|
||||||
sys.stderr.write('processing file %s in %s\n' % (file, dirpath))
|
sys.stderr.write('processing file %s in %s\n' % (file, dirpath))
|
||||||
@ -22,3 +23,5 @@ for (dirpath, dirnames, filenames) in os.walk(basedir):
|
|||||||
cmd = 'msgfmt -o "%s.mo" "%s.po"' % (pf, pf)
|
cmd = 'msgfmt -o "%s.mo" "%s.po"' % (pf, pf)
|
||||||
os.system(cmd)
|
os.system(cmd)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
compile_messages()
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
from django.utils.translation import templateize
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import getopt
|
import getopt
|
||||||
|
|
||||||
from django.utils.translation import templateize
|
|
||||||
|
|
||||||
pythonize_re = re.compile(r'\n\s*//')
|
pythonize_re = re.compile(r'\n\s*//')
|
||||||
|
|
||||||
localedir = None
|
def make_messages():
|
||||||
|
localedir = None
|
||||||
|
|
||||||
if os.path.isdir(os.path.join('conf', 'locale')):
|
if os.path.isdir(os.path.join('conf', 'locale')):
|
||||||
localedir = os.path.abspath(os.path.join('conf', 'locale'))
|
localedir = os.path.abspath(os.path.join('conf', 'locale'))
|
||||||
elif os.path.isdir('locale'):
|
elif os.path.isdir('locale'):
|
||||||
localedir = os.path.abspath('locale')
|
localedir = os.path.abspath('locale')
|
||||||
else:
|
else:
|
||||||
print "This script should be run from the django svn tree or your project or app tree."
|
print "This script should be run from the django svn tree or your project or app tree."
|
||||||
print "If you did indeed run it from the svn checkout or your project or application,"
|
print "If you did indeed run it from the svn checkout or your project or application,"
|
||||||
print "maybe you are just missing the conf/locale (in the django tree) or locale (for project"
|
print "maybe you are just missing the conf/locale (in the django tree) or locale (for project"
|
||||||
@ -24,14 +24,14 @@ else:
|
|||||||
print "you want to enable i18n for your project or application."
|
print "you want to enable i18n for your project or application."
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
(opts, args) = getopt.getopt(sys.argv[1:], 'l:d:va')
|
(opts, args) = getopt.getopt(sys.argv[1:], 'l:d:va')
|
||||||
|
|
||||||
lang = None
|
lang = None
|
||||||
domain = 'django'
|
domain = 'django'
|
||||||
verbose = False
|
verbose = False
|
||||||
all = False
|
all = False
|
||||||
|
|
||||||
for o, v in opts:
|
for o, v in opts:
|
||||||
if o == '-l':
|
if o == '-l':
|
||||||
lang = v
|
lang = v
|
||||||
elif o == '-d':
|
elif o == '-d':
|
||||||
@ -41,22 +41,22 @@ for o, v in opts:
|
|||||||
elif o == '-a':
|
elif o == '-a':
|
||||||
all = True
|
all = True
|
||||||
|
|
||||||
if domain not in ('django', 'djangojs'):
|
if domain not in ('django', 'djangojs'):
|
||||||
print "currently make-messages.py only supports domains 'django' and 'djangojs'"
|
print "currently make-messages.py only supports domains 'django' and 'djangojs'"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
if (lang is None and not all) or domain is None:
|
if (lang is None and not all) or domain is None:
|
||||||
print "usage: make-messages.py -l <language>"
|
print "usage: make-messages.py -l <language>"
|
||||||
print " or: make-messages.py -a"
|
print " or: make-messages.py -a"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
languages = []
|
languages = []
|
||||||
|
|
||||||
if lang is not None:
|
if lang is not None:
|
||||||
languages.append(lang)
|
languages.append(lang)
|
||||||
elif all:
|
elif all:
|
||||||
languages = [el for el in os.listdir(localedir) if not el.startswith('.')]
|
languages = [el for el in os.listdir(localedir) if not el.startswith('.')]
|
||||||
|
|
||||||
for lang in languages:
|
for lang in languages:
|
||||||
|
|
||||||
print "processing language", lang
|
print "processing language", lang
|
||||||
basedir = os.path.join(localedir, lang, 'LC_MESSAGES')
|
basedir = os.path.join(localedir, lang, 'LC_MESSAGES')
|
||||||
@ -137,3 +137,5 @@ for lang in languages:
|
|||||||
open(pofile, 'wb').write(msgs)
|
open(pofile, 'wb').write(msgs)
|
||||||
os.unlink(potfile)
|
os.unlink(potfile)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
make_messages()
|
||||||
|
@ -4,17 +4,18 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import getopt
|
import getopt
|
||||||
|
|
||||||
basedir = None
|
def unique_messages():
|
||||||
|
basedir = None
|
||||||
|
|
||||||
if os.path.isdir(os.path.join('conf', 'locale')):
|
if os.path.isdir(os.path.join('conf', 'locale')):
|
||||||
basedir = os.path.abspath(os.path.join('conf', 'locale'))
|
basedir = os.path.abspath(os.path.join('conf', 'locale'))
|
||||||
elif os.path.isdir('locale'):
|
elif os.path.isdir('locale'):
|
||||||
basedir = os.path.abspath('locale')
|
basedir = os.path.abspath('locale')
|
||||||
else:
|
else:
|
||||||
print "this script should be run from the django svn tree or your project or app tree"
|
print "this script should be run from the django svn tree or your project or app tree"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
for (dirpath, dirnames, filenames) in os.walk(basedir):
|
for (dirpath, dirnames, filenames) in os.walk(basedir):
|
||||||
for file in filenames:
|
for file in filenames:
|
||||||
if file.endswith('.po'):
|
if file.endswith('.po'):
|
||||||
sys.stderr.write('processing file %s in %s\n' % (file, dirpath))
|
sys.stderr.write('processing file %s in %s\n' % (file, dirpath))
|
||||||
@ -24,3 +25,5 @@ for (dirpath, dirnames, filenames) in os.walk(basedir):
|
|||||||
msg = stdout.read()
|
msg = stdout.read()
|
||||||
open('%s.po' % pf, 'w').write(msg)
|
open('%s.po' % pf, 'w').write(msg)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unique_messages()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user