質問

In your opinion, what is the best way to internationalize Schematron error messages? I don't want to duplicate the schematron files, just the assert and report messages.

役に立ちましたか?

解決

I stumbled across this in the schematron ISO standard document:

Diagnostics in multiple languages may be supported 
by using a different diagnostic element for each language, 
with the appropriate xml:lang language attribute, 
and referencing all the unique identifiers of the diagnostic elements 
in the diagnostics attribute of the assertion. 
Annex G gives a simple example of a multi-lingual schema.

Annex G:

<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron"
    xml:lang="en" >
    <sch:title>Example of Multi-Lingual Schema</sch:title>
    <sch:pattern>
        <sch:rule context="dog">
            <sch:assert test="bone" diagnostics="d1 d2">
    A dog should have a bone.
            </sch:assert>
        </sch:rule>
    </sch:pattern>
    <sch:diagnostics>
        <sch:diagnostic id="d1" xml:lang="en">
    A dog should have a bone.
        </sch:diagnostic>
        <sch:diagnostic id="d2" xml:lang="de">
    Ein Hund sollte ein Bein haben.
        </sch:diagnostic>
    </sch:diagnostics>
</sch:schema>

他のヒント

For detail, refer to Best Practices for XML Internationalization . In short, you can internationalize messages in any XML document using the xml:lang attribute.

Example:

 <messages xmlns:xml="http://www.w3.org/XML/1998/namespace">
  <message Id="cannot-find-file-msg">
   <message-text xml:lang="en">Cannot find file.</message-text>
   <message-text xml:lang="fr">Fichier non trouvé.</message-text>
  </message>
 </messages> 

In the above example, you can access the required message text, given the local language, a message identifier and an XPATH expression.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top