@@ -86,7 +86,9 @@ class AnnotationEditor {
86
86
87
87
_focusEventsAllowed = true ;
88
88
89
- _l10nPromise = null ;
89
+ static _l10nPromise = null ;
90
+
91
+ static _l10nResizer = null ;
90
92
91
93
#isDraggable = false ;
92
94
@@ -206,6 +208,17 @@ class AnnotationEditor {
206
208
* @param {Object } l10n
207
209
*/
208
210
static initialize ( l10n , _uiManager , options ) {
211
+ AnnotationEditor . _l10nResizer ||= Object . freeze ( {
212
+ topLeft : "pdfjs-editor-resizer-top-left" ,
213
+ topMiddle : "pdfjs-editor-resizer-top-middle" ,
214
+ topRight : "pdfjs-editor-resizer-top-right" ,
215
+ middleRight : "pdfjs-editor-resizer-middle-right" ,
216
+ bottomRight : "pdfjs-editor-resizer-bottom-right" ,
217
+ bottomMiddle : "pdfjs-editor-resizer-bottom-middle" ,
218
+ bottomLeft : "pdfjs-editor-resizer-bottom-left" ,
219
+ middleLeft : "pdfjs-editor-resizer-middle-left" ,
220
+ } ) ;
221
+
209
222
AnnotationEditor . _l10nPromise ||= new Map (
210
223
[
211
224
"pdfjs-editor-alt-text-button-label" ,
@@ -214,18 +227,7 @@ class AnnotationEditor {
214
227
"pdfjs-editor-new-alt-text-added-button-label" ,
215
228
"pdfjs-editor-new-alt-text-missing-button-label" ,
216
229
"pdfjs-editor-new-alt-text-to-review-button-label" ,
217
- "pdfjs-editor-resizer-label-topLeft" ,
218
- "pdfjs-editor-resizer-label-topMiddle" ,
219
- "pdfjs-editor-resizer-label-topRight" ,
220
- "pdfjs-editor-resizer-label-middleRight" ,
221
- "pdfjs-editor-resizer-label-bottomRight" ,
222
- "pdfjs-editor-resizer-label-bottomMiddle" ,
223
- "pdfjs-editor-resizer-label-bottomLeft" ,
224
- "pdfjs-editor-resizer-label-middleLeft" ,
225
- ] . map ( str => [
226
- str ,
227
- l10n . get ( str . replaceAll ( / ( [ A - Z ] ) / g, c => `-${ c . toLowerCase ( ) } ` ) ) ,
228
- ] )
230
+ ] . map ( str => [ str , l10n . get ( str ) ] )
229
231
) ;
230
232
231
233
// The string isn't in the above list because the string has a parameter
@@ -1480,9 +1482,7 @@ class AnnotationEditor {
1480
1482
div . addEventListener ( "focus" , this . #resizerFocus. bind ( this , name ) , {
1481
1483
signal,
1482
1484
} ) ;
1483
- AnnotationEditor . _l10nPromise
1484
- . get ( `pdfjs-editor-resizer-label-${ name } ` )
1485
- . then ( msg => div . setAttribute ( "aria-label" , msg ) ) ;
1485
+ div . setAttribute ( "data-l10n-id" , AnnotationEditor . _l10nResizer [ name ] ) ;
1486
1486
}
1487
1487
}
1488
1488
@@ -1517,9 +1517,7 @@ class AnnotationEditor {
1517
1517
for ( const child of children ) {
1518
1518
const div = this . #allResizerDivs[ i ++ ] ;
1519
1519
const name = div . getAttribute ( "data-resizer-name" ) ;
1520
- AnnotationEditor . _l10nPromise
1521
- . get ( `pdfjs-editor-resizer-label-${ name } ` )
1522
- . then ( msg => child . setAttribute ( "aria-label" , msg ) ) ;
1520
+ child . setAttribute ( "data-l10n-id" , AnnotationEditor . _l10nResizer [ name ] ) ;
1523
1521
}
1524
1522
}
1525
1523
0 commit comments