From 841995cddf7ad2fe18ff89ac6508aef459ec5742 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Mon, 22 Apr 2019 14:54:05 +0300 Subject: i18n: add args keyword to merge_file * i18n: add args keyword to merge_file * i18n: add testcase to msgfmt args --- docs/markdown/i18n-module.md | 1 + mesonbuild/modules/i18n.py | 7 ++++- mesonbuild/scripts/msgfmthelper.py | 3 +- test cases/frameworks/6 gettext/data2/meson.build | 3 +- .../frameworks/6 gettext/data2/test.desktop.in | 2 +- .../frameworks/6 gettext/installed_files.txt | 2 ++ test cases/frameworks/6 gettext/po/LINGUAS | 2 ++ test cases/frameworks/6 gettext/po/meson.build | 2 +- test cases/frameworks/6 gettext/po/ru.po | 34 ++++++++++++++++++++++ 9 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 test cases/frameworks/6 gettext/po/ru.po diff --git a/docs/markdown/i18n-module.md b/docs/markdown/i18n-module.md index 9053edc..4948fab 100644 --- a/docs/markdown/i18n-module.md +++ b/docs/markdown/i18n-module.md @@ -48,5 +48,6 @@ for normal keywords. In addition it accepts these keywords: also `i18n.gettext()`) * `po_dir`: directory containing translations, relative to current directory * `type`: type of file, valid options are `'xml'` (default) and `'desktop'` +* `args`: (*Added 0.51.0*) list of extra arguments to pass to `msgfmt` *Added 0.37.0* diff --git a/mesonbuild/modules/i18n.py b/mesonbuild/modules/i18n.py index 4b37069..76b9d63 100644 --- a/mesonbuild/modules/i18n.py +++ b/mesonbuild/modules/i18n.py @@ -64,7 +64,8 @@ class I18nModule(ExtensionModule): return [path.join(src_dir, d) for d in dirs] @FeatureNew('i18n.merge_file', '0.37.0') - @permittedKwargs(build.CustomTarget.known_kwargs | {'data_dirs', 'po_dir', 'type'}) + @FeatureNewKwargs('i18n.merge_file', '0.51.0', ['args']) + @permittedKwargs(build.CustomTarget.known_kwargs | {'data_dirs', 'po_dir', 'type', 'args'}) def merge_file(self, state, args, kwargs): podir = kwargs.pop('po_dir', None) if not podir: @@ -86,6 +87,10 @@ class I18nModule(ExtensionModule): if datadirs: command.append(datadirs) + if 'args' in kwargs: + command.append('--') + command.append(mesonlib.stringlistify(kwargs.pop('args', []))) + kwargs['command'] = command inputfile = kwargs['input'] diff --git a/mesonbuild/scripts/msgfmthelper.py b/mesonbuild/scripts/msgfmthelper.py index d4deb00..737f1bc 100644 --- a/mesonbuild/scripts/msgfmthelper.py +++ b/mesonbuild/scripts/msgfmthelper.py @@ -22,6 +22,7 @@ parser.add_argument('output') parser.add_argument('type') parser.add_argument('podir') parser.add_argument('--datadirs', default='') +parser.add_argument('args', default=[], metavar='extra msgfmt argument', nargs='*') def run(args): @@ -31,5 +32,5 @@ def run(args): env = os.environ.copy() env.update({'GETTEXTDATADIRS': options.datadirs}) return subprocess.call(['msgfmt', '--' + options.type, '-d', options.podir, - '--template', options.input, '-o', options.output], + '--template', options.input, '-o', options.output] + options.args, env=env) diff --git a/test cases/frameworks/6 gettext/data2/meson.build b/test cases/frameworks/6 gettext/data2/meson.build index d927ba3..b8c90a1 100644 --- a/test cases/frameworks/6 gettext/data2/meson.build +++ b/test cases/frameworks/6 gettext/data2/meson.build @@ -1,8 +1,9 @@ i18n.merge_file( input: 'test.desktop.in', - output: 'test.desktop', + output: 'test.plugin', type: 'desktop', po_dir: '../po', + args: ['--keyword=Description'], install: true, install_dir: join_paths(get_option('datadir'), 'applications') ) diff --git a/test cases/frameworks/6 gettext/data2/test.desktop.in b/test cases/frameworks/6 gettext/data2/test.desktop.in index 33b9a9f..5c8ea2e 100644 --- a/test cases/frameworks/6 gettext/data2/test.desktop.in +++ b/test cases/frameworks/6 gettext/data2/test.desktop.in @@ -1,6 +1,6 @@ [Desktop Entry] Name=Test GenericName=Application -Comment=Test Application +Description=Test Application Type=Application diff --git a/test cases/frameworks/6 gettext/installed_files.txt b/test cases/frameworks/6 gettext/installed_files.txt index 850711a..f32b282 100644 --- a/test cases/frameworks/6 gettext/installed_files.txt +++ b/test cases/frameworks/6 gettext/installed_files.txt @@ -1,8 +1,10 @@ usr/bin/intlprog?exe usr/share/locale/de/LC_MESSAGES/intltest.mo usr/share/locale/fi/LC_MESSAGES/intltest.mo +usr/share/locale/ru/LC_MESSAGES/intltest.mo usr/share/applications/something.desktop usr/share/applications/test.desktop +usr/share/applications/test.plugin usr/share/applications/test2.desktop usr/share/applications/test3.desktop usr/share/applications/test4.desktop diff --git a/test cases/frameworks/6 gettext/po/LINGUAS b/test cases/frameworks/6 gettext/po/LINGUAS index d319e48..c9274bf 100644 --- a/test cases/frameworks/6 gettext/po/LINGUAS +++ b/test cases/frameworks/6 gettext/po/LINGUAS @@ -1,2 +1,4 @@ de fi +ru + diff --git a/test cases/frameworks/6 gettext/po/meson.build b/test cases/frameworks/6 gettext/po/meson.build index 8ea2c11..86e02f1 100644 --- a/test cases/frameworks/6 gettext/po/meson.build +++ b/test cases/frameworks/6 gettext/po/meson.build @@ -1,3 +1,3 @@ -langs = ['fi', 'de'] +langs = ['fi', 'de', 'ru'] i18n.gettext('intltest', languages : langs) diff --git a/test cases/frameworks/6 gettext/po/ru.po b/test cases/frameworks/6 gettext/po/ru.po new file mode 100644 index 0000000..e5867c8 --- /dev/null +++ b/test cases/frameworks/6 gettext/po/ru.po @@ -0,0 +1,34 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the intltest package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: intltest\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-05-31 05:16-0500\n" +"PO-Revision-Date: 2019-04-22 02:38+0300\n" +"Language: ru\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Last-Translator: \n" +"Language-Team: \n" +"X-Generator: Poedit 2.2.1\n" + +#: src/intlmain.c:15 +msgid "International greeting." +msgstr "Межнациональное приветствие." + +#: data/test.desktop.in:3 +msgid "Test" +msgstr "Тест" + +#: data/test.desktop.in:4 +msgid "Application" +msgstr "Приложение" + +#: data/test.desktop.in:5 +msgid "Test Application" +msgstr "Тестовое приложение" -- cgit v1.1