aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorentin Noël <corentin@elementary.io>2018-07-25 18:26:07 +0200
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2018-09-03 22:34:22 -0700
commit176af2c8c33e79732680ebb1e2a25b5cd7a51bb9 (patch)
treea1e844d4a9c7d291341ee5c391602d3756086fef
parentc54cd69015b68b2ee583787036cba90420b6d6d8 (diff)
downloadmeson-176af2c8c33e79732680ebb1e2a25b5cd7a51bb9.zip
meson-176af2c8c33e79732680ebb1e2a25b5cd7a51bb9.tar.gz
meson-176af2c8c33e79732680ebb1e2a25b5cd7a51bb9.tar.bz2
i18n: respect variable substitution for the target name when merging translations
Previously it wasn't possible to use twice @BASENAME@ as the targets would then be named @BASENAME@_merge
-rw-r--r--mesonbuild/modules/i18n.py14
-rw-r--r--test cases/frameworks/6 gettext/data/meson.build22
-rw-r--r--test cases/frameworks/6 gettext/data/test2.desktop.in6
-rw-r--r--test cases/frameworks/6 gettext/installed_files.txt2
4 files changed, 42 insertions, 2 deletions
diff --git a/mesonbuild/modules/i18n.py b/mesonbuild/modules/i18n.py
index b44fbea..40f73f7 100644
--- a/mesonbuild/modules/i18n.py
+++ b/mesonbuild/modules/i18n.py
@@ -80,7 +80,19 @@ class I18nModule(ExtensionModule):
command.append(datadirs)
kwargs['command'] = command
- ct = build.CustomTarget(kwargs['output'] + '_merge', state.subdir, state.subproject, kwargs)
+
+ inputfile = kwargs['input']
+ if isinstance(inputfile, str):
+ inputfile = mesonlib.File.from_source_file(state.environment.source_dir,
+ state.subdir, inputfile)
+ output = kwargs['output']
+ ifile_abs = inputfile.absolute_path(state.environment.source_dir,
+ state.environment.build_dir)
+ values = mesonlib.get_filenames_templates_dict([ifile_abs], None)
+ outputs = mesonlib.substitute_values([output], values)
+ output = outputs[0]
+
+ ct = build.CustomTarget(output + '_merge', state.subdir, state.subproject, kwargs)
return ModuleReturnValue(ct, [ct])
@FeatureNewKwargs('i18n.gettext', '0.37.0', ['preset'])
diff --git a/test cases/frameworks/6 gettext/data/meson.build b/test cases/frameworks/6 gettext/data/meson.build
index d927ba3..a6b0a8b 100644
--- a/test cases/frameworks/6 gettext/data/meson.build
+++ b/test cases/frameworks/6 gettext/data/meson.build
@@ -1,6 +1,26 @@
+# Use filename substitution
i18n.merge_file(
input: 'test.desktop.in',
- output: 'test.desktop',
+ output: '@BASENAME@',
+ type: 'desktop',
+ po_dir: '../po',
+ install: true,
+ install_dir: join_paths(get_option('datadir'), 'applications')
+)
+
+# Use filename substitution for another file
+i18n.merge_file(
+ input: '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,
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..41f931c
--- /dev/null
+++ b/test cases/frameworks/6 gettext/data/test2.desktop.in
@@ -0,0 +1,6 @@
+[Desktop Entry]
+Name=Test 2
+GenericName=Application
+Comment=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 879f56b..9298909 100644
--- a/test cases/frameworks/6 gettext/installed_files.txt
+++ b/test cases/frameworks/6 gettext/installed_files.txt
@@ -2,3 +2,5 @@ usr/bin/intlprog?exe
usr/share/locale/de/LC_MESSAGES/intltest.mo
usr/share/locale/fi/LC_MESSAGES/intltest.mo
usr/share/applications/test.desktop
+usr/share/applications/test2.desktop
+usr/share/applications/test3.desktop