i18n: add args keyword to merge_file

* i18n: add args keyword to merge_file

* i18n: add testcase to msgfmt args
pull/5302/head
Konstantin 6 years ago committed by Jussi Pakkanen
parent 8dedddca36
commit 841995cddf
  1. 1
      docs/markdown/i18n-module.md
  2. 7
      mesonbuild/modules/i18n.py
  3. 3
      mesonbuild/scripts/msgfmthelper.py
  4. 3
      test cases/frameworks/6 gettext/data2/meson.build
  5. 2
      test cases/frameworks/6 gettext/data2/test.desktop.in
  6. 2
      test cases/frameworks/6 gettext/installed_files.txt
  7. 2
      test cases/frameworks/6 gettext/po/LINGUAS
  8. 2
      test cases/frameworks/6 gettext/po/meson.build
  9. 34
      test cases/frameworks/6 gettext/po/ru.po

@ -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*

@ -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']

@ -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)

@ -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')
)

@ -1,6 +1,6 @@
[Desktop Entry]
Name=Test
GenericName=Application
Comment=Test Application
Description=Test Application
Type=Application

@ -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

@ -1,3 +1,3 @@
langs = ['fi', 'de']
langs = ['fi', 'de', 'ru']
i18n.gettext('intltest', languages : langs)

@ -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 <EMAIL@ADDRESS>, 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 "Тестовое приложение"
Loading…
Cancel
Save