Skip to content

Commit 9253f35

Browse files
authored
Locale update to use ariaLabel method (primefaces#6313)
1 parent 420da6a commit 9253f35

File tree

5 files changed

+104
-101
lines changed

5 files changed

+104
-101
lines changed

components/lib/carousel/Carousel.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import PrimeReact, { PrimeReactContext, localeOption } from '../api/Api';
2+
import PrimeReact, { PrimeReactContext, ariaLabel, localeOption } from '../api/Api';
33
import { useHandleStyle } from '../componentbase/ComponentBase';
44
import { useMergeProps, useMountEffect, usePrevious, useResizeListener, useUpdateEffect } from '../hooks/Hooks';
55
import { ChevronDownIcon } from '../icons/chevrondown';
@@ -510,7 +510,7 @@ export const Carousel = React.memo(
510510
});
511511

512512
const ariaSlideNumber = (value) => {
513-
return localeOption('aria') ? localeOption('aria').slideNumber.replace(/{slideNumber}/g, value) : undefined;
513+
return ariaLabel('slideNumber', { slideNumber: value });
514514
};
515515

516516
const createItems = () => {
@@ -724,7 +724,7 @@ export const Carousel = React.memo(
724724
};
725725

726726
const ariaPageLabel = (value) => {
727-
return localeOption('aria') ? localeOption('aria').pageLabel.replace(/{page}/g, value) : undefined;
727+
return ariaLabel('pageLabel', { page: value });
728728
};
729729

730730
const createIndicator = (index) => {

components/lib/galleria/GalleriaItem.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { localeOption } from '../api/Api';
2+
import { ariaLabel, localeOption } from '../api/Api';
33
import { useMergeProps, useMountEffect } from '../hooks/Hooks';
44
import { ChevronLeftIcon } from '../icons/chevronleft';
55
import { ChevronRightIcon } from '../icons/chevronright';
@@ -21,11 +21,11 @@ export const GalleriaItem = React.memo(
2121
};
2222

2323
const ariaSlideNumber = (value) => {
24-
return localeOption('aria') ? localeOption('aria').slideNumber.replace(/{slideNumber}/g, value) : undefined;
24+
return ariaLabel('slideNumber', { slideNumber: value });
2525
};
2626

2727
const ariaPageLabel = (value) => {
28-
return localeOption('aria') ? localeOption('aria').pageLabel.replace(/{page}/g, value) : undefined;
28+
return ariaLabel('pageLabel', { page: value });
2929
};
3030

3131
const next = () => {

components/lib/galleria/GalleriaThumbnails.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import PrimeReact, { PrimeReactContext, localeOption } from '../api/Api';
2+
import PrimeReact, { PrimeReactContext, ariaLabel, localeOption } from '../api/Api';
33
import { useMergeProps, useMountEffect, usePrevious, useResizeListener, useUpdateEffect } from '../hooks/Hooks';
44
import { ChevronDownIcon } from '../icons/chevrondown';
55
import { ChevronLeftIcon } from '../icons/chevronleft';
@@ -27,7 +27,7 @@ const GalleriaThumbnailItem = React.memo((props) => {
2727
};
2828

2929
const ariaPageLabel = (value) => {
30-
return localeOption('aria') ? localeOption('aria').pageLabel.replace(/{page}/g, value) : undefined;
30+
return ariaLabel('pageLabel', { page: value });
3131
};
3232

3333
const onThumbnailKeydown = (event) => {

components/lib/hooks/useLocale.js

Lines changed: 91 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -5,125 +5,127 @@ import PrimeReact from '../api/Api';
55

66
let locales = {
77
en: {
8-
startsWith: 'Starts with',
8+
accept: 'Yes',
9+
addRule: 'Add Rule',
10+
am: 'AM',
11+
apply: 'Apply',
12+
cancel: 'Cancel',
13+
choose: 'Choose',
14+
chooseDate: 'Choose Date',
15+
chooseMonth: 'Choose Month',
16+
chooseYear: 'Choose Year',
17+
clear: 'Clear',
18+
completed: 'Completed',
919
contains: 'Contains',
10-
notContains: 'Not contains',
20+
custom: 'Custom',
21+
dateAfter: 'Date is after',
22+
dateBefore: 'Date is before',
23+
dateFormat: 'mm/dd/yy',
24+
dateIs: 'Date is',
25+
dateIsNot: 'Date is not',
26+
dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
27+
dayNamesMin: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
28+
dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
29+
emptyFilterMessage: 'No results found',
30+
emptyMessage: 'No available options',
31+
emptySearchMessage: 'No results found',
32+
emptySelectionMessage: 'No selected item',
1133
endsWith: 'Ends with',
1234
equals: 'Equals',
13-
notEquals: 'Not equals',
14-
noFilter: 'No Filter',
35+
fileSizeTypes: ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
1536
filter: 'Filter',
16-
lt: 'Less than',
17-
lte: 'Less than or equal to',
37+
firstDayOfWeek: 0,
1838
gt: 'Greater than',
1939
gte: 'Greater than or equal to',
20-
dateIs: 'Date is',
21-
dateIsNot: 'Date is not',
22-
dateBefore: 'Date is before',
23-
dateAfter: 'Date is after',
24-
custom: 'Custom',
25-
clear: 'Clear',
26-
close: 'Close',
27-
apply: 'Apply',
40+
lt: 'Less than',
41+
lte: 'Less than or equal to',
2842
matchAll: 'Match All',
2943
matchAny: 'Match Any',
30-
addRule: 'Add Rule',
31-
removeRule: 'Remove Rule',
32-
accept: 'Yes',
33-
reject: 'No',
34-
choose: 'Choose',
35-
upload: 'Upload',
36-
cancel: 'Cancel',
37-
pending: 'Pending',
38-
fileSizeTypes: ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
39-
dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
40-
dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
41-
dayNamesMin: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
44+
medium: 'Medium',
4245
monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
4346
monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
44-
chooseYear: 'Choose Year',
45-
chooseMonth: 'Choose Month',
46-
chooseDate: 'Choose Date',
47-
prevDecade: 'Previous Decade',
4847
nextDecade: 'Next Decade',
49-
prevYear: 'Previous Year',
50-
nextYear: 'Next Year',
51-
prevMonth: 'Previous Month',
48+
nextHour: 'Next Hour',
49+
nextMinute: 'Next Minute',
5250
nextMonth: 'Next Month',
51+
nextSecond: 'Next Second',
52+
nextYear: 'Next Year',
53+
noFilter: 'No Filter',
54+
notContains: 'Not contains',
55+
notEquals: 'Not equals',
56+
now: 'Now',
57+
passwordPrompt: 'Enter a password',
58+
pending: 'Pending',
59+
pm: 'PM',
60+
prevDecade: 'Previous Decade',
5361
prevHour: 'Previous Hour',
54-
nextHour: 'Next Hour',
5562
prevMinute: 'Previous Minute',
56-
nextMinute: 'Next Minute',
63+
prevMonth: 'Previous Month',
5764
prevSecond: 'Previous Second',
58-
nextSecond: 'Next Second',
59-
prevMilliSecond: 'Previous Second',
60-
nextMilliSecond: 'Next Second',
61-
am: 'am',
62-
pm: 'pm',
65+
prevYear: 'Previous Year',
66+
reject: 'No',
67+
removeRule: 'Remove Rule',
68+
searchMessage: '{0} results are available',
69+
selectionMessage: '{0} items selected',
70+
showMonthAfterYear: false,
71+
startsWith: 'Starts with',
72+
strong: 'Strong',
6373
today: 'Today',
64-
weekHeader: 'Wk',
65-
firstDayOfWeek: 0,
66-
showMonthAfterYear: true,
67-
dateFormat: 'mm/dd/yy',
74+
upload: 'Upload',
6875
weak: 'Weak',
69-
medium: 'Medium',
70-
strong: 'Strong',
71-
passwordPrompt: 'Enter a password',
72-
emptyFilterMessage: 'No available options',
73-
emptyMessage: 'No results found',
76+
weekHeader: 'Wk',
7477
aria: {
75-
trueLabel: 'True',
76-
falseLabel: 'False',
77-
nullLabel: 'Not Selected',
78-
star: '1 star',
79-
stars: '{star} stars',
80-
selectAll: 'All items selected',
81-
unselectAll: 'All items unselected',
78+
cancelEdit: 'Cancel Edit',
8279
close: 'Close',
83-
previous: 'Previous',
84-
next: 'Next',
85-
navigation: 'Navigation',
86-
scrollTop: 'Scroll Top',
87-
moveTop: 'Move Top',
88-
moveUp: 'Move Up',
89-
moveDown: 'Move Down',
90-
moveBottom: 'Move Bottom',
91-
moveToTarget: 'Move to Target',
92-
moveToSource: 'Move to Source',
93-
moveAllToTarget: 'Move All to Target',
94-
moveAllToSource: 'Move All to Source',
95-
pageLabel: 'Page {page}',
80+
collapseRow: 'Row Collapsed',
81+
editRow: 'Edit Row',
82+
expandRow: 'Row Expanded',
83+
falseLabel: 'False',
84+
filterConstraint: 'Filter Constraint',
85+
filterOperator: 'Filter Operator',
9686
firstPageLabel: 'First Page',
87+
gridView: 'Grid View',
88+
hideFilterMenu: 'Hide Filter Menu',
89+
jumpToPageDropdownLabel: 'Jump to Page Dropdown',
90+
jumpToPageInputLabel: 'Jump to Page Input',
9791
lastPageLabel: 'Last Page',
92+
listView: 'List View',
93+
moveAllToSource: 'Move All to Source',
94+
moveAllToTarget: 'Move All to Target',
95+
moveBottom: 'Move Bottom',
96+
moveDown: 'Move Down',
97+
moveToSource: 'Move to Source',
98+
moveToTarget: 'Move to Target',
99+
moveTop: 'Move Top',
100+
moveUp: 'Move Up',
101+
navigation: 'Navigation',
102+
next: 'Next',
98103
nextPageLabel: 'Next Page',
104+
nullLabel: 'Not Selected',
105+
pageLabel: 'Page {page}',
106+
otpLabel: 'Please enter one time password character {0}',
107+
passwordHide: 'Hide Password',
108+
passwordShow: 'Show Password',
109+
previous: 'Previous',
99110
previousPageLabel: 'Previous Page',
111+
rotateLeft: 'Rotate Left',
112+
rotateRight: 'Rotate Right',
100113
rowsPerPageLabel: 'Rows per page',
101-
jumpToPageDropdownLabel: 'Jump to Page Dropdown',
102-
jumpToPageInputLabel: 'Jump to Page Input',
114+
saveEdit: 'Save Edit',
115+
scrollTop: 'Scroll Top',
116+
selectAll: 'All items selected',
103117
selectRow: 'Row Selected',
104-
unselectRow: 'Row Unselected',
105-
expandRow: 'Row Expanded',
106-
collapseRow: 'Row Collapsed',
107118
showFilterMenu: 'Show Filter Menu',
108-
hideFilterMenu: 'Hide Filter Menu',
109-
filterOperator: 'Filter Operator',
110-
filterConstraint: 'Filter Constraint',
111-
editRow: 'Row Edit',
112-
saveEdit: 'Save Edit',
113-
cancelEdit: 'Cancel Edit',
114-
listView: 'List View',
115-
gridView: 'Grid View',
116119
slide: 'Slide',
117120
slideNumber: '{slideNumber}',
121+
star: '1 star',
122+
stars: '{star} stars',
123+
trueLabel: 'True',
124+
unselectAll: 'All items unselected',
125+
unselectRow: 'Row Unselected',
118126
zoomImage: 'Zoom Image',
119127
zoomIn: 'Zoom In',
120-
zoomOut: 'Zoom Out',
121-
rotateRight: 'Rotate Right',
122-
rotateLeft: 'Rotate Left',
123-
selectLabel: 'Select',
124-
unselectLabel: 'Unselect',
125-
expandLabel: 'Expand',
126-
collapseLabel: 'Collapse'
128+
zoomOut: 'Zoom Out'
127129
}
128130
}
129131
};

components/lib/inputotp/InputOtp.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import React, { useRef, useContext, useState } from 'react';
2-
import { useMergeProps } from '../hooks/Hooks';
3-
import { PrimeReactContext } from '../api/Api';
4-
import { InputOtpBase } from './BaseInputOtp';
51
import { InputText } from '@/components/lib/inputtext/InputText';
2+
import React, { useContext, useRef, useState } from 'react';
3+
import { PrimeReactContext, ariaLabel } from '../api/Api';
64
import { useHandleStyle } from '../componentbase/ComponentBase';
5+
import { useMergeProps } from '../hooks/Hooks';
76
import { ObjectUtils } from '../utils/Utils';
7+
import { InputOtpBase } from './BaseInputOtp';
88

99
export const InputOtp = React.memo(
1010
React.forwardRef((inProps, ref) => {
@@ -179,6 +179,7 @@ export const InputOtp = React.memo(
179179
invalid: props?.invalid,
180180
tabIndex: props?.tabIndex,
181181
unstyled: props?.unstyled,
182+
'aria-label': ariaLabel('otpLabel', { 0: inputElementIndex + 1 }),
182183
className: cx('input')
183184
},
184185
ptm('input')

0 commit comments

Comments
 (0)