Permalink
Browse files

dev instructions should now work with the new gettext-based infrastru…

…cture.
  • Loading branch information...
1 parent 93a6577 commit 92abd1e45022d3a947876f3e7ad143b88b0f558b @toolness toolness committed Nov 12, 2011
Showing with 26 additions and 9 deletions.
  1. +1 −1 .gitignore
  2. +15 −5 go.py
  3. +10 −3 vendor/localization.py
View
@@ -3,4 +3,4 @@ browser-addon/chrome/webxray.js
src/settings.local.js
static-files/mix-master-dialog
/locale
-/src/locale
+/src/locale/*.js
View
@@ -103,6 +103,13 @@ def serve(cfg, ip=''):
print "serving on %s port %d" % (ipstr, cfg['port'])
server.serve_forever()
+def compilemessages(cfg):
+ localization.compilemessages(json_dir=path(cfg['staticFilesDir']),
+ js_locale_dir=path('src', 'locale'),
+ default_locale='en',
+ locale_dir=locale_dir,
+ locale_domain=locale_domain)
+
if __name__ == "__main__":
cfg = json.loads(open('config.json', 'r').read())
cfg['compiledFilename'] = cfg['staticFilesDir'] + cfg['compiledFile']
@@ -114,15 +121,13 @@ def serve(cfg, ip=''):
cmd = sys.argv[1]
if cmd == 'serve':
+ compilemessages(cfg)
serve(cfg, '127.0.0.1')
elif cmd == 'globalserve':
+ compilemessages(cfg)
serve(cfg)
elif cmd == 'compilemessages':
- localization.compilemessages(json_dir=path(cfg['staticFilesDir']),
- js_locale_dir=path('src', 'locale'),
- default_locale='en',
- locale_dir=locale_dir,
- locale_domain=locale_domain)
+ compilemessages(cfg)
elif cmd == 'makemessages':
locale = None
if len(sys.argv) > 2:
@@ -133,13 +138,18 @@ def serve(cfg, ip=''):
locale_domain=locale_domain,
locale=locale)
elif cmd == 'compile':
+ compilemessages(cfg)
f = open(cfg['compiledFilename'], 'w')
f.write(build_compiled_file(cfg))
f.close()
print "wrote %s" % cfg['compiledFilename']
elif cmd == 'clean':
if os.path.exists(cfg['compiledFilename']):
+ print "removing %s" % cfg['compiledFilename']
os.remove(cfg['compiledFilename'])
+ for filename in glob.glob(path('src', 'locale', '*.js')):
+ print "removing %s" % filename
+ os.remove(filename)
print "removed generated files."
else:
print "unknown command: %s" % cmd
@@ -32,6 +32,8 @@ def webxray_extract(fileobj, keywords, comment_tags, options):
yield (lineno, funcname, message, comments)
def find_locales(dirname, domain):
+ if not os.path.exists(dirname):
+ return []
return [name for name in os.listdir(dirname)
if locale_exists(name, dirname, domain)]
@@ -45,9 +47,11 @@ def compilemessages(json_dir, js_locale_dir, locale_dir, locale_domain,
"convert message files into binary and JS formats"
data = json.load(open(os.path.join(json_dir, 'strings.json')))
- babel(['compile', '--use-fuzzy', '-d', locale_dir, '-D',
- locale_domain])
- locales = find_locales(locale_dir, locale_domain) + [default_locale]
+ found_locales = find_locales(locale_dir, locale_domain)
+ if found_locales:
+ babel(['compile', '--use-fuzzy', '-d', locale_dir, '-D',
+ locale_domain])
+ locales = found_locales + [default_locale]
for locale in locales:
nice_locale = locale.replace('_', '-')
print "processing localization '%s'" % nice_locale
@@ -94,6 +98,9 @@ def makemessages(babel_ini_file, json_dir, locale_dir,
babel(['extract', '-F', babel_ini_file, '-o', potfile,
json_dir])
+ if not locale and not find_locales(locale_dir, locale_domain):
+ return
+
babel([cmd, '-i', potfile, '-d', locale_dir, '-D', locale_domain] +
localeargs)

0 comments on commit 92abd1e

Please sign in to comment.