Skip to content

Commit a009724

Browse files
committed
Add dynamic translations for Aria tags
1 parent a1ebb7b commit a009724

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

resource/js/tab-hierarchy.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ function startHierarchyApp () {
1515
computed: {
1616
openAriaMessage () {
1717
return $t('Open')
18+
},
19+
goToTheConceptPageAriaMessage () {
20+
return $t('Go to the concept page')
1821
}
1922
},
2023
provide () {
@@ -205,6 +208,7 @@ function startHierarchyApp () {
205208
:selectedConcept="selectedConcept"
206209
:loadingChildren="loadingChildren"
207210
:openAriaMessage="openAriaMessage"
211+
:goToTheConceptPageAriaMessage="goToTheConceptPageAriaMessage"
208212
@load-children="loadChildren($event)"
209213
@select-concept="selectedConcept = $event"
210214
></tab-hier-wrapper>
@@ -244,7 +248,7 @@ function startHierarchyApp () {
244248
})
245249

246250
tabHierApp.component('tab-hier-wrapper', {
247-
props: ['hierarchy', 'selectedConcept', 'loadingChildren', 'openAriaMessage'],
251+
props: ['hierarchy', 'selectedConcept', 'loadingChildren', 'openAriaMessage', 'goToTheConceptPageAriaMessage'],
248252
emits: ['loadChildren', 'selectConcept'],
249253
mounted () {
250254
// scroll automatically to selected concept after the whole hierarchy tree has been mounted
@@ -284,6 +288,7 @@ function startHierarchyApp () {
284288
:isLast="i == hierarchy.length - 1"
285289
:loadingChildren="loadingChildren"
286290
:openAriaMessage="openAriaMessage"
291+
:goToTheConceptPageAriaMessage="goToTheConceptPageAriaMessage"
287292
@load-children="loadChildren($event)"
288293
@select-concept="selectConcept($event)"
289294
></tab-hier>
@@ -292,7 +297,7 @@ function startHierarchyApp () {
292297
})
293298

294299
tabHierApp.component('tab-hier', {
295-
props: ['concept', 'selectedConcept', 'isTopConcept', 'isLast', 'loadingChildren', 'openAriaMessage'],
300+
props: ['concept', 'selectedConcept', 'isTopConcept', 'isLast', 'loadingChildren', 'openAriaMessage', 'goToTheConceptPageAriaMessage'],
296301
emits: ['loadChildren', 'selectConcept'],
297302
inject: ['partialPageLoad', 'getConceptURL', 'showNotation'],
298303
methods: {
@@ -332,7 +337,7 @@ function startHierarchyApp () {
332337
<a :class="{ 'selected': selectedConcept === concept.uri }"
333338
:href="getConceptURL(concept.uri)"
334339
@click="handleClickConceptEvent($event, concept)"
335-
aria-label="Go to the concept page"
340+
:aria-label="goToTheConceptPageAriaMessage"
336341
>
337342
<span v-if="showNotation && concept.notation" class="concept-notation">{{ concept.notation }} </span>
338343
{{ concept.label }}
@@ -344,6 +349,7 @@ function startHierarchyApp () {
344349
:concept="c"
345350
:selectedConcept="selectedConcept"
346351
:openAriaMessage="openAriaMessage"
352+
:goToTheConceptPageAriaMessage="goToTheConceptPageAriaMessage"
347353
:isTopConcept="false"
348354
:isLast="i == concept.children.length - 1"
349355
:loadingChildren="loadingChildren"

tests/cypress/template/sidebar-hierarchy.cy.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,14 @@ describe('Hierarchy', () => {
118118
cy.visit('/test-hierarchy/fi/')
119119
cy.get('#hierarchy').should('not.have.class', 'disabled').click()
120120
cy.get('#hierarchy-list').find('ul.list-group button').should('have.attr', 'aria-label', 'avaa');
121+
cy.get('.concept-label a').first().should('have.attr', 'aria-label', 'Mene käsitesivulle')
121122
cy.visit('/test-hierarchy/en/')
122123
cy.get('#hierarchy').should('not.have.class', 'disabled').click()
123124
cy.get('#hierarchy-list').find('ul.list-group button').should('have.attr', 'aria-label', 'Open');
125+
cy.get('.concept-label a').first().should('have.attr', 'aria-label', 'Go to the concept page')
124126
cy.visit('/test-hierarchy/sv/')
125127
cy.get('#hierarchy').should('not.have.class', 'disabled').click()
126128
cy.get('#hierarchy-list').find('ul.list-group button').should('have.attr', 'aria-label', 'öppna');
129+
cy.get('.concept-label a').first().should('have.attr', 'aria-label', 'Gå till begreppssidan')
127130
})
128-
129131
})

0 commit comments

Comments
 (0)