On Fri, 24 Aug 2018 at 15:16, Dylan Baker <dy...@pnwbakers.com> wrote:
>
> 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

No obvious reason comes to mind why we want divergence here.
Can you elaborate more what's happening here - what are the .gmo
files, I though we're using .mo ones?

If the only difference is a) extension and b) .mo file location - we
could update the autoconf/others to follow the same pattern.

> ---
>  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
>
I would keep these in 2/5 which already does the cleanups.

>  parser = argparse.ArgumentParser()
>  parser.add_argument('template')
>  parser.add_argument('localedir')
>  parser.add_argument('languages', nargs='*')
> +parser.add_argument('--meson', action='store_true')
Please annotate the argument as required/optional as they are introduced.

>  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
Something looks odd there - do we raise an exception, or continue
(while printing an warning to strerr)?

-Emil
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to