Skip to content

Commit

Permalink
empty translation detection hack
Browse files Browse the repository at this point in the history
  • Loading branch information
gdtsouk committed Mar 17, 2014
1 parent e31236d commit 308972e
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 12 deletions.
12 changes: 7 additions & 5 deletions compile-translations.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/bin/bash

export DJANGO_SETTINGS_MODULE=settings
export PYTHONPATH=`pwd`

for d in zeus helios heliosauth server_ui; do
cd $d;
DJANGO_SETTINGS_MODULE=settings;
PYTHONPATH=..;
django-admin compilemessages;
cd ..;
cd $d;
django-admin compilemessages;
cd ..;
done;

cd zeus/static/booth;
django-admin compilemessages;
3 changes: 3 additions & 0 deletions detect-empty-translations
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

find . -name '*.po' | xargs ./detect-empty-translations.py
50 changes: 50 additions & 0 deletions detect-empty-translations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env python

import sys

po_files = sys.argv[1:]
if not po_files:
print "Usage: %s <path/to/some.po> ..." % sys.argv[0]
raise SystemExit

for po_file in po_files:
state = 0
msgid = None
msgstr = None
msgid_line = 0
fuzzy = False

for line in open(po_file):
msgid_line += 1
if line.startswith('#') and 'fuzzy' in line:
fuzzy = True
elif state == 0 and line.startswith('msgid'):
if line != 'msgid ""\n':
msgid = line
if fuzzy:
print "%s:%d: %s" % (po_file, msgid_line, msgid),
msgid = None
state = 0
else:
state = 1
fuzzy = False
elif state == 1:
fuzzy = False
if line == 'msgstr ""\n':
state = 2
elif line.startswith('msgstr') or line == '\n':
state = 0
msgid = None
fuzzy = False
elif state == 2:
fuzzy = False
if line == '\n':
print "%s:%d: %s" % (po_file, msgid_line, msgid),
state = 0
msgid = None
fuzzy = False

if (state == 0 and fuzzy) or (state == 2 and msgid is not None):
# last-in-file empty translation
print "%s:%d: %s" % (po_file, msgid_line, msgid),

13 changes: 6 additions & 7 deletions update-translations.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#!/bin/bash

export PYTHONPATH=`pwd`
export DJANGO_SETTINGS_MODULE=settings;
for d in zeus helios heliosauth server_ui; do
cd $d;
DJANGO_SETTINGS_MODULE=settings;
PYTHONPATH=..;
django-admin makemessages -l el -e .html -e .txt;
#django-admin makemessages -l en -e .html -e .txt;
cd ..;
cd $d;
django-admin makemessages -l el -e .html -e .txt;
#django-admin makemessages -l en -e .html -e .txt;
cd ..;
done;

python manage.py makeboothmessages -l en -l el -e .html -e .js;
cd zeus/static/booth;

0 comments on commit 308972e

Please sign in to comment.