diff options
Diffstat (limited to 'test cases/frameworks/6 gettext')
28 files changed, 466 insertions, 0 deletions
diff --git a/test cases/frameworks/6 gettext/data/data3/meson.build b/test cases/frameworks/6 gettext/data/data3/meson.build new file mode 100644 index 0000000..044b498 --- /dev/null +++ b/test cases/frameworks/6 gettext/data/data3/meson.build @@ -0,0 +1,9 @@ +# Target name will contain a path separator +i18n.merge_file( + input: 'test.desktop.in', + output: 'test4.desktop', + type: 'desktop', + po_dir: '../../po', + install: true, + install_dir: join_paths(get_option('datadir'), 'applications') +) diff --git a/test cases/frameworks/6 gettext/data/data3/test.desktop.in b/test cases/frameworks/6 gettext/data/data3/test.desktop.in new file mode 100644 index 0000000..35edf07 --- /dev/null +++ b/test cases/frameworks/6 gettext/data/data3/test.desktop.in @@ -0,0 +1,5 @@ +[Desktop Entry] +Name=Test +GenericName=Application +Comment=Test Application +Type=Application diff --git a/test cases/frameworks/6 gettext/data/meson.build b/test cases/frameworks/6 gettext/data/meson.build new file mode 100644 index 0000000..698eeec --- /dev/null +++ b/test cases/frameworks/6 gettext/data/meson.build @@ -0,0 +1,59 @@ +# Use filename substitution +i18n.merge_file( + input: 'test.desktop.in', + output: '@BASENAME@', + type: 'desktop', + po_dir: '../po', + data_dirs: '../po', + install: true, + install_dir: join_paths(get_option('datadir'), 'applications') +) + +# Use filename substitution for another file +i18n.merge_file( + input: files('test2.desktop.in'), + output: '@BASENAME@', + type: 'desktop', + po_dir: '../po', + install: true, + install_dir: join_paths(get_option('datadir'), 'applications') +) + +i18n.merge_file( + input: 'test.desktop.in', + output: 'test3.desktop', + type: 'desktop', + po_dir: '../po', + install: true, + install_dir: join_paths(get_option('datadir'), 'applications') +) + +# Regression test when passing File object as input and '@BASENAME@' as output +# in multiple i18n.merge_file() calls. It used to make target name collision. +# https://github.com/mesonbuild/meson/issues/9022 +i18n.merge_file( + input: configure_file( + input: 'test5.desktop.in.in', + output: '@BASENAME@', + configuration: { 'NAME': 'Application' }, + ), + output: '@BASENAME@', + type: 'desktop', + po_dir: '../po', + install: true, + install_dir: join_paths(get_option('datadir'), 'applications') +) +i18n.merge_file( + input: configure_file( + input: 'test6.desktop.in.in', + output: '@BASENAME@', + configuration: { 'NAME': 'Application' }, + ), + output: '@BASENAME@', + type: 'desktop', + po_dir: '../po', + install: true, + install_dir: join_paths(get_option('datadir'), 'applications') +) + +subdir('data3') diff --git a/test cases/frameworks/6 gettext/data/test.desktop.in b/test cases/frameworks/6 gettext/data/test.desktop.in new file mode 100644 index 0000000..35edf07 --- /dev/null +++ b/test cases/frameworks/6 gettext/data/test.desktop.in @@ -0,0 +1,5 @@ +[Desktop Entry] +Name=Test +GenericName=Application +Comment=Test Application +Type=Application diff --git a/test cases/frameworks/6 gettext/data/test2.desktop.in b/test cases/frameworks/6 gettext/data/test2.desktop.in new file mode 100644 index 0000000..23be0a4 --- /dev/null +++ b/test cases/frameworks/6 gettext/data/test2.desktop.in @@ -0,0 +1,5 @@ +[Desktop Entry] +Name=Test 2 +GenericName=Application +Comment=Test Application +Type=Application diff --git a/test cases/frameworks/6 gettext/data/test5.desktop.in.in b/test cases/frameworks/6 gettext/data/test5.desktop.in.in new file mode 100644 index 0000000..a401e36 --- /dev/null +++ b/test cases/frameworks/6 gettext/data/test5.desktop.in.in @@ -0,0 +1,5 @@ +[Desktop Entry] +Name=Test 2 +GenericName=@NAME@ +Comment=Test Application +Type=Application diff --git a/test cases/frameworks/6 gettext/data/test6.desktop.in.in b/test cases/frameworks/6 gettext/data/test6.desktop.in.in new file mode 100644 index 0000000..a401e36 --- /dev/null +++ b/test cases/frameworks/6 gettext/data/test6.desktop.in.in @@ -0,0 +1,5 @@ +[Desktop Entry] +Name=Test 2 +GenericName=@NAME@ +Comment=Test Application +Type=Application diff --git a/test cases/frameworks/6 gettext/data2/meson.build b/test cases/frameworks/6 gettext/data2/meson.build new file mode 100644 index 0000000..9a992c9 --- /dev/null +++ b/test cases/frameworks/6 gettext/data2/meson.build @@ -0,0 +1,10 @@ +i18n.merge_file( + input: 'test.desktop.in', + output: 'test.plugin', + type: 'desktop', + po_dir: '../po', + data_dirs: '../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 new file mode 100644 index 0000000..b57ba21 --- /dev/null +++ b/test cases/frameworks/6 gettext/data2/test.desktop.in @@ -0,0 +1,5 @@ +[Desktop Entry] +Name=Test +GenericName=Application +Description=Test Application +Type=Application 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/generated/desktopgenerator.py b/test cases/frameworks/6 gettext/generated/desktopgenerator.py new file mode 100644 index 0000000..e49c2d6 --- /dev/null +++ b/test cases/frameworks/6 gettext/generated/desktopgenerator.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 + +import os, sys, shutil + +ifile = sys.argv[1] +ofile = sys.argv[2] + +try: + os.unlink(ofile) +except FileNotFoundError: + pass + +shutil.copy(ifile, ofile) diff --git a/test cases/frameworks/6 gettext/generated/meson.build b/test cases/frameworks/6 gettext/generated/meson.build new file mode 100644 index 0000000..5ed9205 --- /dev/null +++ b/test cases/frameworks/6 gettext/generated/meson.build @@ -0,0 +1,16 @@ +dgen = find_program('desktopgenerator.py') + +desktop_in_file = custom_target('something.desktop.in', + input : ['something.desktop.in.in'], + output : 'something.desktop.in', + command : [dgen, '@INPUT@', '@OUTPUT@'], +) + +i18n.merge_file( + input : desktop_in_file, + output : 'something.desktop', + type : 'desktop', + po_dir : '../po', + install: true, + install_dir: join_paths(get_option('datadir'), 'applications'), +) diff --git a/test cases/frameworks/6 gettext/generated/something.desktop.in.in b/test cases/frameworks/6 gettext/generated/something.desktop.in.in new file mode 100644 index 0000000..e2094fd --- /dev/null +++ b/test cases/frameworks/6 gettext/generated/something.desktop.in.in @@ -0,0 +1,15 @@ +[Desktop Entry] +Name=Something doer +Comment=Do something +# Translators: Search terms to find this application. Do NOT translate or localize the semicolons! The list MUST also end with a semicolon! +Keywords=zip;tar;extract;unpack; +TryExec=file-roller +Exec=file-roller %U +StartupNotify=true +Terminal=false +Type=Application +# Translators: Do NOT translate or transliterate this text (this is an icon file name)! +Icon=something +Categories=GTK;GNOME;Utility +X-GNOME-DocPath=file-roller/file-roller.xml +X-GNOME-UsesNotifications=true diff --git a/test cases/frameworks/6 gettext/meson.build b/test cases/frameworks/6 gettext/meson.build new file mode 100644 index 0000000..ce99242 --- /dev/null +++ b/test cases/frameworks/6 gettext/meson.build @@ -0,0 +1,27 @@ +project('gettext example', 'c') + +gettext = find_program('gettext', required: false) +if not gettext.found() + error('MESON_SKIP_TEST gettext not found.') +endif + +xgettext = find_program('xgettext', required: false) +if not xgettext.found() + error('MESON_SKIP_TEST xgettext not found.') +endif + +intl = dependency('intl', required: false, static: get_option('static')) +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/meson_options.txt b/test cases/frameworks/6 gettext/meson_options.txt new file mode 100644 index 0000000..f41ed25 --- /dev/null +++ b/test cases/frameworks/6 gettext/meson_options.txt @@ -0,0 +1 @@ +option('static', type : 'boolean', value : false, description : 'build statically linked binaries') diff --git a/test cases/frameworks/6 gettext/po/LINGUAS b/test cases/frameworks/6 gettext/po/LINGUAS new file mode 100644 index 0000000..4cde210 --- /dev/null +++ b/test cases/frameworks/6 gettext/po/LINGUAS @@ -0,0 +1,3 @@ +de +fi +ru diff --git a/test cases/frameworks/6 gettext/po/POTFILES b/test cases/frameworks/6 gettext/po/POTFILES new file mode 100644 index 0000000..8ac0de5 --- /dev/null +++ b/test cases/frameworks/6 gettext/po/POTFILES @@ -0,0 +1,2 @@ +src/intlmain.c +data/test.desktop.in diff --git a/test cases/frameworks/6 gettext/po/de.po b/test cases/frameworks/6 gettext/po/de.po new file mode 100644 index 0000000..1e4693b --- /dev/null +++ b/test cases/frameworks/6 gettext/po/de.po @@ -0,0 +1,26 @@ +# German translations for PACKAGE package. +# Copyright (C) 2013 THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# Jussi Pakkanen <jpakkane@brash>, 2013. +# +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-09-12 18:53+0300\n" +"PO-Revision-Date: 2013-09-12 18:57+0300\n" +"Last-Translator: Jussi Pakkanen <jpakkane@brash>\n" +"Language-Team: German\n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ASCII\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: 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/fi.po b/test cases/frameworks/6 gettext/po/fi.po new file mode 100644 index 0000000..114cb10 --- /dev/null +++ b/test cases/frameworks/6 gettext/po/fi.po @@ -0,0 +1,22 @@ +# Finnish translations for PACKAGE package. +# Copyright (C) 2013 THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# Jussi Pakkanen <jpakkane@brash>, 2013. +# +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-09-12 18:53+0300\n" +"PO-Revision-Date: 2013-09-12 18:57+0300\n" +"Last-Translator: Jussi Pakkanen <jpakkane@brash>\n" +"Language-Team: Finnish\n" +"Language: fi\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ASCII\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: src/intlmain.c:15 +msgid "International greeting." +msgstr "Maailman tervehdys." diff --git a/test cases/frameworks/6 gettext/po/intltest.pot b/test cases/frameworks/6 gettext/po/intltest.pot new file mode 100644 index 0000000..c34e7f9 --- /dev/null +++ b/test cases/frameworks/6 gettext/po/intltest.pot @@ -0,0 +1,38 @@ +# 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. +# +#, fuzzy +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: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: LANGUAGE <LL@li.org>\n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\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 "" + +#: 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 new file mode 100644 index 0000000..5510e42 --- /dev/null +++ b/test cases/frameworks/6 gettext/po/meson.build @@ -0,0 +1,4 @@ +langs = ['fi', 'de', 'ru'] + +gettext_targets = i18n.gettext('intltest', languages : langs) +mo_targets = gettext_targets[0] 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 <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 "Тестовое приложение" diff --git a/test cases/frameworks/6 gettext/src/intlmain.c b/test cases/frameworks/6 gettext/src/intlmain.c new file mode 100644 index 0000000..bd7af6f --- /dev/null +++ b/test cases/frameworks/6 gettext/src/intlmain.c @@ -0,0 +1,17 @@ +#include<libintl.h> +#include<locale.h> +#include<stdio.h> + +#define _(String) gettext (String) + +#define PACKAGE "intltest" +// WRONG, but enough for this test. +#define LOCALEDIR "/usr/share/locale" + +int main(int argc, char **argv) { + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + printf("%s\n", _("International greeting.")); + return 0; +} diff --git a/test cases/frameworks/6 gettext/src/meson.build b/test cases/frameworks/6 gettext/src/meson.build new file mode 100644 index 0000000..cda3ea4 --- /dev/null +++ b/test cases/frameworks/6 gettext/src/meson.build @@ -0,0 +1,2 @@ +executable('intlprog', 'intlmain.c', install : true, + dependencies : intl) diff --git a/test cases/frameworks/6 gettext/test.json b/test cases/frameworks/6 gettext/test.json new file mode 100644 index 0000000..910fc1c --- /dev/null +++ b/test cases/frameworks/6 gettext/test.json @@ -0,0 +1,26 @@ +{ + "installed": [ + {"type": "exe", "file": "usr/bin/intlprog"}, + {"type": "file", "file": "usr/share/locale/de/LC_MESSAGES/intltest.mo"}, + {"type": "file", "file": "usr/share/locale/fi/LC_MESSAGES/intltest.mo"}, + {"type": "file", "file": "usr/share/locale/ru/LC_MESSAGES/intltest.mo"}, + {"type": "file", "file": "usr/share/applications/something.desktop"}, + {"type": "file", "file": "usr/share/applications/test.desktop"}, + {"type": "file", "file": "usr/share/applications/test.plugin"}, + {"type": "file", "file": "usr/share/applications/test2.desktop"}, + {"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/metainfo/com.mesonbuild.test.intlprog.metainfo.xml"} + ], + "matrix": { + "options": { + "static": [ + { "val": "true" }, + { "val": "false" } + ] + } + }, + "skip_on_jobname": ["azure", "cygwin"] +} |