Test 1 : Localisable Text in Attributes
Sample
xml file describing a menu
|
Marked
up with xlf Localisation Directives
|
<?xml version="1.0"
encoding="UTF-8"?>
<!-- Test 1 - Mixture of localisable /
non-localisable text in attributes -->
<window id="greeting-window" title="Greetings">
<menubar id="main-menubar">
<!-- File menu -->
<menu id="fileMenu" value="File" accesskey="f">
<menupopup>
<menuitem id="fileOpen" value="Open" accesskey="o" oncommand="Open()"/>
<menuitem value="Close" accesskey="c" oncommand="Close()"/>
</menupopup>
</menu>
<!-- Edit menu -->
<menu id="editMenu" value="Edit" accesskey="e">
<menupopup>
<menuitem value="Undo" accesskey="z" type="CTRL" oncommand="Undo()"/>
<menuitem value="Redo" accesskey="F4" type="VIRTKEY" oncommand="Redo()"/>
</menupopup>
</menu>
</menubar>
</window>
|
<?xml version="1.0"
encoding="UTF-8"?>
<window id="greeting-window" title="Greetings"
xmlns:xlf="http://www.open-oasis.org/xliff/1.1">
<menubar id="main-menubar"
xlf:path="/menu/menupopup/menuitem/@value
;
/menu/menupopup/menuitem/@accesskey"
xlf:localise="yes">
<!-- Means, localise all items matching
the path, ... -->
<!-- i.e. value and accesskey within menuitem
-->
<!--
What has to be localised appears in bold -->
<!-- File menu -->
<menu id="fileMenu" value="File" accesskey="f">
<!--
Note the value File was not specified… -->
<menupopup>
<menuitem value="Open"
accesskey="o" oncommand="Open()"/>
<menuitem value="Close" accesskey="c" oncommand="Close()"/>
</menupopup>
</menu>
<!-- Edit menu -->
<menu id="editMenu" value="Edit" accesskey="e">
<menupopup>
<menuitem value="Undo"
accesskey="z" type="CTRL" oncommand="Undo()"/>
<menuitem xlf:path="@accesskey" xlf:localise="no" value="Redo" accesskey="F4" type="VIRTKEY" oncommand="Redo()"/>
<!-- Means, do not localise the
accesskey for just this item, i.e. F4
-->
</menupopup>
</menu>
</menubar>
</window>
|
Comments
Difficutlt to identify which items are for localisation
To mark every attribute individually here would be wasteful. I think there
is no point in trying that, the user may as well convert to xliff proper.
If we have a way of globally specifying which attributes are for
localisation, this could be really powerful. An application like Catlayst
could very easily go through this and pick out the items for localisation.
Perhaps an XPath type syntax would help (as in sample)
While it may be easy enough for us to specify the simple cases as above, this
could get quite complicated for the processing application.
- Need to be able to specify which attributes are to be localised
- Need to be able to specify exceptions eg. Localise all
accesskeys except the one in Redo
Even in the above example, you have problems...
- xlf:path and xlf:localise must appear together, can this be validated?
- xlf:path looks like a global variable that is set once, this is not the
case, it is simply an instruction (Processer must interpret instruction to )
- In a global setting mechanism like this, we can't assign an ID per
translation unit
An alternative might be to create an element which would try to
globally describe what has to be localised, eg.
<xlf:localise>
<xlf:path="/menu/menupopup/menuitem/@value"
/>
<xlf:path="/menu/menupopup/menuitem/@accesskey"
/>
</xlf:localise>