PRIVATE_SCRIPT := $(LOCAL_PATH)/xmlpool/gen_xmlpool.py
PRIVATE_LOCALEDIR := $(intermediates)/xmlpool
PRIVATE_TEMPLATE_HEADER := $(LOCAL_PATH)/xmlpool/t_options.h
-PRIVATE_MO_FILES := $(MESA_DRI_OPTIONS_LANGS:%=$(intermediates)/xmlpool/%/LC_MESSAGES/options.mo)
+PRIVATE_MO_FILES := $(MESA_DRI_OPTIONS_LANGS:%=$(intermediates)/xmlpool/%.gmo)
LOCAL_GENERATED_SOURCES += $(PRIVATE_MO_FILES)
$(LOCAL_GENERATED_SOURCES): PRIVATE_PYTHON := $(MESA_PYTHON2)
-$(PRIVATE_MO_FILES): $(intermediates)/xmlpool/%/LC_MESSAGES/options.mo: $(intermediates)/xmlpool/%.po
+$(PRIVATE_MO_FILES): $(intermediates)/xmlpool/%.gmo: $(intermediates)/xmlpool/%.po
mkdir -p $(dir $@)
msgfmt -o $@ $<
# Don't change anything below, unless you know what you're doing.
#
LANGS=$(POS:%.po=%)
-MOS=$(POS:%.po=%/LC_MESSAGES/options.mo)
+MOS=$(POS:%.po=%.gmo)
POT=xmlpool.pot
-.PHONY: all clean pot po mo
+.PHONY: all clean clean-local pot po mo
EXTRA_DIST = \
gen_xmlpool.py \
$(POS) \
$(MOS)
+clean-local:
+ rm -f $(MOS)
+
# Default target options.h
LOCALEDIR := .
options.h: t_options.h $(MOS)
$(AM_V_GEN) $(PYTHON) $(PYTHON_FLAGS) $(srcdir)/gen_xmlpool.py $(srcdir)/t_options.h $(LOCALEDIR) $(LANGS) > options.h
# Update .mo files from the corresponding .po files.
-%/LC_MESSAGES/options.mo: %.po
+%.gmo: %.po
@mo="$@"; \
lang=$${mo%%/*}; \
echo "Updating ($$lang) $@ from $?."; \
- $(MKDIR_P) $$lang/LC_MESSAGES; \
msgfmt -o $@ $?
# Use this target to create or update .po files with new messages in
#
from __future__ import print_function
-
import argparse
-import io
-import sys
import gettext
+import io
+import os
import re
+import sys
parser = argparse.ArgumentParser()
parser.add_argument('template')
translations = [("en", gettext.NullTranslations())]
for lang in args.languages:
try:
- trans = gettext.translation ("options", args.localedir, [lang])
- except IOError:
+ filename = os.path.join(args.localedir, '{}.gmo'.format(lang))
+ with io.open(filename, 'rb') as f:
+ trans = gettext.GNUTranslations(f)
+ except (IOError, OSError):
sys.stderr.write ("Warning: language '%s' not found.\n" % lang)
continue
translations.append ((lang, trans))
input : ['gen_xmlpool.py', 't_options.h'],
output : 'options.h',
command : [
- prog_python, '@INPUT@', meson.current_source_dir(), _langs,
+ prog_python, '@INPUT@', meson.current_build_dir(), _langs,
],
capture : true,
depend_files : _langs_po_files,