If you are a maintainer, you will want to minimize the number of tests that
are skipped. To this effect, you need to install also:
+ * The xmllint program
+ + Homepage: https://gitlab.gnome.org/GNOME/libxml2/-/wikis/home
+ + Pre-built package name:
+ - On Debian and Debian-based systems: libxml2-utils,
+ - On Red Hat distributions: libxml2.
+ - Other: https://repology.org/project/libxml2/versions
+
* A C++ compiler
+ Homepage: https://gcc.gnu.org/
+ Pre-built package name:
Version 0.23 - September 2024
* Programming languages support:
+ - XML: XML schemas for .its and .loc files are now provided.
- Python:
o xgettext now assumes source code for Python 3 rather than Python 2.
This affects the interpretation of escape sequences in string literals.
$prefix/share/gettext/config.rpath
$prefix/share/gettext/po/*
$prefix/share/gettext/projects/*
+ $prefix/share/gettext/schema/*
$prefix/share/gettext/styles/*
$prefix/share/gettext/gettext.h
$prefix/share/gettext/gettext.jar
dnl We execute these tests if and only if we don't install our own libintl.
AM_CONDITIONAL([TEST_SYSTEM_LIBINTL], [test $USE_INCLUDED_LIBINTL = no])
+dnl Checks for optional programs for the its/* tests.
+AC_PATH_PROGS([XMLLINT], [xmllint], [:])
+
AC_CONFIG_SUBDIRS([examples])
AC_CONFIG_FILES([Makefile],
* AppData:: AppData - freedesktop.org application description
* Preparing ITS Rules:: Preparing Rules for XML Internationalization
+Preparing Rules for XML Internationalization
+
+* ITS Rules:: Specifying ITS Rules
+* Locating Rules:: Specifying where to find the ITS Rules
+
Localized Data Formats
* Editable Message Catalogs:: Editable Message Catalogs
@subsection Preparing Rules for XML Internationalization
@cindex preparing rules for XML translation
+@menu
+* ITS Rules:: Specifying ITS Rules
+* Locating Rules:: Specifying where to find the ITS Rules
+@end menu
+
+@node ITS Rules
+@subsubsection Specifying ITS Rules
+
Marking translatable strings in an XML file is done through a separate
"rule" file, making use of the Internationalization Tag Set standard
(ITS, @uref{https://www.w3.org/TR/its20/}). The currently supported ITS
</its:rules>
@end example
-@samp{xgettext} needs another file called "locating rule" to associate
+ITS rules files must have the @file{.its} file extension and obey
+the XML schema encoded by
+@code{its.xsd} and its auxiliary schema @code{its-extensions.xsd}.
+
+@node Locating Rules
+@subsubsection Specifying where to find the ITS Rules
+
+@samp{xgettext} needs another file called "locating rules" to associate
an ITS rule with an XML file. If the above ITS file is saved as
-@file{messages.its}, the locating rule would look like:
+@file{messages.its}, the locating rules file would look like:
@example
<?xml version="1.0"?>
The first rule matches any file with the @file{.xml} file extension, but
it only applies to XML files whose root element is @samp{<messages>}.
-The second rule indicates that the same ITS rule file are also
+The second rule indicates that the same ITS rules file are also
applicable to any file with the @file{.msg} file extension. The
optional @code{name} attribute of @code{locatingRule} allows to choose
rules by name, typically with @code{xgettext}'s @code{-L} option.
-The associated ITS rule file is indicated by the @code{target} attribute
+The associated ITS rules file is indicated by the @code{target} attribute
of @code{locatingRule} or @code{documentRule}. If it is specified in a
@code{documentRule} element, the parent @code{locatingRule} shouldn't
have the @code{target} attribute.
-Locating rule files must have the @file{.loc} file extension. Both ITS
-rule files and locating rule files must be installed in the
+Locating rules files must have the @file{.loc} file extension and obey
+the XML schema encoded by @code{locating-rules.xsd}.
+Both ITS rules files and locating rules files must be installed in the
@file{$prefix/share/gettext/its} directory. Once those files are
properly installed, @code{xgettext} can extract translatable strings
from the matching XML files.
## Makefile for the gettext-tools/its subdirectory of GNU gettext
-## Copyright (C) 2015, 2017 Free Software Foundation, Inc.
+## Copyright (C) 2015-2024 Free Software Foundation, Inc.
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
pkgdatadir = $(datadir)/gettext
itsdir = $(pkgdatadir)$(PACKAGE_SUFFIX)/its
-dist_its_DATA = glade.loc glade1.its glade2.its gtkbuilder.its \
-gsettings.loc gsettings.its metainfo.loc metainfo.its
+
+ITS_FILES = \
+ glade1.its glade2.its gtkbuilder.its \
+ gsettings.its \
+ metainfo.its
+
+LOC_FILES = \
+ glade.loc \
+ gsettings.loc \
+ metainfo.loc
+
+dist_its_DATA = $(ITS_FILES) $(LOC_FILES)
+
+# Checks the XML files against their schemas.
+check-local:
+ @for file in $(ITS_FILES); do \
+ echo "Checking $$file..."; \
+ echo "$(XMLLINT) --noout --schema $(top_srcdir)/src/its.xsd $(srcdir)/$$file"; \
+ $(XMLLINT) --noout --schema $(top_srcdir)/src/its.xsd $(srcdir)/$$file || exit 1; \
+ done
+ @for file in $(LOC_FILES); do \
+ echo "Checking $$file..."; \
+ echo "$(XMLLINT) --noout --schema $(top_srcdir)/src/locating-rules.xsd $(srcdir)/$$file"; \
+ $(XMLLINT) --noout --schema $(top_srcdir)/src/locating-rules.xsd $(srcdir)/$$file || exit 1; \
+ done
jardir = $(datadir)/gettext
pkgdatadir = $(datadir)/gettext
projectsdir = $(pkgdatadir)/projects
+schemadir = $(pkgdatadir)/schema
pkglibdir = $(libdir)/gettext
pkglibexecdir = $(libexecdir)/gettext
$(RM) $(DESTDIR)$(pkgdatadir)/msgunfmt.tcl
+# Special rules for XML schemas.
+
+schema_DATA = \
+ its.xsd its-extensions.xsd \
+ locating-rules.xsd
+EXTRA_DIST += $(schema_DATA)
+
+
# Support for relocatability.
RELOCATABLE_LIBRARY_PATH = $(libdir)
RELOCATABLE_SRC_DIR = $(top_srcdir)/gnulib-lib
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<schema targetNamespace="https://www.gnu.org/s/gettext/ns/its/extensions/1.0" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:gt="https://www.gnu.org/s/gettext/ns/its/extensions/1.0" elementFormDefault="qualified">
+
+ <annotation>
+ <documentation>XML schema extensions for *.its files, as understood by GNU gettext.
+
+Copyright (C) 2015-2024 Free Software Foundation, Inc.
+
+This file is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published
+by the Free Software Foundation, either version 3 of the License,
+or (at your option) any later version.
+
+This file is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+Written by Bruno Haible <bruno@clisp.org>, 2024.
+</documentation>
+ </annotation>
+
+ <element name="preserveSpaceRule" type="gt:ExtendedPreserveSpaceRuleType"></element>
+ <element name="contextRule" type="gt:ContextRuleType"></element>
+ <element name="escapeRule" type="gt:EscapeRuleType"></element>
+
+ <complexType name="ExtendedPreserveSpaceRuleType">
+ <attribute name="selector" type="string" use="required"></attribute>
+ <attribute name="space" use="required">
+ <simpleType>
+ <restriction base="string">
+ <enumeration value="preserve"></enumeration>
+ <enumeration value="default"></enumeration>
+ <enumeration value="trim"></enumeration>
+ <enumeration value="paragraph"></enumeration>
+ </restriction>
+ </simpleType>
+ </attribute>
+ </complexType>
+
+ <complexType name="ContextRuleType">
+ <attribute name="selector" type="string" use="required"></attribute>
+ <attribute name="contextPointer" type="string" use="required"></attribute>
+ <attribute name="textPointer" type="string" use="optional"></attribute>
+ </complexType>
+
+ <complexType name="EscapeRuleType">
+ <attribute name="selector" type="string" use="required"></attribute>
+ <attribute name="escape" type="string" use="required"></attribute>
+ </complexType>
+</schema>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<schema targetNamespace="http://www.w3.org/2005/11/its" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:its="http://www.w3.org/2005/11/its" xmlns:gt="https://www.gnu.org/s/gettext/ns/its/extensions/1.0" elementFormDefault="qualified">
+
+ <annotation>
+ <documentation>XML schema of *.its files, as understood by GNU gettext.
+
+Copyright (C) 2015-2024 Free Software Foundation, Inc.
+
+This file is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published
+by the Free Software Foundation, either version 3 of the License,
+or (at your option) any later version.
+
+This file is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+Written by Bruno Haible <bruno@clisp.org>, 2024.
+</documentation>
+ </annotation>
+
+ <!-- Define elements and types in the gt namespace. -->
+ <import namespace="https://www.gnu.org/s/gettext/ns/its/extensions/1.0" schemaLocation="its-extensions.xsd"/>
+
+ <element name="rules" type="its:RulesType"></element>
+
+ <complexType name="RulesType">
+ <sequence minOccurs="0" maxOccurs="unbounded">
+ <choice>
+ <element name="translateRule" type="its:TranslateRuleType">
+ </element>
+ <element name="locNoteRule" type="its:LocNoteRuleType">
+ </element>
+ <element name="withinTextRule" type="its:WithinTextRuleType">
+ </element>
+ <element name="preserveSpaceRule" type="its:PreserveSpaceRuleType">
+ </element>
+ <element ref="gt:preserveSpaceRule">
+ </element>
+ <element ref="gt:contextRule">
+ </element>
+ <element ref="gt:escapeRule">
+ </element>
+ </choice>
+ </sequence>
+ <attribute name="version" type="string" use="required" fixed="2.0"></attribute>
+ </complexType>
+
+ <complexType name="TranslateRuleType">
+ <attribute name="selector" type="string" use="required"></attribute>
+ <attribute name="translate" type="string" use="required"></attribute>
+ </complexType>
+
+ <complexType name="LocNoteRuleType">
+ <annotation>
+ <documentation>Note: An instance should not have both the 'locNotePointer' attribute and a 'locNote' child at the same time.
+</documentation></annotation>
+ <sequence minOccurs="0" maxOccurs="1">
+ <element name="locNote" type="string"></element>
+ </sequence>
+ <attribute name="selector" type="string" use="required"></attribute>
+ <attribute name="locNoteType" type="string" use="required"></attribute>
+ <attribute name="locNotePointer" type="string" use="optional"></attribute>
+ <!-- Valid in XML Schema 1.1 only:
+ <xsd:assert test="not(@locNotePointer and locNote)"/>
+ -->
+ </complexType>
+
+ <complexType name="WithinTextRuleType">
+ <attribute name="selector" type="string" use="required"></attribute>
+ <attribute name="withinText" type="string" use="required"></attribute>
+ </complexType>
+
+ <complexType name="PreserveSpaceRuleType">
+ <attribute name="selector" type="string" use="required"></attribute>
+ <attribute name="space" use="required">
+ <simpleType>
+ <restriction base="string">
+ <enumeration value="preserve"></enumeration>
+ <enumeration value="default"></enumeration>
+ </restriction>
+ </simpleType>
+ </attribute>
+ </complexType>
+</schema>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:annotation>
+ <xsd:documentation>XML schema of *.loc files, as understood by GNU gettext.
+
+Copyright (C) 2015-2024 Free Software Foundation, Inc.
+
+This file is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published
+by the Free Software Foundation, either version 3 of the License,
+or (at your option) any later version.
+
+This file is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+Written by Bruno Haible <bruno@clisp.org>, 2024.
+</xsd:documentation></xsd:annotation>
+
+ <xsd:element name="locatingRules" type="LocatingRulesType">
+ <xsd:annotation>
+ <xsd:documentation></xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+
+ <xsd:complexType name="LocatingRulesType">
+ <xsd:annotation>
+ <xsd:documentation>Example:
+<locatingRules>
+ <locatingRule name="Glade" pattern="*.glade">
+ <documentRule localName="GTK-Interface" target="glade1.its"/>
+ <documentRule localName="glade-interface" target="glade2.its"/>
+ <documentRule localName="interface" target="gtkbuilder.its"/>
+ </locatingRule>
+ <locatingRule name="Glade" pattern="*.glade2">
+ <documentRule localName="glade-interface" target="glade2.its"/>
+ </locatingRule>
+ <locatingRule name="Glade" pattern="*.ui">
+ <documentRule localName="interface" target="gtkbuilder.its"/>
+ </locatingRule>
+</locatingRules>
+</xsd:documentation></xsd:annotation>
+ <xsd:sequence minOccurs="0" maxOccurs="unbounded">
+ <xsd:element name="locatingRule" type="LocatingRuleType">
+ <xsd:annotation>
+ <xsd:documentation></xsd:documentation>
+ </xsd:annotation></xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="LocatingRuleType">
+ <xsd:annotation>
+ <xsd:documentation>Example:
+&lt;locatingRule name=&quot;Glade&quot; pattern=&quot;*.glade&quot;&gt;
+ &lt;documentRule localName=&quot;GTK-Interface&quot; target=&quot;glade1.its&quot;/&gt;
+ &lt;documentRule localName=&quot;glade-interface&quot; target=&quot;glade2.its&quot;/&gt;
+ &lt;documentRule localName=&quot;interface&quot; target=&quot;gtkbuilder.its&quot;/&gt;
+&lt;/locatingRule&gt;
+
+Note: An instance should not have both the 'target' attribute and a 'documentRule' child at the same time.
+</xsd:documentation></xsd:annotation>
+ <xsd:sequence minOccurs="0" maxOccurs="unbounded">
+ <xsd:element name="documentRule" type="DocumentRuleType"></xsd:element>
+ </xsd:sequence>
+ <xsd:attribute name="pattern" type="xsd:string" use="required"></xsd:attribute>
+ <xsd:attribute name="name" type="xsd:string" use="optional"></xsd:attribute>
+ <xsd:attribute name="target" type="xsd:string" use="optional"></xsd:attribute>
+ <!-- Valid in XML Schema 1.1 only:
+ <xsd:assert test="not(@target and documentRule)"/>
+ -->
+ </xsd:complexType>
+
+ <xsd:complexType name="DocumentRuleType">
+ <xsd:annotation>
+ <xsd:documentation>Example:
+<documentRule localName="GTK-Interface" target="glade1.its"/>
+</xsd:documentation>
+ </xsd:annotation>
+ <xsd:attribute name="target" type="xsd:string" use="required"></xsd:attribute>
+ <xsd:attribute name="ns" type="xsd:string" use="optional"></xsd:attribute>
+ <xsd:attribute name="localName" type="xsd:string" use="optional"></xsd:attribute>
+ </xsd:complexType>
+</xsd:schema>