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
This commit is contained in:
Corentin Noël 2018-07-25 18:26:07 +02:00 committed by Nirbheek Chauhan
parent c54cd69015
commit 176af2c8c3
4 changed files with 42 additions and 2 deletions

View File

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

View File

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

View File

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

View File

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