AntennaHouse / pdf5-ml

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

Multilingual PDF with "Chapter" translated for each language? #196

Closed steinbacher01 closed 3 years ago

steinbacher01 commented 3 years ago

Question: Is it possible to generate a multilingual PDF that has the correct translation of "Chapter" for each language? We've customized this in the past, but we are wondering if there is a way to do it within the base pdf5-ml plugin.

Multilingual-PDF

Thanks,

Leroy Steinbacher

ToshihikoMakita commented 3 years ago

Base PDF5-ML plug-in adopts bookmap/@xml:lang for generating chapter prefix/suffix. This is because one publication should adopt consistent chapter prefix/suffix as a book.

steinbacher01 commented 3 years ago

Are there any other options available to create a single multilingual PDF? Can multiple PDFs be embeded together? Is it possible to publish embeded PDFs referenced within a DITA bookmap?

We have some multilingual documents that include up to 30 languages. What is the most efficient way to bundle these within a single PDF?

Thanks,

Leroy Steinbacher

ToshihikoMakita commented 3 years ago

if you want to generate "a multilingual PDF that has the correct translation of "Chapter" for each language", you can do it by changing following code into topic/title processing template and change it from getVarvalue to getVarValueWithLang to get the topic/@xml:lang specific value.

https://github.com/AntennaHouse/pdf5-ml/blob/master/com.antennahouse.pdf5.ml/xsl/dita2fo_global.xsl

<xsl:variable name="cPartTitlePrefix"  select="ahf:getVarValue('Part_Title_Prefix')" as="xs:string"/>
<xsl:variable name="cPartTitleSuffix"  select="ahf:getVarValue('Part_Title_Suffix')" as="xs:string"/>
<xsl:variable name="cChapterTitlePrefix"  select="ahf:getVarValue('Chapter_Title_Prefix')" as="xs:string"/>
<xsl:variable name="cChapterTitleSuffix"  select="ahf:getVarValue('Chapter_Title_Suffix')" as="xs:string"/>
steinbacher01 commented 3 years ago

Thank you for the suggestion. I'm getting the following error.

Fatal Error! Cannot find a 1-argument function named Q{http://www.w3.org/2005/xpath-functions}getVarValueWithLang()

I added the code change you suggested above to the topic/title processing template.

com.antennahouse.pdf5.ml\xsl\dita2fo_title.xsl

<xsl:template match="*[contains(@class, ' topic/title ')]">
    <xsl:variable name="cPartTitlePrefix"  select="getVarValueWithLang('Part_Title_Prefix')" as="xs:string"/>
    <xsl:variable name="cPartTitleSuffix"  select="getVarValueWithLang('Part_Title_Suffix')" as="xs:string"/>
    <xsl:variable name="cChapterTitlePrefix"  select="getVarValueWithLang('Chapter_Title_Prefix')" as="xs:string"/>
    <xsl:variable name="cChapterTitleSuffix"  select="getVarValueWithLang('Chapter_Title_Suffix')" as="xs:string"/>
        <xsl:apply-templates/>
</xsl:template>

Any suggestions?

Thanks,

Leroy

ToshihikoMakita commented 3 years ago

Try using template version of getVarValueWithLang instead.

https://github.com/AntennaHouse/pdf5-ml/blob/master/com.antennahouse.pdf5.ml/xsl/dita2fo_style_get.xsl line 1048

<xsl:template name="getVarValueWithLang" as="xs:string">
    <xsl:param name="prmVarName" as="xs:string" required="yes"/>
    <xsl:param name="prmElem" as="element()" required="no" select="."/>
    <xsl:param name="prmDocType" as="xs:string?" required="no" select="$defaultDocType"/>
    <xsl:param name="prmPaperSize" as="xs:string?" required="no" select="$defaultPaperSize"/>
    <xsl:param name="prmOutputType" as="xs:string?" required="no" select="$defaultOutputType"/>
    <xsl:param name="prmBrandType" as="xs:string?" required="no" select="$defaultBrandType"/>
steinbacher01 commented 3 years ago

Thank you for the suggestions.