Requirement Information:
There are two main aspects in indicating translatable parts of an XML document.
<p>
element
of HTML is translatable.<p>
element in one specific HTML file
is not to be translated.Indicators of translatability can be defined using two main methods:
When XML Schema is used, the indicator can be set
<xs:schema version="1.0" xml:lang="en" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3.org/1999/xhtml" xmlns="The-original-format" xmlns:itsdef="The-ITS-definition-namespace" xmlns:xml="http://www.w3.org/XML/1998/namespace" elementFormDefault="qualified"> ... <xs:element name="para" itsdef:translatable="yes"> <xs:complexType mixed="true"> <xs:complexContent> <xs:extension base="Inline"> <xs:attributeGroup ref="attrs"/> </xs:extension> </xs:complexContent> </xs:complexType> </xs:element> ... </xs:schema>
The same indicator can be used for attributes. However, be aware that using translatable attribute is not recommended as it causes various problems for localization and in several languages. See [<Ref to Attributes section>] for more information.
The same namespace can be used in Relax-NG (XML form):
<grammar xmlns="http://relaxng.org/ns/structure/1.0" xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes" xmlns:itsdef="The-ITS-definition-namespace"> ... <define name="title"> <element name="title" itsdef:translatable="yes"> <ref name="title.attlist" /> <zeroOrMore> <ref name="title.char.mix" /> </zeroOrMore> </element> </define> ... </grammar>
Some documents may not be associated with a formal schema (XML Schema, DTD, etc.), or may be associated with schemas that have no localization information and on which the content developers of the documents have no control. In such cases, while this not the preferred way, it is important to allow a definition of the localizable parts in a generic way, rather than flag each and every instance.
Such definition would be stated at the beginning of the document.
<doc xmlns:its="The-ITS-instance-namespace"> <its:globalProperties> <its:defaultForElements translatable="no"/> <its:defaultForAttributes translatable="no"/> <its:rule source="\\para" translatable="yes"/> <its:rule source="@title" translatable="yes"/> </its:globalProperties> <item type="2"> <name>ItemABC</name> <file>data.img</file> <fileref>9E5DDF49-0876-4b59-965B-38336DC4C366</fileref> </item> <item type="1"> <name>Item1</name> <data title="This is translatable"> <para>This is to translate.</para> </data> </item> ... </doc>
An alternative, and more modular, way of specifying top-level definitions is to use a pointer to the definitions.
<doc xmlns:its="The-ITS-instance-namespace" its:fileProperties="DocITSProperties.xml"> <item type="2"> <name>ItemABC</name> <file>data.img</file> <fileref>9E5DDF49-0876-4b59-965B-38336DC4C366</fileref> </item> <item type="1"> <name>Item1</name> <data title="This is translatable"> <para>This is to translate.</para> </data> </item> ... </doc>
This second method has several advantages over embedding the definitions within the original document itself:
Whether the general specification of what is translatable is done from a schema, or from a block of information at the top of the document, there are cases within the document that may be exceptions to the general specifications. One can imagine for example a simple XML format allowing to mix UI text and programming strings within the same document. The general localization properties would specify that a given element is translatable, but within some files, some occurrences of the element will contain non-translatable data.
Translatability of an element content can be set using an ITS attribute if no equivalent attribute exists in the original format.
<doc xmlns="The-original-namespace" xmlns:its="The-ITS-instance-namespace"> ... <para its:translate="no">Some text content that is not translatable.</para> ... </doc>
For mixed content elements, when a portion of the text needs to be labeled for translatability, one can use an existing span-like element, or the one provided by the ITS namespace.
<para>Some text content that is <inline-format its:translate="no">not translatable</inline-format>.</para>
<para>Some text content that is <its:span translate="no">not translatable</its:span>.</para>
Dealing with meta-data for attribute is more difficult as the information cannot be attached to the attribute itself, like for an element. The solution is to use an ITS attribute enumerating the attributes for a given localization property:
<doc xmlns="The-original-namespace" xmlns:its="The-ITS-instance-namespace"> ... <para id="102" title="To translate" index="Not to translate" comment="Not to translate" its:notTranslatableAttributes="comment index"> its:translatableAttributes="title">Text to localize.</para> ... </doc>
Note that ITS-instance level markup can be used in XML Schema or the XML syntax of Relax-NG as well, since both formats are XML documents themselves:
<xs:schema version="1.0" xml:lang="en" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3.org/1999/xhtml" xmlns="The-original-format" xmlns:itsdef="The-ITS-definition-namespace" xmlns:its="The-ITS-instance-namespace" xmlns:xml="http://www.w3.org/XML/1998/namespace" elementFormDefault="qualified"> ... <xs:element name="para" itsdef:translatable="yes"> <xs:annotation> <xs:documentation its:translate="no">This comment is not to be translated.</xs:documentation> </xs:annotation> <xs:complexType mixed="true"> <xs:complexContent> <xs:extension base="Inline"> <xs:attributeGroup ref="attrs"/> </xs:extension> </xs:complexContent> </xs:complexType> </xs:element> ... </xs:schema>
The different levels of translatability can be summarized as follow: