Skip to content

Commit

Permalink
Separate l10n string for each annotation state
Browse files Browse the repository at this point in the history
a11yAnnotationCreated* and a11yAnnotationSelected*
  • Loading branch information
abaevbog committed Oct 11, 2024
1 parent e5f1456 commit c1c8065
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
9 changes: 3 additions & 6 deletions src/common/reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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');
Expand Down
13 changes: 11 additions & 2 deletions src/en-us.strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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."
};

0 comments on commit c1c8065

Please sign in to comment.