How to set Locale for Transformation

lostiniceland
Posts: 14
Joined: Tue Nov 12, 2013 4:26 pm

How to set Locale for Transformation

Post by lostiniceland » Fri Nov 15, 2013 1:10 am

Hello everyone,

I would like to propose DITA for my project and one last thing I'd like to figure out is, how I set the locale for the Dita-OT transformation.

We will have only one language for our publications (which is German) and because that wont change I dont want to put the xml:lang="de_de" Attribute on each and every topic. I tried setting ANT-properties, for example args.dita.locale, on a custom transformation szenario without success.

Can someone please let me know which attribute I have to set? There must be some way, because some articles mention that the OT comes with a lot of languages.

sorin_ristache
Posts: 4144
Joined: Fri Mar 28, 2003 2:12 pm

Re: How to set Locale for Transformation

Post by sorin_ristache » Fri Nov 15, 2013 12:17 pm

Hello,

You should set the locale in the DITA source files by setting the xml:lang attribute at the DITA map level (for example by setting the xml:lang attribute on the root element <map> or <bookmap>), at the topic level (set the attribute on the <topic> or <task> or <concept> element) or even at element level (paragraph, list, table, etc). The closest ancestor with an xml:lang attribute declaration will set the locale for the current element. The DITA processing will fork to the appropriate locale based on the xml:lang declarations in the XML source files.

For example you can set only once, on the <map> element or the <bookmap> element, the attribute xml:lang="de-de" (BTW the correct language value is "de-de", not "de_de", always use a hyphen instead of an underline character), and only override this language setting at the topic level or at the element level, if you need to insert in the same DITA map some topics or elements with content in a different language.


Regards,
Sorin

lostiniceland
Posts: 14
Joined: Tue Nov 12, 2013 4:26 pm

Re: How to set Locale for Transformation

Post by lostiniceland » Fri Nov 15, 2013 12:33 pm

Thanks for the quick reply. I indeed tried the attribut at map-level already but with the typo...de_de comes from my Java background :-)

Still, when I transform to Webhelp I have "Content" instead of "Inhalt" or for reltable-content the output still says "related information". Is this specific for Webhelp? I expected that the translation applies to all scenarios.

sorin_ristache
Posts: 4144
Joined: Fri Mar 28, 2003 2:12 pm

Re: How to set Locale for Transformation

Post by sorin_ristache » Fri Nov 15, 2013 5:45 pm

The title of the Content, Search and Index tabs is always in English because the language is not read correctly from the DITA map file. We will correct this problem in the next version. You can correct it yourself in the current version by replacing the following code on line 166 in file [Oxygen-15.1-install-dir]\frameworks\dita\DITA-OT\plugins\com.oxygenxml.webhelp\build_dita.xml:

Code: Select all

in="${output.dir}/toc.xml"
with this code:

Code: Select all

in="${dita.temp.dir}/${user.input.file}"

If the language of a topic is not English you have to set the xml:lang in that topic too. I thought that setting the xml:lang attribute once in the map was enough, but I was wrong :-( Each topic is assumed by any DITA transformation to contain English text unless otherwise specified by an xml:lang attribute in an XML element of that topic.


Regards,
Sorin

lostiniceland
Posts: 14
Joined: Tue Nov 12, 2013 4:26 pm

Re: How to set Locale for Transformation

Post by lostiniceland » Fri Nov 15, 2013 8:23 pm

Thanks again for your help Sorin.

Everything is as expected now, though I think it is not the best idea to resolve all topics to english when there is no xml:lang. I hope this is only related to the Dita OT and not the standard, so I can file a feature request there.

Well, thanks again.

sorin_ristache
Posts: 4144
Joined: Fri Mar 28, 2003 2:12 pm

Re: How to set Locale for Transformation

Post by sorin_ristache » Mon Nov 18, 2013 10:10 am

It is related to the processor (DITA-OT in our case):
xml:lang
Specifies the language of the element content. When no xml:lang value is supplied, the default value of US English (en-us) is assumed.
It is not fixed by the DITA specification but there is a strong recommendation to set the xml:lang attribute in each map and topic:
If the @xml:lang attribute on the document (outermost) element of a map or of a top-level topic has no value, the processor should assume a default value. The default value of the processor may be either fixed, configurable, or derived from the content itself, such as the @xml:lang attribute on the primary map file. As the default value of a processor may be fixed, it is strongly recommended that the @xml:lang attribute be set on each map and top-level topic.

Regards,
Sorin

Post Reply