Override sidetoc.xsl aria-label
Posted: Tue Jun 01, 2021 4:26 pm
Hello,
We have set our focus on making our webhelp responsive output as accessible as possible.
I've noticed that in some XSL files, some aria-labels haven't been localized yet.
Tried to add them myself and failed.
I've only got to the point that at least our customized strings-en-us.xml file is used, but the other strings-xx-xx files are not used.
It looks like the processing loses the language part somewhere, and I don't know why.
Normally, I would have only tunneled the i18n_context parameter - which worked in my other XSLs - but this time, I needed to import the functions.xsl file (the visible import is only a quick fix. I know it should be done otherwise.) and redefine the webhelp.language and i18n_context variables as was done elsewhere in the com.oxygenxml.webhelp.responsive plug-in. Otherwise, only the label defined in <xsl:otherwise> was used.
I've also redefined the variable to insert the label.home string, but to no avail.
What have I done wrong?
Best,
Christina
We have set our focus on making our webhelp responsive output as accessible as possible.
I've noticed that in some XSL files, some aria-labels haven't been localized yet.
Tried to add them myself and failed.
I've only got to the point that at least our customized strings-en-us.xml file is used, but the other strings-xx-xx files are not used.
It looks like the processing loses the language part somewhere, and I don't know why.
Normally, I would have only tunneled the i18n_context parameter - which worked in my other XSLs - but this time, I needed to import the functions.xsl file (the visible import is only a quick fix. I know it should be done otherwise.) and redefine the webhelp.language and i18n_context variables as was done elsewhere in the com.oxygenxml.webhelp.responsive plug-in. Otherwise, only the label defined in <xsl:otherwise> was used.
I've also redefined the variable to insert the label.home string, but to no avail.
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:toc="http://www.oxygenxml.com/ns/webhelp/toc" xmlns="http://www.w3.org/1999/xhtml"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:st="http://www.oxygenxml.com/ns/webhelp/side-toc"
xmlns:oxygen="http://www.oxygenxml.com/functions"
exclude-result-prefixes="xs toc st xhtml" version="2.0">
<xsl:import href="../../com.oxygenxml.webhelp.responsive/xsl/util/functions.xsl"/>
<xsl:variable name="webhelp_language" select="oxygen:getParameter('webhelp.language')"/>
<xsl:variable name="i18n_context">
<i18n_context>
<xsl:attribute name="xml:lang" select="$webhelp_language"/>
<xsl:attribute name="lang" select="$webhelp_language"/>
<xsl:attribute name="dir" select="oxygen:getParameter('webhelp.page.direction')"/>
</i18n_context>
</xsl:variable>
<xsl:template match="xhtml:ul" mode="toc-accessibility">
<xsl:copy>
<xsl:variable name="isRoot" as="xs:boolean" select="count(parent::*) = 0"/>
<xsl:attribute name="role">
<xsl:choose>
<xsl:when test="$isRoot">
<xsl:value-of>tree</xsl:value-of>
</xsl:when>
<xsl:otherwise>
<xsl:value-of>group</xsl:value-of>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:apply-templates select="@*" mode="toc-accessibility"/>
<xsl:if test="$isRoot">
<xsl:attribute name="aria-label">
<xsl:choose>
<xsl:when test="exists($i18n_context)">
<xsl:for-each select="$i18n_context[1]">
<xsl:call-template name="getWebhelpString">
<xsl:with-param name="stringName" select="'label.home'"/>
</xsl:call-template>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>Table of Contents</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<span class="expand-button-action-labels">
<span id="{$expandActionID}" aria-label="Expand"/>
<span id="{$collapseActionID}" aria-label="Collapse"/>
<span id="{$pendingActionID}" aria-label="Pending"/>
</span>
</xsl:if>
<xsl:apply-templates select="node()" mode="toc-accessibility"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Best,
Christina