Multilingual Support in SQF

The second draft of the Schematron QuickFix specification comes with an important addition, the localization concept for quick fixes. It is based on the Schematron localization concept, but it is more flexible.

A new attribute was added for the sqf:title and sqf:p elements, the @ref attribute. In the value of the @ref attribute, you can specify one or more IDs that point to different translations of the current phrase. The specification does not restrict the implementations of the @ref attribute to a specific reference structure.

Example 17. Schematron QuickFix that has multilingual support

 <sqf:fix id="addBone">
     <sqf:description>
         <sqf:title ref="fix_en fix_de">Add a bone</sqf:title>
         <sqf:p ref="fix_d_en fix_d_de">Add a bone as child element</sqf:p>
     </sqf:description>
     <sqf:add node-type="element" target="bone"/>
 </sqf:fix>

One possible implementation of the multilingual support in SQF is to use the Schematron diagnostics element. You can define a diagnostic for each referenced id and specify the language of the diagnostic message using the xml:lang attribute on the sch:diagnostic element or on its parent.

Example 18. Schematron diagnostics

 <sch:diagnostics>
     <sch:diagnostic 
        id="fix_en" 
        xml:lang="en">Add a bone</sch:diagnostic>
     <sch:diagnostic 
        id="fix_de" 
        xml:lang="de">Fügen Sie einen Knochen hinzu</sch:diagnostic>
 </sch:diagnostics>

This implementation conforms with the Schematron standard that also uses diagnostic for localization. It is easier to translate the messages because the Schematron messages and quick fix messages are kept together, and another important aspect is that it will be the same implementation used for both Schematron and SQF messages.

There are also some issues with this implementation. One of them is that you cannot have IDs with the same name in your document because the diagnostic uses XML IDs. Another issue is that SQF will depend on the Schematron language and cannot be encapsulated separately.

Another implementation of quick fix localization is to use Java Property Files. In this case, the localized text phrases should be stored in external files, grouped by language. These files should be placed parallel to the Schematron schema with the name pattern ${fileName}_${lang}.xml. The ${fileName} should be the name of the Schematron schema but without the extension. The @ref attribute from the quick fix must reference the property key.

Example 19. Java Property File for German translation

<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
    <entry key="dog.addBone.title">Füge einen Knochen hinzu</entry>
    <entry key="dog.addBone.p">Der Hund wird einen Knochen erhalten.</entry>
</properties>


In contrast to the references to sch:diagnostic elements, in this case, it is not necessary to make any changes in the Schematron schema to introduce a new language. You just have to add a file with the name (for example localized_fr.xml) in the same folder of the Schematron file (for example localized.sch).

However, this needs a different implementation than the standard Schematron, and the Schematron messages and the SQF messages will be in different locations.