[aisleriot] metainfo: Fix broken metainfo translations



commit 8521cdbc77c563f5d6df45f65cd377ad8294dff4
Author: Christian Persch <chpe src gnome org>
Date:   Tue Oct 11 20:52:18 2022 +0200

    metainfo: Fix broken metainfo translations
    
    Work around gettext bug https://savannah.gnu.org/bugs/?54472 by running
    itstool directly with a custom metainfo.its file that's been copied from
    appstream's master copy and modified to fix the xml namespace bug.
    
    This increases the required meson version to 0.62.

 data/meson.build  | 12 ++++++++---
 data/metainfo.its | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 meson.build       |  7 +++----
 po/meson.build    |  4 +++-
 4 files changed, 75 insertions(+), 8 deletions(-)
---
diff --git a/data/meson.build b/data/meson.build
index c97e0b2e..7c5f31e5 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -15,14 +15,20 @@
 
 # Appstream data
 
+metainfo_its = [
+  'metainfo.its',
+]
+
 metainfodir = ar_prefix / ar_datadir / 'metainfo'
 
-i18n.merge_file(
+i18n.itstool_join(
   input: 'sol.metainfo.xml.in',
-  output: '@BASENAME@',
-  po_dir: po_dir,
   install: true,
   install_dir: metainfodir,
+  install_tag: 'metadata',
+  its_files: metainfo_its,
+  mo_targets: gettext_targets[0],
+  output: '@BASENAME@',
 )
 
 # Desktop file
diff --git a/data/metainfo.its b/data/metainfo.its
new file mode 100644
index 00000000..d2e3efe0
--- /dev/null
+++ b/data/metainfo.its
@@ -0,0 +1,60 @@
+<?xml version="1.0"?>
+<!--
+  Copyright © 2015-2022 Matthias Klumpp <matthias tenstral net>
+  Copyright © 2019 Takao Fujiwara <takao fujiwara1 gmail com>
+
+  Copying and distribution of this file, with or without modification,
+  are permitted in any medium without royalty provided the copyright
+  notice and this notice are preserved.  This file is offered as-is,
+  without any warranty.
+-->
+<its:rules xmlns:its="http://www.w3.org/2005/11/its";
+           xmlns:mi="https://specifications.freedesktop.org/metainfo/1.0";
+           version="2.0">
+
+  <its:translateRule selector="/mi:component" translate="no"
+                     xmlns:mi="https://specifications.freedesktop.org/metainfo/1.0"/>
+  <its:translateRule selector="/mi:component/mi:name |
+                               /mi:component/mi:summary |
+                               /mi:component/mi:description |
+                               /mi:component/mi:developer_name |
+                               /mi:component/mi:name_variant_suffix |
+                               /mi:component/mi:keywords/mi:keyword |
+                               /mi:component/mi:screenshots/mi:screenshot/mi:caption |
+                               /mi:component/mi:releases/mi:release/mi:description |
+                               /mi:component/mi:agreement/mi:agreement_section/mi:name |
+                               /mi:component/mi:agreement/mi:agreement_section/mi:description"
+                     translate="yes"
+                     xmlns:mi="https://specifications.freedesktop.org/metainfo/1.0"/>
+
+  <its:withinTextRule withinText="yes" selector="/mi:component//mi:description//mi:em |
+                                                 /mi:component//mi:description//mi:code"
+                      xmlns:mi="https://specifications.freedesktop.org/metainfo/1.0"/>
+
+  <its:translateRule selector="/mi:component/mi:name[@translate = 'no']"
+                     translate="no"
+                     xmlns:mi="https://specifications.freedesktop.org/metainfo/1.0"/>
+  <its:translateRule selector="/mi:component/mi:developer_name[@translate = 'no']"
+                     translate="no"
+                     xmlns:mi="https://specifications.freedesktop.org/metainfo/1.0"/>
+  <its:translateRule selector="/mi:component/mi:name_variant_suffix[@translate = 'no']"
+                     translate="no"
+                     xmlns:mi="https://specifications.freedesktop.org/metainfo/1.0"/>
+  <its:translateRule selector="/mi:component/mi:keywords/mi:keyword[@translate = 'no']"
+                     translate="no"
+                     xmlns:mi="https://specifications.freedesktop.org/metainfo/1.0"/>
+  <its:translateRule selector="/mi:component/mi:releases/mi:release/mi:description[@translate = 'no']"
+                     translate="no"
+                     xmlns:mi="https://specifications.freedesktop.org/metainfo/1.0"/>
+
+  <!-- DEPRECATED -->
+  <its:translateRule selector="/mi:component/mi:name[@translatable = 'no']"
+                     translate="no"
+                     xmlns:mi="https://specifications.freedesktop.org/metainfo/1.0"/>
+  <its:translateRule selector="/mi:component/mi:developer_name[@translatable = 'no']"
+                     translate="no"
+                     xmlns:mi="https://specifications.freedesktop.org/metainfo/1.0"/>
+  <its:translateRule selector="/mi:component/mi:releases/mi:release/mi:description[@translatable = 'no']"
+                     translate="no"
+                     xmlns:mi="https://specifications.freedesktop.org/metainfo/1.0"/>
+</its:rules>
diff --git a/meson.build b/meson.build
index 2f59d3bd..f4bf9811 100644
--- a/meson.build
+++ b/meson.build
@@ -20,7 +20,7 @@ project(
     'buildtype=release',
     'c_std=gnu11',
     'cpp_std=gnu++11',
-    'warning_level=' + (meson.version().version_compare('>= 0.50.0') ? '0' : '1'),
+    'warning_level=0',
     'b_ndebug=false',
   ],
   license: [
@@ -29,7 +29,7 @@ project(
     'GFDL-1.1-or-later',
     'GFDL-1.3-only',
   ],
-  meson_version: '>= 0.49.0',
+  meson_version: '>= 0.62.0',
   version: '3.22.25',
 )
 
@@ -63,7 +63,6 @@ ar_micro_version = version_split[2].to_int()
 # i18n
 
 ar_gettext_domain = ar_name
-po_dir = meson.current_source_dir() / 'po'
 
 # Directories
 
@@ -439,10 +438,10 @@ configure_file(
 
 top_inc = include_directories('.')
 
+subdir('po')
 subdir('data')
 subdir('games')
 subdir('src')
-subdir('po')
 
 if get_option('docs')
   subdir('help')
diff --git a/po/meson.build b/po/meson.build
index c808c284..16291907 100644
--- a/po/meson.build
+++ b/po/meson.build
@@ -13,7 +13,9 @@
 # You should have received a copy of the GNU General Public License
 # along with this programme.  If not, see <https://www.gnu.org/licenses/>.
 
-i18n.gettext(
+po_dir = meson.current_source_dir()
+
+gettext_targets = i18n.gettext(
   ar_gettext_domain,
   args: [
     '--keyword=G_',


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]