From 82f3e6bc3cb1bdc166f208f3fa6f49385f41a930 Mon Sep 17 00:00:00 2001 From: Nils Philippsen Date: Fri, 6 Nov 2015 16:57:39 +0100 Subject: [PATCH] Implement translation of AppData file. Use the ITS rules file from KDE for itstool: https://websvn.kde.org/trunk/l10n-kf5/scripts/as-metainfo.its?revision=1395611&view=markup --- ...ppdata.xml.in => ardour.appdata.xml.in.in} | 0 gtk2_ardour/wscript | 41 ++++++++++++++++++- tools/as-metainfo.its | 8 ++++ 3 files changed, 48 insertions(+), 1 deletion(-) rename gtk2_ardour/{ardour.appdata.xml.in => ardour.appdata.xml.in.in} (100%) create mode 100644 tools/as-metainfo.its diff --git a/gtk2_ardour/ardour.appdata.xml.in b/gtk2_ardour/ardour.appdata.xml.in.in similarity index 100% rename from gtk2_ardour/ardour.appdata.xml.in rename to gtk2_ardour/ardour.appdata.xml.in.in diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index 008fa1eae4..a6c0af1a12 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -9,6 +9,8 @@ import re import time from waflib.Task import Task from waflib.Tools import winres +import subprocess +import glob # Mandatory variables top = '.' @@ -688,9 +690,12 @@ def build(bld): obj.target = 'ardour.xml' obj.chmod = Utils.O644 + # build appdata with translations + appdata_i18n_mo(bld) + appdata_i18n_xmlin(bld) obj = bld(features = 'subst') obj.source = 'ardour.appdata.xml.in' - obj.target = str (bld.env['lwrcase_dirname']) + '.appdata.xml' + obj.target = str (bld.env['lwrcase_dirname']) + '.appdata.xml' obj.chmod = Utils.O644 obj.dict = freedesktop_subst_dict set_subst_dict(obj, freedesktop_subst_dict) @@ -750,18 +755,52 @@ def i18n(bld): I18N_PACKAGE = 'gtk2_ardour' + bld.env['MAJOR'] autowaf.build_i18n(bld, top, 'gtk2_ardour', I18N_PACKAGE, gtk2_ardour_sources, 'Paul Davis') + appdata_i18n_pot(bld) + appdata_i18n_po(bld) def i18n_pot(bld): I18N_PACKAGE = 'gtk2_ardour' + bld.env['MAJOR'] autowaf.build_i18n_pot(bld, top, 'gtk2_ardour', I18N_PACKAGE, gtk2_ardour_sources, 'Paul Davis') + appdata_i18n_pot(bld) def i18n_po(bld): I18N_PACKAGE = 'gtk2_ardour' + bld.env['MAJOR'] autowaf.build_i18n_po(bld, top, 'gtk2_ardour', I18N_PACKAGE, gtk2_ardour_sources, 'Paul Davis') + appdata_i18n_po(bld) def i18n_mo(bld): I18N_PACKAGE = 'gtk2_ardour' + bld.env['MAJOR'] autowaf.build_i18n_mo(bld, top, 'gtk2_ardour', I18N_PACKAGE, gtk2_ardour_sources, 'Paul Davis') + +def appdata_i18n_pot(bld): + Logs.info('Generating pot file from Ardour appdata') + itsfile = os.path.join(bld.top_dir, 'tools', 'as-metainfo.its') + potfile = os.path.join(bld.top_dir, 'gtk2_ardour', 'appdata', + 'ardour.appdata.pot') + adsource = os.path.join(bld.top_dir, 'gtk2_ardour', + 'ardour.appdata.xml.in.in') + Logs.info('Updating ' + potfile) + subprocess.call(('itstool', '-i', itsfile, '-o', potfile, adsource)) + +def appdata_i18n_po(bld): + autowaf.build_i18n_po(bld, bld.top_dir, os.path.join( + 'gtk2_ardour', 'appdata'), 'ardour.appdata', 'dummy', 'dummy') + +def appdata_i18n_mo(bld): + autowaf.build_i18n_mo(bld, bld.top_dir, os.path.join( + 'gtk2_ardour', 'appdata'), 'ardour.appdata', 'dummy', 'dummy') + +def appdata_i18n_xmlin(bld): + itsfile = os.path.join(bld.top_dir, 'tools', 'as-metainfo.its') + adxmlininfile = os.path.join(bld.top_dir, 'gtk2_ardour', + 'ardour.appdata.xml.in.in') + adxmlinfile = os.path.join(bld.top_dir, 'gtk2_ardour', + 'ardour.appdata.xml.in') + mo_glob = os.path.join(bld.top_dir, 'gtk2_ardour', 'appdata', 'po', '*.mo') + mo_files = glob.glob(mo_glob) + Logs.info('Generating ' + adxmlinfile) + subprocess.call(['itstool', '-i', itsfile, '-o', adxmlinfile, + '-j', adxmlininfile] + mo_files) diff --git a/tools/as-metainfo.its b/tools/as-metainfo.its new file mode 100644 index 0000000000..d2530d40c9 --- /dev/null +++ b/tools/as-metainfo.its @@ -0,0 +1,8 @@ + + + +