[gucharmap] metainfo: Fix broken metainfo translations



commit 100edba0d7f52ba4cd5f995e22f18485f46a7e26
Author: Christian Persch <chpe src gnome org>
Date:   Tue Oct 11 19:07:23 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/gucharmap.metainfo.xml.in |  4 +--
 data/meson.build               | 12 ++++++---
 data/metainfo.its              | 60 ++++++++++++++++++++++++++++++++++++++++++
 meson.build                    |  7 +++--
 po/meson.build                 |  6 +++--
 5 files changed, 77 insertions(+), 12 deletions(-)
---
diff --git a/data/gucharmap.metainfo.xml.in b/data/gucharmap.metainfo.xml.in
index 7092b328..0b3fb548 100644
--- a/data/gucharmap.metainfo.xml.in
+++ b/data/gucharmap.metainfo.xml.in
@@ -28,9 +28,7 @@
   If not, see <https://www.gnu.org/licenses/>.
 -->
 <component type="desktop-application"
-  xmlns="https://specifications.freedesktop.org/metainfo/1.0";
-  xmlns:xi="http://www.w3.org/2001/XInclude";
-  xmlns:its="http://www.w3.org/2005/11/its";>
+  xmlns="https://specifications.freedesktop.org/metainfo/1.0";>
   <id>gucharmap.desktop</id>
   <metadata_license>GPL-3.0+ or GFDL-1.3-only</metadata_license>
   <project_license>GPL-3.0+</project_license>
diff --git a/data/meson.build b/data/meson.build
index 4bd50014..13d9a81d 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -15,14 +15,20 @@
 
 # Appstream data
 
+metainfo_its = [
+  'metainfo.its',
+]
+
 metainfodir = gucharmap_prefix / gucharmap_datadir / 'metainfo'
 
-i18n.merge_file(
+i18n.itstool_join(
   input: 'gucharmap.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 d667fefa..f60160ca 100644
--- a/meson.build
+++ b/meson.build
@@ -19,11 +19,11 @@ project(
   default_options: [
     'buildtype=release',
     'c_std=gnu11',
-    'warning_level=' + (meson.version().version_compare('>= 0.50.0') ? '0' : '1'),
+    'warning_level=0',
     'b_ndebug=false',
   ],
   license: ['GPL-3.0-or-later',],
-  meson_version: '>= 0.49.0',
+  meson_version: '>= 0.62.0',
   version: '15.0.1',
 )
 
@@ -79,7 +79,6 @@ libgucharmap_gtk4_soversion = '0'
 # i18n
 
 gucharmap_gettext_domain = gucharmap_name
-po_dir = meson.current_source_dir() / 'po'
 
 # Directories
 
@@ -262,9 +261,9 @@ configure_file(
 
 top_inc = include_directories('.')
 
+subdir('po')
 subdir('data')
 subdir('gucharmap')
-subdir('po')
 
 if get_option('docs')
   subdir('docs' / 'reference')
diff --git a/po/meson.build b/po/meson.build
index a9695d20..aaf169a6 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() / 'po'
+
+gettext_targets = i18n.gettext(
   gucharmap_gettext_domain,
   preset: 'glib',
-)
\ No newline at end of file
+)


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