Re: [docbook-apps] Multiple languages in PDF?

From
M. Downing Roberts <>
Date
2021-12-29T09:31:30+00:00
ID
CAHtfQAc8ttVkJuOX1n4uW=
Thread
Re: [docbook-apps] Multiple languages in PDF?
Hi,

Looks like I'm stuck on a multiple languages issue again. I'm trying to generate two different indexes, one for English and one for Japanese.

To set this up, I followed the instructions in DocBook XSL: the Complete Guide.

I have <indexterm> elements in my document, like this:

<indexterm type="en"><primary>Hypothesis</primary></indexterm>
<indexterm type="ja"><primary>äè</primary></indexterm>

And <index> elements at the end, like this:

<index type="en"><title>Index</title></index>
<index type="ja"><title>çå</title></index>

My customized style sheet includes:

<xsl:importÂhref="">
...Â
<xsl:param name="autolink.index.see" select="0"/>
<xsl:param name="index.on.type" select="1"/>
<xsl:param name="index.method">kimber</xsl:param>

I try to run my book file through saxon like this:

$ java com.icl.saxon.StyleSheet \
> -o tmp.fo \
> book-1.xml \
> custom-1.xsl

The CLASSPATH is set ike this:

CLASSPATH=/usr/local/lib/i18n_support/i18n_support.jar:/usr/local/Cellar/docbook-xsl/1.79.2_1/docbook-xsl/tools/lib/saxon.jar:

But it fails:

Error at xsl:variable on line 705 of file: custom-1.xsl:
 Key abbrev has not been defined
Transformation failed: Run-time errors were reported

The offending line in the customization layer is in this template:

<xsl:template match="footnote" name="process.footnote" mode="process.footnote.mode">

It looks like this:

Â<xsl:variable name="lookup" select="key('abbrev', $biblioref)"/>

At this point, I'm kind of lost. I guess saxon is installed correctly, but I'm not sure. The documentation for installing saxon on macOS mostly assumes a level of expertise that I don't have.

In case it might help, my customization layer is here:Âhttps://pastebin.com/raw/Qk8Es8ur

Any suggestions?

Thanks!

M.

On Wed, Dec 22, 2021 at 5:53 PM Eric Streit <> wrote:

pas de quoi .... sending in PM

Eric

Le 22/12/2021 Ã 08:53, M. Downing Roberts a ÃcritÂ:

> Hi,

> 

> Thanks for your message. I followed your idea to install Noto Sans (from 

> Google fonts) and FOP on my machine can find the fonts now.

> 

> <foreignphrase> works, but I'm still trying to figure out how to 

> customize theÂXSL so that <subtitle> uses a different font.

> 

> If you don't mind sending your customization file, maybe I can learn 

> something by reading it.

> 

> Merci mille fois !

> 

> M.

> 

> On Wed, Dec 22, 2021 at 4:24 PM Eric Streit < 

> <mailto:>> wrote:

> 

>Â Â Âre-

> 

>Â Â Âand yes, sometimes, finding the name fof needs can be tricky. I used

>Â Â Âsome command line tools to find out what was the name fod wants: very

>Â Â Âdifferent from the name in the a folder for example.

> 

>Â Â ÂI don't remember which one I used at the time I was looking for it but

>Â Â Âjust try every "font manager" you can find, and you'll find it.

> 

>Â Â ÂI can send you my cutomization file if you want, I made some other

>Â Â Âcustomization (for the list handling when the numbers are over 10

>Â Â Âetc ...)

> 

>Â Â ÂBest regards

> 

>Â Â ÂEric

>Â Â ÂLe 22/12/2021 Ã 08:15, M. Downing Roberts a ÃcritÂ:

>Â Â Â > Hi,

>Â Â Â >

>Â Â Â > Thanks very much for your suggestions. Using <foreignphrase> and the

>Â Â Â > customization you suggested, the font is substituted. However,

>Â Â Âalthough

>Â Â Â > I specify Times or Arial, it tries Times-Roman or ArialMT,

>Â Â Âneither of

>Â Â Â > which include Japanese characters.

>Â Â Â >

>Â Â Â > Is there some way I can find out the names of the fonts that FOP

>Â Â Â > believes I have installed? It seems like there's some mismatch

>Â Â Âbetween

>Â Â Â > what is shown in apps vs. what FOP thinks is actually available.

>Â Â Â >

>Â Â Â > Next, I was unable to get the <subtitle> element to substitute

>Â Â Âthe font.

>Â Â Â > Here's the customization that I'm trying:

>Â Â Â >

>Â Â Â >Â Â Â<xsl:template match="subtitle"

>Â Â Âmode="section.titlepage.recto.auto.mode">

>Â Â Â >Â Â Â Â <xsl:choose>

>Â Â Â >Â Â Â Â Â<xsl:when test="contains(' ja ', @xml:lang)">

>Â Â Â >Â Â Â Â Â Â <fo:block

>Â Â Â >Â Â Âxsl:use-attribute-sets="section.titlepage.recto.style"

>Â Â Â >Â Â Âfont-family="Times" font-weight="bold">

>Â Â Â >Â Â Â Â Â Â Â <xsl:apply-templates select="."

>Â Â Â >Â Â Âmode="section.titlepage.recto.mode"/>

>Â Â Â >Â Â Â Â Â Â </fo:block>

>Â Â Â >Â Â Â Â Â</xsl:when>

>Â Â Â >Â Â Â Â Â <xsl:otherwise>

>Â Â Â >Â Â Â Â Â Â <fo:block

>Â Â Â >Â Â Âxsl:use-attribute-sets="section.titlepage.recto.style"

>Â Â Â >Â Â Âfont-family="{$title.fontset}">

>Â Â Â >Â Â Â Â Â Â Â <xsl:apply-templates select="."

>Â Â Â >Â Â Âmode="section.titlepage.recto.mode"/>

>Â Â Â >Â Â Â Â Â Â </fo:block>

>Â Â Â >Â Â Â Â Â </xsl:otherwise>

>Â Â Â >Â Â Â Â </xsl:choose>

>Â Â Â >Â Â Â</xsl:template>

>Â Â Â >

>Â Â Â >

>Â Â Â > I must be doing something wrong, but I'm not sure what.

>Â Â Â >

>Â Â Â > Thanks,

>Â Â Â >

>Â Â Â > M.

>Â Â Â >

>Â Â Â > On Wed, Dec 22, 2021 at 3:35 PM Alemps Florimond

>Â Â Â< <mailto:>

>Â Â Â > <mailto: <mailto:>>>

>Â Â Âwrote:

>Â Â Â >

>Â Â Â >Â Â ÂHello

>Â Â Â >

>Â Â Â >Â Â ÂI would address this like that :

>Â Â Â >Â Â Â<para>The HÅjÅki [<foreignphrase xml:lang="ja">æäè

>Â Â Â >Â Â Â</foreignphrase>] is an important and popular short work of the

>Â Â Â >Â Â Âearly Kamakura period.</para>

>Â Â Â >

>Â Â Â >Â Â ÂCustomise font here :

>Â Â Â >Â Â Â<xsl:template match="d:foreignphrase">

>Â Â Â >Â Â Â Â <xsl:choose>

>Â Â Â >Â Â Â ÂÂ <xsl:when test="contains(' ja ', @xml:lang)">

>Â Â Â >Â Â Â ÂÂÂÂÂ <fo:inline font-family="Hiragino Mincho ProN">

>Â Â Â >Â Â Â ÂÂÂÂÂÂÂ <xsl:apply-templates/>

>Â Â Â >Â Â Â ÂÂÂÂÂ </fo:inline>

>Â Â Â >Â Â Â ÂÂ </xsl:when>

>Â Â Â >Â Â Â ÂÂÂ <xsl:otherwise>

>Â Â Â >Â Â Â ÂÂÂÂÂ <xsl:call-template name="inline.italicseq"/>

>Â Â Â >Â Â Â ÂÂÂ </xsl:otherwise>

>Â Â Â >Â Â Â Â </xsl:choose>

>Â Â Â >Â Â Â</xsl:template>

>Â Â Â >

>Â Â Â >Â Â Â"contains" is useful if you can use the same font for different

>Â Â Â >Â Â Âlanguages ... :

>Â Â Â >Â Â Â ÂÂ <xsl:when test="contains(' ja ko zh ', @xml:lang)">

>Â Â Â >Â Â Â ÂÂÂÂÂ <fo:inline font-family= Hiragino Mincho ProN">

>Â Â Â >Â Â Â ÂÂÂÂÂÂÂ <xsl:apply-templates/>

>Â Â Â >Â Â Â ÂÂÂÂÂ </fo:inline>

>Â Â Â >Â Â Â ÂÂ </xsl:when>

>Â Â Â >

>Â Â Â >Â Â ÂFor titles, I would condition attribute font-family in the

>Â Â Â >Â Â Âappropriate xsl:attribute-sets="section.titlepage.recto.style

>Â Â Âbased

>Â Â Â >Â Â Âon xml:lang as done above.

>Â Â Â >

>Â Â Â >Â Â ÂTo make sure it is not a problem with the font itself :

>Â Â Â >Â Â Â1. replace "Hiragino Mincho ProN" with Arial or Times or even

>Â Â Â >Â Â Â2. set attribute font-weight="bold"

>Â Â Â >

>Â Â Â >Â Â ÂHope this help

>Â Â Â >Â Â ÂFlorimond

>Â Â Â >

>Â Â Â >

>Â Â Â >Â Â ÂLe mercredi 22 dÃcembre 2021, 04:01:33 UTC+1, M. Downing Roberts

>Â Â Â >Â Â Â<

>Â Â Â<mailto:>

>Â Â Â<mailto:

>Â Â Â<mailto:>>>

>Â Â Â >Â Â Âa Ãcrit :

>Â Â Â >

>Â Â Â >

>Â Â Â >

>Â Â Â >

>Â Â Â >

>Â Â Â >Â Â ÂI'm back with another question.

>Â Â Â >

>Â Â Â >Â Â ÂI'd like to combineÂEnglish and Japanese text in a single book. I

>Â Â Â >Â Â Âcan set the @lang attribute on various elements, but the

>Â Â Âproblem is

>Â Â Â >Â Â Âthat I need to switch fonts, too. The font that I want to use for

>Â Â Â >Â Â Âbody text doesn't include Japanese characters. I'm not sure

>Â Â Âhow to

>Â Â Â >Â Â Âembed Japanese text within a <para> of English and get it to

>Â Â Ârender

>Â Â Â >Â Â Âproperly. E.g.:

>Â Â Â >

>Â Â Â >Â Â Â > <para>The HÅjÅki [æäè] is an important and popular

>Â Â Âshort work

>Â Â Â >Â Â Âof the early Kamakura period.</para>

>Â Â Â >

>Â Â Â >Â Â ÂIt seems like I need something akin to <span lang="ja"> to

>Â Â Âmark the

>Â Â Â >Â Â ÂJapanese text, and then a customization in the stylesheet to

>Â Â Âdetect

>Â Â Â >Â Â Âthis and specify a suitable font. However, I'm not sure how I

>Â Â Âshould

>Â Â Â >Â Â Âhandle either ofÂthese issues.

>Â Â Â >

>Â Â Â >Â Â ÂI would also like to specify a different font for the <subtitle>

>Â Â Â >Â Â Âelement. I've tried this customization:

>Â Â Â >

>Â Â Â >Â Â Â > <xsl:template match="subtitle"

>Â Â Â >Â Â Âmode="section.titlepage.recto.auto.mode">

>Â Â Â >Â Â Â > <fo:block

>Â Â Âxsl:use-attribute-sets="section.titlepage.recto.style"

>Â Â Â >Â Â Âfont-family="Hiragino Mincho ProN">

>Â Â Â >Â Â Â > <xsl:apply-templates select="."

>Â Â Âmode="section.titlepage.recto.mode"/>

>Â Â Â >Â Â Â > </fo:block>

>Â Â Â >Â Â Â > </xsl:template>

>Â Â Â >

>Â Â Â >Â Â Â > <xsl:template match="subtitle" mode="titlepage.mode">

>Â Â Â >Â Â Â > Â <fo:block font-family="Hiragino Mincho ProN">

>Â Â Â >Â Â Â > Â Â <xsl:apply-templates mode="titlepage.mode"/>

>Â Â Â >Â Â Â > Â </fo:block>

>Â Â Â >Â Â Â > </xsl:template>

>Â Â Â >

>Â Â Â >Â Â Â...but it seems to have no effect. The font is not found,

>Â Â Âthough it

>Â Â Â >Â Â Âis installed on my machine.

>Â Â Â >

>Â Â Â >Â Â ÂWhat am I doing wrong? What's the best way to approach this?

>Â Â Â >

>Â Â Â >Â Â ÂThanks!

>Â Â Â >

>Â Â Â >Â Â ÂM.

>Â Â Â >

>Â Â Â >

>