From c1c806548ad0e6d2424b77083be12d13dc426d49 Mon Sep 17 00:00:00 2001 From: Bogdan Abaev Date: Thu, 10 Oct 2024 23:15:09 -0700 Subject: [PATCH] Separate l10n string for each annotation state a11yAnnotationCreated* and a11yAnnotationSelected* --- src/common/reader.js | 9 +++------ src/en-us.strings.js | 13 +++++++++++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/common/reader.js b/src/common/reader.js index c2e8ec35..0a0eda0b 100644 --- a/src/common/reader.js +++ b/src/common/reader.js @@ -273,8 +273,7 @@ class Reader { annotation = this._annotationManager.addAnnotation(annotation); // Tell screen readers the annotation was added after focus is settled setTimeout(() => { - let annotationType = this._getString(`pdfReader.${annotation.type}Annotation`); - this.setA11yMessage(annotationType + ' ' + this._getString('pdfReader.a11yAnnotationCreated')); + this.setA11yMessage(this._getString(`pdfReader.a11yAnnotationCreated.${annotation.type}`)); }, 100); if (select) { this.setSelectedAnnotations([annotation.id]); @@ -789,8 +788,7 @@ class Reader { annotation = this._annotationManager.addAnnotation(annotation); // Tell screen readers the annotation was added after focus is settled setTimeout(() => { - let annotationType = this._getString(`pdfReader.${annotation.type}Annotation`); - this.setA11yMessage(annotationType + ' ' + this._getString('pdfReader.a11yAnnotationCreated')); + this.setA11yMessage(this._getString(`pdfReader.a11yAnnotationCreated.${annotation.type}`)); }, 100); if (select) { this.setSelectedAnnotations([annotation.id], true); @@ -1218,8 +1216,7 @@ class Reader { // After a small delay for focus to settle, announce to screen readers that annotation // is selected and how one can manipulate it setTimeout(() => { - let annotationType = this._getString(`pdfReader.${annotation.type}Annotation`); - let a11yAnnouncement = annotationType + ' ' + this._getString('pdfReader.a11yAnnotationSelected'); + let a11yAnnouncement = this._getString(`pdfReader.a11yAnnotationSelected.${annotation.type}`); if (document.querySelector('.annotation-popup')) { // add note that popup is opened a11yAnnouncement += ' ' + this._getString('pdfReader.a11yAnnotationPopupAppeared'); diff --git a/src/en-us.strings.js b/src/en-us.strings.js index 3c550833..85aec94b 100644 --- a/src/en-us.strings.js +++ b/src/en-us.strings.js @@ -201,8 +201,17 @@ export default { 'pdfReader.a11yMoveAnnotation': 'Use the arrow keys to move the annotation.', 'pdfReader.a11yEditTextAnnotation': 'To move the end of the text annotation, use the left/right arrow keys while holding Shift. To move the start of the annotation, use the arrow keys while holding Shift -', 'pdfReader.a11yResizeAnnotation': 'To resize the annotation, use the arrow keys while holding Shift.', - 'pdfReader.a11yAnnotationSelected': 'selected.', 'pdfReader.a11yAnnotationPopupAppeared': 'Use Tab to navigate the annotation popup.', - 'pdfReader.a11yAnnotationCreated': 'has been created.', + "pdfReader.a11yAnnotationCreated.highlight": "A highlight annotation has been created.", + "pdfReader.a11yAnnotationCreated.underline": "An underline annotation has been created.", + "pdfReader.a11yAnnotationCreated.note": "A note annotation has been created.", + "pdfReader.a11yAnnotationCreated.text": "A text annotation has been created.", + "pdfReader.a11yAnnotationCreated.image": "An image annotation has been created.", + + "pdfReader.a11yAnnotationSelected.highlight": "A highlight annotation has been selected.", + "pdfReader.a11yAnnotationSelected.underline": "An underline annotation has been selected.", + "pdfReader.a11yAnnotationSelected.note": "A note annotation has been selected.", + "pdfReader.a11yAnnotationSelected.text": "A text annotation has been selected.", + "pdfReader.a11yAnnotationSelected.image": "An image annotation has been selected." };