AntennaHouse / pdf5-ml

Antenna House PDF5-ML DITA-OT Plug-in
23 stars 9 forks source link

Hungarian xref to step and page #210

Closed steinbacher01 closed 3 years ago

steinbacher01 commented 3 years ago

Our localization team has given us some feedback on how Hungarian xrefs that point to steps should be handled. 

English: “step X on page N.”

should be 

Hungarian: "N. oldal, X. lépés" (oldal is page and lépés is step)

I added a new string for step suffix.

<variable name="Xref_Step_Prefix">&#x00A0;</variable>
<variable name="Xref_Step_Suffix">.&#x00A0;lépés</variable>

Then I created a custom extension for the getXrefTitleStep template (dita2fo_xref.xsl).

Added the stepHeading-suffix variable.

<!-- US563 xref step on page for Hungarian New string variable -->
<xsl:variable name="stepHeading-suffix" as="xs:string">
  <xsl:call-template name="getVarValueWithLang">
    <xsl:with-param name="prmVarName" select="'Xref_Step_Suffix'"/>
    <xsl:with-param name="prmElem" select="$prmDestElement"/>
  </xsl:call-template>
</xsl:variable>

Included the stepHeading-suffix variable in output.

<xsl:when test="$prmDestElement[contains(@class, ' task/step ')]">
<xsl:variable name="numberFormat" select="ahf:getOlNumberFormat($prmDestElement/parent::*,$stepsNumberFormat)" as="xs:string"/>
  <fo:inline>
    <xsl:copy-of select="$stepHeading"/>
    <xsl:number format="{$numberFormat}" value="ahf:getStepNumber($prmDestElement)"/>
    <!-- US563 xref step on page for Hungarian New string variable -->
    <xsl:copy-of select="$stepHeading-suffix"/>
  </fo:inline>
</xsl:when>

This puts the number in front of "step" (page already has a suffix string).

But, the xref generated text for Hungarian is still this.

See 1. lépés, 11. oldal.

Is it possible to change the step and page order so the Hungarian output is like this?

See 11. oldal,1. lépés.

It looks like the the page number is generated in different templates within dita2fo_xref.xsl, so I am not sure how this can be done.

Thanks,

Leroy Steinbacher t_xref-test_hu.zip

ToshihikoMakita commented 3 years ago

Supporting Hungarian xrefs that refers steps will need language specific information. According to your information, the page should precedes step. I will investigate the relevant stylesheet.

ToshihikoMakita commented 3 years ago

I have tested with new Hungarian style hu_style.xml.

<?xml version="1.0" encoding="UTF-8" ?>
<!--
************************************************************
DITA to XSL-FO Style Definition 
************************************************************
File Name : hu_style.xml
************************************************************
Copyright © 2009 2021 Antenna House, Inc.
Antenna House is a trademark of Antenna House, Inc.
URL : http://www.antennahouse.com/
************************************************************
-->
<style-definition xmlns:axf="http://www.antennahouse.com/names/XSL/Extensions"
 xmlns="http://www.antennahouse.com/names/XSLT/Document/Layout">
 <variables>
  <!-- Xref -->
  <variable name="Xref_Prefix">. oldal </variable>
  <variable name="Xref_Suffix"/>
  <variable name="Xref_Adopt_Title_Page_Order">false</variable>
  <variable name="Xref_Prefix_Title_Page"></variable>
  <variable name="Xref_Suffix_Title_Page">. oldal, </variable>
  <variable name="Xref_Prefix_Page_Only"/>
  <variable name="Xref_Suffix_Page_Only">. oldal </variable>
  <variable name="Xref_Title_Prefix"></variable>
  <variable name="Xref_Title_Suffix"></variable>
  <variable name="Xref_Step_Prefix">&#x00A0;</variable>
  <variable name="Xref_Step_Suffix">.&#x00A0;lépés</variable>
  <variable name="Xref_Step_Substep_Separator">.</variable>
 </variables>
</style-definition>

And the PDF result.

hu-xref-to-step

However there exists one redundant space in the step-number only formatting result.

bm_xref-test_hu.pdf

ToshihikoMakita commented 3 years ago

However there exists one redundant space in the step-number only formatting result.

Removing prefix &#x00A0; solved this problem.

  <variable name="Xref_Step_Prefix"></variable>
  <variable name="Xref_Step_Suffix">.&#x00A0;lépés</variable>
  <variable name="Xref_Step_Substep_Separator">.</variable>

hu-xref-to-step-2

steinbacher01 commented 3 years ago

Thank you very much for the solution. 🥇 It is now working as expected. Our Hungarian linguists will be pleased.

ToshihikoMakita commented 3 years ago

@steinbacher01 I have merged "issue-hangarian-xref" branch into "develop". In a short time I will merge it into "master" and make the release. For your reference, I've heard from my user that Hungarian word "lépés" may vary by context. This user only use step number and author this word manually.

steinbacher01 commented 3 years ago

Thanks! Yes we are aware of how the proper Hungarian translation of this reference can vary by context. Based on the case, the suffix of lépés will change. We have advised our writers to be careful when writing xrefs in English to make it easier to translate to Hungarian and other agglutinative languages.