Skip to content

Commit

Permalink
PG doesn't like language+script-codes in their generated ePubs.
Browse files Browse the repository at this point in the history
  • Loading branch information
jhellingman committed May 7, 2024
1 parent c81df6e commit acc1ed9
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions modules/utils.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,19 @@
<xsl:when test="matches($lang, '^[a-z]{2}-[A-Za-z]{2}$')">
<xsl:value-of select="substring($lang, 1, 3) || upper-case(substring($lang, 4, 2))"/>
</xsl:when>
<!-- Fix case of language + script code (e.g. zh-Latn)-->
<!-- Strip script code from 2-letter language + script code, if in pg-compliant mode -->
<xsl:when test="f:is-set('pg.compliant') and matches($lang, '^[a-z]{2}-[A-Za-z]{4}$')">
<xsl:value-of select="substring($lang, 1, 2)"/>
</xsl:when>
<!-- Fix case of 2-letter language + script code (e.g. zh-Latn) -->
<xsl:when test="matches($lang, '^[a-z]{2}-[A-Za-z]{4}$')">
<xsl:value-of select="substring($lang, 1, 3) || upper-case(substring($lang, 4, 1)) || lower-case(substring($lang, 5, 3))"/>
</xsl:when>
<!-- Fix case of language + script code (e.g. grc-Latn)-->
<!-- Strip script code of 3-letter language + script code, if in pg-compliant mode -->
<xsl:when test="f:is-set('pg.compliant') and matches($lang, '^[a-z]{3}-[A-Za-z]{4}$')">
<xsl:value-of select="substring($lang, 1, 3)"/>
</xsl:when>
<!-- Fix case of 3-letter language + script code (e.g. grc-Latn) -->
<xsl:when test="matches($lang, '^[a-z]{3}-[A-Za-z]{4}$')">
<xsl:value-of select="substring($lang, 1, 4) || upper-case(substring($lang, 5, 1)) || lower-case(substring($lang, 6, 3))"/>
</xsl:when>
Expand Down

0 comments on commit acc1ed9

Please sign in to comment.