The gen_xmlpool.py script would work correctly only when executed from the
directory that contained the script. This shortcoming was due to some
hard-coded paths in the script.
In order to easily invoke the script from the Android build system, we
must be able to execute the script from an arbitrary directory. To enable
that, this patch replaces the two hard-coded paths with new command line
arguments.
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
Reviewed-by: Carl Worth <cworth@cworth.org>
-rm -rf $(LANGS)
# Default target options.h
-rm -rf $(LANGS)
# Default target options.h
+options.h: LOCALEDIR := .
options.h: t_options.h mo
options.h: t_options.h mo
- $(PYTHON2) $(PYTHON_FLAGS) gen_xmlpool.py $(LANGS) > options.h
+ $(PYTHON2) $(PYTHON_FLAGS) gen_xmlpool.py t_options.h $(LOCALEDIR) $(LANGS) > options.h
# Update .mo files from the corresponding .po files.
mo:
# Update .mo files from the corresponding .po files.
mo:
+#
+# Usage:
+# gen_xmlpool.py /path/to/t_option.h localedir lang lang lang ...
+#
+# For each given language, this script expects to find a .mo file at
+# `{localedir}/{language}/LC_MESSAGES/options.mo`.
+#
+
import sys
import gettext
import re
import sys
import gettext
import re
+# Path to t_options.h
+template_header_path = sys.argv[1]
+
+localedir = sys.argv[2]
+
# List of supported languages
# List of supported languages
-languages = sys.argv[1:]
+languages = sys.argv[3:]
# Escape special characters in C strings
def escapeCString (s):
# Escape special characters in C strings
def escapeCString (s):
translations = [("en", gettext.NullTranslations())]
for lang in languages:
try:
translations = [("en", gettext.NullTranslations())]
for lang in languages:
try:
- trans = gettext.translation ("options", ".", [lang])
+ trans = gettext.translation ("options", localedir, [lang])
except IOError:
sys.stderr.write ("Warning: language '%s' not found.\n" % lang)
continue
except IOError:
sys.stderr.write ("Warning: language '%s' not found.\n" % lang)
continue
# Process the options template and generate options.h with all
# translations.
# Process the options template and generate options.h with all
# translations.
-template = file ("t_options.h", "r")
+template = file (template_header_path, "r")
descMatches = []
for line in template:
if len(descMatches) > 0:
descMatches = []
for line in template:
if len(descMatches) > 0: