Changing the Related Link order - "topic name "on page" "page number"

Post here questions and problems related to editing and publishing DITA content.
Anonymous1

Changing the Related Link order - "topic name "on page" "page number"

Post by Anonymous1 »

Hello,

our Japanese translators just informed us that for the Related Links section, our order of "topic name", "on page", and "page number" does not work in Japanese.

Example:
Snapshots on page 15

They would like to have:
15 on page "Snapshots"

A Japanese example:
15 ページの 「スナップショット (Snapshots)」

Can someone help me finding the right position in the framework to change this for Japanese?
Radu
Posts: 9446
Joined: Fri Jul 09, 2004 5:18 pm

Re: Changing the Related Link order - "topic name "on page" "page number"

Post by Radu »

Hi,

If you set the attribute xml:lang="ja-JP" on the main DITA root map, the publishing engine should correctly use Japanese to translate static texts in the PDF. Otherwise you may also need to set the attribute on each topic.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Anonymous1

Re: Changing the Related Link order - "topic name "on page" "page number"

Post by Anonymous1 »

It's not about the translation, but about the order of the elements. The "on page" is translated correctly, but I don't know how to move the "on page" element before the "link text" element.

The xml:lang attribute is set correctly.

So I want to have the following variable to appear in front of the topic title of the related link:

Code: Select all

<variable id="On the page"><param ref-name="pagenum"/> ページの </variable>
So I can have this:
  • 5 ページの オフラインプロセッサーについて
Instead of this:
  • オフラインプロセッサーについて5 ページの
Radu
Posts: 9446
Joined: Fri Jul 09, 2004 5:18 pm

Re: Changing the Related Link order - "topic name "on page" "page number"

Post by Radu »

Hi,

Unfortunately this would probably require an XSLT customization.
In the XSLT stylesheet:

OXYGEN_INSTALL_DIR\frameworks\dita\DITA-OT2.x\plugins\org.dita.pdf2\xsl\fo\links.xsl

if you search for the first occurrence of the "insertPageNumberCitation" template, it gets called after the referenced target title is output.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Anonymous1

Re: Changing the Related Link order - "topic name "on page" "page number"

Post by Anonymous1 »

Thanks for pointing me to the right place. I have managed to put the related links in the right order. But I struggle with getting this fix applied for only certain languages (Japanese in this case).

I tried to work with when/otherwise, but it doesn't put out what I'd like to. My plan is to apply my fix only when the xml:lang attribute set to "ja-JP" is found. In all other cases, the related links order should be normal. Here is what I tried.

Code: Select all

        <fo:block xsl:use-attribute-sets="link">
<xsl:choose>
<xsl:when test="concept/@xml:lang = 'ja-JP'">
<xsl:call-template name="insertPageNumberCitation">
<xsl:with-param name="isTitleEmpty" select="true()"/>
<xsl:with-param name="destination" select="$destination"/>
<xsl:with-param name="element" select="$element"/>
</xsl:call-template>
<fo:inline xsl:use-attribute-sets="link__content">
<fo:basic-link>
<xsl:call-template name="buildBasicLinkDestination">
<xsl:with-param name="scope" select="$linkScope"/>
<xsl:with-param name="href" select="@href"/>
</xsl:call-template>
<xsl:copy-of select="$referenceTitle"/>
</fo:basic-link>
</fo:inline>
</xsl:when>
<xsl:otherwise>
<fo:inline xsl:use-attribute-sets="link__content">
<fo:basic-link>
<xsl:call-template name="buildBasicLinkDestination">
<xsl:with-param name="scope" select="$linkScope"/>
<xsl:with-param name="href" select="@href"/>
</xsl:call-template>
<xsl:choose>
<xsl:when test="not($linkScope = 'external') and exists($referenceTitle)">
<xsl:copy-of select="$referenceTitle"/>
</xsl:when>
<xsl:when test="not($linkScope = 'external')">
<xsl:call-template name="insertPageNumberCitation">
<xsl:with-param name="isTitleEmpty" select="true()"/>
<xsl:with-param name="destination" select="$destination"/>
<xsl:with-param name="element" select="$element"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</fo:basic-link>
</fo:inline>
<xsl:if test="not($linkScope = 'external') and exists($referenceTitle)">
<xsl:call-template name="insertPageNumberCitation">
<xsl:with-param name="destination" select="$destination"/>
<xsl:with-param name="element" select="$element"/>
</xsl:call-template>
</xsl:if>

</xsl:otherwise>
</xsl:choose>
</fo:block>
HomeGoods
Posts: 96
Joined: Wed Feb 09, 2005 8:57 am

Re: Changing the Related Link order - "topic name "on page" "page number"

Post by HomeGoods »

This may be off topic, but...
In your boots I'd leave the word order as it is and just translate "NAME on page NUM" into "NAME(NUM ページ)", "NAME (p.NUM)" or the like.
I, a native Japanese speaker, am afraid your current goal ("NUM ページの NAME") might be rather distracting for enumeration purposes.
Radu
Posts: 9446
Joined: Fri Jul 09, 2004 5:18 pm

Re: Changing the Related Link order - "topic name "on page" "page number"

Post by Radu »

Hi,

The XPath expression concept/@xml:lang = 'ja-JP' is relative to the current context node. Also the xml:lang needs to appear as a condition.
So if you want to find the closest ancestor concept of the context node the XPath should probably be something like: (ancestor::concept[1])[@xml:lang = 'ja-JP'].

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply