diff options
author | Matthias Klumpp <matthias@tenstral.net> | 2021-12-18 04:26:46 +0100 |
---|---|---|
committer | Matthias Klumpp <matthias@tenstral.net> | 2022-01-21 22:26:17 +0100 |
commit | 02fb0c3f8bb60d88998c8a8c7d090ecc864ed04c (patch) | |
tree | d94965290f00c5d1a4173c274ca9575328a43624 /test cases | |
parent | e60d358e0482edc56b6441aaa3021d83dd14b527 (diff) | |
download | meson-02fb0c3f8bb60d88998c8a8c7d090ecc864ed04c.zip meson-02fb0c3f8bb60d88998c8a8c7d090ecc864ed04c.tar.gz meson-02fb0c3f8bb60d88998c8a8c7d090ecc864ed04c.tar.bz2 |
i18n: Add support for joining XML localization via itstool
Diffstat (limited to 'test cases')
-rw-r--r-- | test cases/frameworks/6 gettext/data3/com.mesonbuild.test.intlprog.metainfo.xml | 33 | ||||
-rw-r--r-- | test cases/frameworks/6 gettext/data3/meson.build | 33 | ||||
-rw-r--r-- | test cases/frameworks/6 gettext/data3/metainfo.its | 33 | ||||
-rwxr-xr-x | test cases/frameworks/6 gettext/data3/verify.py | 13 | ||||
-rw-r--r-- | test cases/frameworks/6 gettext/meson.build | 3 | ||||
-rw-r--r-- | test cases/frameworks/6 gettext/po/de.po | 4 | ||||
-rw-r--r-- | test cases/frameworks/6 gettext/po/intltest.pot | 4 | ||||
-rw-r--r-- | test cases/frameworks/6 gettext/po/meson.build | 3 | ||||
-rw-r--r-- | test cases/frameworks/6 gettext/test.json | 3 |
9 files changed, 127 insertions, 2 deletions
diff --git a/test cases/frameworks/6 gettext/data3/com.mesonbuild.test.intlprog.metainfo.xml b/test cases/frameworks/6 gettext/data3/com.mesonbuild.test.intlprog.metainfo.xml new file mode 100644 index 0000000..7fb4d1f --- /dev/null +++ b/test cases/frameworks/6 gettext/data3/com.mesonbuild.test.intlprog.metainfo.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<component type="console-application"> + <id>com.mesonbuild.test.intlprog</id> + + <name>Test</name> + <summary>Application</summary> + + <metadata_license>FSFAP</metadata_license> + <project_license>FSFAP</project_license> + + <description> + <p> + Test Application + </p> + <p> + International greeting. + </p> + <p> + This is <code>text</code> with <em>embedded XML tags</em>. Nice! + </p> + </description> + + <icon type="stock">meson-unittest-intlprog</icon> + + <categories> + <category>Development</category> + <category>Building</category> + </categories> + + <provides> + <binary>intlprog</binary> + </provides> +</component> diff --git a/test cases/frameworks/6 gettext/data3/meson.build b/test cases/frameworks/6 gettext/data3/meson.build new file mode 100644 index 0000000..2be2e89 --- /dev/null +++ b/test cases/frameworks/6 gettext/data3/meson.build @@ -0,0 +1,33 @@ + +if itstool.found() + + mi_translated = i18n.itstool_join( + input: 'com.mesonbuild.test.intlprog.metainfo.xml', + output: 'com.mesonbuild.test.intlprog.metainfo.xml', + mo_targets: mo_targets, + its_files: ['metainfo.its'], + install: true, + install_dir: get_option('datadir') / 'metainfo', + ) + + # older versions of itstool have a bug where ITS rules specified on the command-line + # are not read when joining files. Since we don't install appstream in the Meson CI + # environment, the to-be-tested entry will be untranslated and the test would fail, so + # we just skip verification if the installed itstool is too old. + r = run_command(itstool, '-v', check: true) + itstool_v = r.stdout().strip().split() + if itstool_v[1].version_compare('>=2.0.6') + verify_exe = find_program('verify.py') + test('test xml translation', + verify_exe, + args: [mi_translated, + '<p xml:lang="de">Dies ist <code>Text</code> mit <em>eingebetteten XML Tags</em>. Toll!</p>'] + ) + else + message('Skipping translation verification: Itstool too old.') + endif + +else + install_data('com.mesonbuild.test.intlprog.metainfo.xml', + install_dir: get_option('datadir') / 'metainfo') +endif diff --git a/test cases/frameworks/6 gettext/data3/metainfo.its b/test cases/frameworks/6 gettext/data3/metainfo.its new file mode 100644 index 0000000..0852a0f --- /dev/null +++ b/test cases/frameworks/6 gettext/data3/metainfo.its @@ -0,0 +1,33 @@ +<?xml version="1.0"?> +<!-- + Copyright (C) 2015-2021 Matthias Klumpp <matthias@tenstral.net> + Copyright (C) 2019 Takao Fujiwara <takao.fujiwara1@gmail.com> + SPDX-License-Identifier: FSFAP +--> +<its:rules xmlns:its="http://www.w3.org/2005/11/its" + version="2.0"> + + <its:withinTextRule withinText="yes" selector="/component//description//em | + /component//description//code"/> + + <its:translateRule selector="/component" translate="no"/> + <its:translateRule selector="/component/name | + /component/summary | + /component/description | + /component/developer_name | + /component/name_variant_suffix | + /component/screenshots/screenshot/caption | + /component/releases/release/description | + /component/agreement/agreement_section/name | + /component/agreement/agreement_section/description" + translate="yes"/> + + <its:translateRule selector="/component/name[@translatable = 'no']" + translate="no"/> + <its:translateRule selector="/component/developer_name[@translatable = 'no']" + translate="no"/> + <its:translateRule selector="/component/name_variant_suffix[@translatable = 'no']" + translate="no"/> + <its:translateRule selector="/component/releases/release/description[@translatable = 'no']" + translate="no"/> +</its:rules> diff --git a/test cases/frameworks/6 gettext/data3/verify.py b/test cases/frameworks/6 gettext/data3/verify.py new file mode 100755 index 0000000..aff2f2e --- /dev/null +++ b/test cases/frameworks/6 gettext/data3/verify.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 + +import os +import sys + +assert len(sys.argv) == 3 + +fname = sys.argv[1] +check_str = sys.argv[2] + +assert os.path.isfile(fname) +with open(fname, 'r', encoding='utf-8') as f: + assert check_str in f.read() diff --git a/test cases/frameworks/6 gettext/meson.build b/test cases/frameworks/6 gettext/meson.build index 2640ab2..ce99242 100644 --- a/test cases/frameworks/6 gettext/meson.build +++ b/test cases/frameworks/6 gettext/meson.build @@ -15,10 +15,13 @@ if not intl.found() error('MESON_SKIP_TEST libintl/gettext functions not found.') endif +itstool = find_program('itstool', required: false) + i18n = import('i18n') subdir('po') subdir('src') subdir('data') subdir('data2') +subdir('data3') subdir('generated') diff --git a/test cases/frameworks/6 gettext/po/de.po b/test cases/frameworks/6 gettext/po/de.po index 8d9d6e7..1e4693b 100644 --- a/test cases/frameworks/6 gettext/po/de.po +++ b/test cases/frameworks/6 gettext/po/de.po @@ -20,3 +20,7 @@ msgstr "" #: src/intlmain.c:15 msgid "International greeting." msgstr "Internationale Gruss." + +#: data/com.mesonbuild.test.dummy.metainfo.xml:19 +msgid "This is <code>text</code> with <em>embedded XML tags</em>. Nice!" +msgstr "Dies ist <code>Text</code> mit <em>eingebetteten XML Tags</em>. Toll!" diff --git a/test cases/frameworks/6 gettext/po/intltest.pot b/test cases/frameworks/6 gettext/po/intltest.pot index 2d0a4cc..c34e7f9 100644 --- a/test cases/frameworks/6 gettext/po/intltest.pot +++ b/test cases/frameworks/6 gettext/po/intltest.pot @@ -32,3 +32,7 @@ msgstr "" #: data/test.desktop.in:5 msgid "Test Application" msgstr "" + +#: data/com.mesonbuild.test.dummy.metainfo.xml:19 +msgid "This is <code>text</code> with <em>embedded XML tags</em>. Nice!" +msgstr "" diff --git a/test cases/frameworks/6 gettext/po/meson.build b/test cases/frameworks/6 gettext/po/meson.build index 86e02f1..5510e42 100644 --- a/test cases/frameworks/6 gettext/po/meson.build +++ b/test cases/frameworks/6 gettext/po/meson.build @@ -1,3 +1,4 @@ langs = ['fi', 'de', 'ru'] -i18n.gettext('intltest', languages : langs) +gettext_targets = i18n.gettext('intltest', languages : langs) +mo_targets = gettext_targets[0] diff --git a/test cases/frameworks/6 gettext/test.json b/test cases/frameworks/6 gettext/test.json index df97430..910fc1c 100644 --- a/test cases/frameworks/6 gettext/test.json +++ b/test cases/frameworks/6 gettext/test.json @@ -11,7 +11,8 @@ {"type": "file", "file": "usr/share/applications/test3.desktop"}, {"type": "file", "file": "usr/share/applications/test4.desktop"}, {"type": "file", "file": "usr/share/applications/test5.desktop"}, - {"type": "file", "file": "usr/share/applications/test6.desktop"} + {"type": "file", "file": "usr/share/applications/test6.desktop"}, + {"type": "file", "file": "usr/share/metainfo/com.mesonbuild.test.intlprog.metainfo.xml"} ], "matrix": { "options": { |