[gnome-terminal] metainfo: Fix broken metainfo translations



commit dcb875efe36829c487a337a44d4bb116ab46c9f4
Author: Christian Persch <chpe src gnome org>
Date:   Mon Oct 10 20:26:42 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.
    
    Fixes: https://gitlab.gnome.org/GNOME/gnome-terminal/-/issues/356

 data/meson.build                                 | 18 ++++---
 data/metainfo.its                                | 60 ++++++++++++++++++++++++
 data/org.gnome.Terminal.Nautilus.metainfo.xml.in |  1 -
 data/org.gnome.Terminal.metainfo.xml.in          |  1 -
 meson.build                                      |  5 +-
 po/meson.build                                   |  4 +-
 6 files changed, 77 insertions(+), 12 deletions(-)
---
diff --git a/data/meson.build b/data/meson.build
index f53a0b5b..a9db7e2f 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -15,24 +15,30 @@
 
 # Appstream data
 
+metainfo_its = [
+  'metainfo.its',
+]
+
 metainfodir = gt_datadir / 'metainfo'
 
-i18n.merge_file(
+i18n.itstool_join(
   input: gt_dns_name + '.metainfo.xml.in',
-  output: '@BASENAME@',
-  po_dir: po_dir,
   install: true,
   install_dir: gt_prefix / metainfodir,
   install_tag: 'metadata',
+  its_files: metainfo_its,
+  mo_targets: gettext_targets[0],
+  output: '@BASENAME@',
 )
 
-i18n.merge_file(
+i18n.itstool_join(
   input: gt_dns_name + '.Nautilus.metainfo.xml.in',
-  output: '@BASENAME@',
-  po_dir: po_dir,
   install: true,
   install_dir: gt_prefix / 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/data/org.gnome.Terminal.Nautilus.metainfo.xml.in 
b/data/org.gnome.Terminal.Nautilus.metainfo.xml.in
index bce73491..84f4e254 100644
--- a/data/org.gnome.Terminal.Nautilus.metainfo.xml.in
+++ b/data/org.gnome.Terminal.Nautilus.metainfo.xml.in
@@ -30,7 +30,6 @@
 <component
   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";
   type="addon">
   <id>org.gnome.Terminal.Nautilus</id>
   <extends>org.gnome.Nautilus.desktop</extends>
diff --git a/data/org.gnome.Terminal.metainfo.xml.in b/data/org.gnome.Terminal.metainfo.xml.in
index 6a4e7de5..af850a77 100644
--- a/data/org.gnome.Terminal.metainfo.xml.in
+++ b/data/org.gnome.Terminal.metainfo.xml.in
@@ -30,7 +30,6 @@
 <component
   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";
   type="desktop-application">
   <id>org.gnome.Terminal.desktop</id>
   <metadata_license>GPL-3.0+ or GFDL-1.3-only</metadata_license>
diff --git a/meson.build b/meson.build
index 8f8ae38f..88f0557c 100644
--- a/meson.build
+++ b/meson.build
@@ -26,7 +26,7 @@ project(
     'GPL-3.0-only', 'CC-BY-SA-3.0', # the documentation
     'GFDL-1.3-only',                # the appstream data
   ],
-  meson_version: '>= 0.60.0',
+  meson_version: '>= 0.62.0',
   version: '3.47.1',
 )
 
@@ -107,7 +107,6 @@ pkg   = import('pkgconfig')
 # i18n
 
 gt_gettext_domain = gt_name
-po_dir = meson.current_source_dir() / 'po'
 
 # Compilers
 
@@ -380,8 +379,8 @@ xsltproc = find_program('xsltproc')
 # Subdirs
 
 subdir('src')
-subdir('data')
 subdir('po')
+subdir('data')
 
 if get_option('docs')
   subdir('help')
diff --git a/po/meson.build b/po/meson.build
index 0af089ff..4c0179d9 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(
   gt_gettext_domain,
   preset: 'glib',
 )


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