[Mesa-dev] [PATCH 4/5] util/gen_xmlpool: Add a --meson switch
Dylan Baker
dylan at pnwbakers.com
Fri Aug 24 14:13:44 UTC 2018
Meson won't put the .gmo files in the layout that python's
gettext.translation() expects, so we need to handle them differently,
this switch allows the script to load the files as meson lays them out
---
src/util/xmlpool/gen_xmlpool.py | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/src/util/xmlpool/gen_xmlpool.py b/src/util/xmlpool/gen_xmlpool.py
index b40f295738e..59d7a9bb84d 100644
--- a/src/util/xmlpool/gen_xmlpool.py
+++ b/src/util/xmlpool/gen_xmlpool.py
@@ -8,17 +8,18 @@
#
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')
parser.add_argument('localedir')
parser.add_argument('languages', nargs='*')
+parser.add_argument('--meson', action='store_true')
args = parser.parse_args()
if sys.version_info < (3, 0):
@@ -166,8 +167,14 @@ def expandMatches (matches, translations, end=None):
translations = [("en", gettext.NullTranslations())]
for lang in args.languages:
try:
- trans = gettext.translation ("options", args.localedir, [lang])
+ if args.meson:
+ filename = os.path.join(args.localedir, '{}.gmo'.format(lang))
+ with io.open(filename, 'rb') as f:
+ trans = gettext.GNUTranslations(f)
+ else:
+ trans = gettext.translation ("options", args.localedir, [lang])
except IOError:
+ raise
sys.stderr.write ("Warning: language '%s' not found.\n" % lang)
continue
translations.append ((lang, trans))
--
2.18.0
More information about the mesa-dev
mailing list