Skip to content

Commit

Permalink
Locale update to use ariaLabel method (#6313)
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware authored Apr 9, 2024
1 parent 420da6a commit 9253f35
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 101 deletions.
6 changes: 3 additions & 3 deletions components/lib/carousel/Carousel.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import PrimeReact, { PrimeReactContext, localeOption } from '../api/Api';
import PrimeReact, { PrimeReactContext, ariaLabel, localeOption } from '../api/Api';
import { useHandleStyle } from '../componentbase/ComponentBase';
import { useMergeProps, useMountEffect, usePrevious, useResizeListener, useUpdateEffect } from '../hooks/Hooks';
import { ChevronDownIcon } from '../icons/chevrondown';
Expand Down Expand Up @@ -510,7 +510,7 @@ export const Carousel = React.memo(
});

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

const createItems = () => {
Expand Down Expand Up @@ -724,7 +724,7 @@ export const Carousel = React.memo(
};

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

const createIndicator = (index) => {
Expand Down
6 changes: 3 additions & 3 deletions components/lib/galleria/GalleriaItem.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { localeOption } from '../api/Api';
import { ariaLabel, localeOption } from '../api/Api';
import { useMergeProps, useMountEffect } from '../hooks/Hooks';
import { ChevronLeftIcon } from '../icons/chevronleft';
import { ChevronRightIcon } from '../icons/chevronright';
Expand All @@ -21,11 +21,11 @@ export const GalleriaItem = React.memo(
};

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

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

const next = () => {
Expand Down
4 changes: 2 additions & 2 deletions components/lib/galleria/GalleriaThumbnails.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import PrimeReact, { PrimeReactContext, localeOption } from '../api/Api';
import PrimeReact, { PrimeReactContext, ariaLabel, localeOption } from '../api/Api';
import { useMergeProps, useMountEffect, usePrevious, useResizeListener, useUpdateEffect } from '../hooks/Hooks';
import { ChevronDownIcon } from '../icons/chevrondown';
import { ChevronLeftIcon } from '../icons/chevronleft';
Expand Down Expand Up @@ -27,7 +27,7 @@ const GalleriaThumbnailItem = React.memo((props) => {
};

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

const onThumbnailKeydown = (event) => {
Expand Down
180 changes: 91 additions & 89 deletions components/lib/hooks/useLocale.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,125 +5,127 @@ import PrimeReact from '../api/Api';

let locales = {
en: {
startsWith: 'Starts with',
accept: 'Yes',
addRule: 'Add Rule',
am: 'AM',
apply: 'Apply',
cancel: 'Cancel',
choose: 'Choose',
chooseDate: 'Choose Date',
chooseMonth: 'Choose Month',
chooseYear: 'Choose Year',
clear: 'Clear',
completed: 'Completed',
contains: 'Contains',
notContains: 'Not contains',
custom: 'Custom',
dateAfter: 'Date is after',
dateBefore: 'Date is before',
dateFormat: 'mm/dd/yy',
dateIs: 'Date is',
dateIsNot: 'Date is not',
dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
dayNamesMin: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
emptyFilterMessage: 'No results found',
emptyMessage: 'No available options',
emptySearchMessage: 'No results found',
emptySelectionMessage: 'No selected item',
endsWith: 'Ends with',
equals: 'Equals',
notEquals: 'Not equals',
noFilter: 'No Filter',
fileSizeTypes: ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
filter: 'Filter',
lt: 'Less than',
lte: 'Less than or equal to',
firstDayOfWeek: 0,
gt: 'Greater than',
gte: 'Greater than or equal to',
dateIs: 'Date is',
dateIsNot: 'Date is not',
dateBefore: 'Date is before',
dateAfter: 'Date is after',
custom: 'Custom',
clear: 'Clear',
close: 'Close',
apply: 'Apply',
lt: 'Less than',
lte: 'Less than or equal to',
matchAll: 'Match All',
matchAny: 'Match Any',
addRule: 'Add Rule',
removeRule: 'Remove Rule',
accept: 'Yes',
reject: 'No',
choose: 'Choose',
upload: 'Upload',
cancel: 'Cancel',
pending: 'Pending',
fileSizeTypes: ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
dayNamesMin: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
medium: 'Medium',
monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
chooseYear: 'Choose Year',
chooseMonth: 'Choose Month',
chooseDate: 'Choose Date',
prevDecade: 'Previous Decade',
nextDecade: 'Next Decade',
prevYear: 'Previous Year',
nextYear: 'Next Year',
prevMonth: 'Previous Month',
nextHour: 'Next Hour',
nextMinute: 'Next Minute',
nextMonth: 'Next Month',
nextSecond: 'Next Second',
nextYear: 'Next Year',
noFilter: 'No Filter',
notContains: 'Not contains',
notEquals: 'Not equals',
now: 'Now',
passwordPrompt: 'Enter a password',
pending: 'Pending',
pm: 'PM',
prevDecade: 'Previous Decade',
prevHour: 'Previous Hour',
nextHour: 'Next Hour',
prevMinute: 'Previous Minute',
nextMinute: 'Next Minute',
prevMonth: 'Previous Month',
prevSecond: 'Previous Second',
nextSecond: 'Next Second',
prevMilliSecond: 'Previous Second',
nextMilliSecond: 'Next Second',
am: 'am',
pm: 'pm',
prevYear: 'Previous Year',
reject: 'No',
removeRule: 'Remove Rule',
searchMessage: '{0} results are available',
selectionMessage: '{0} items selected',
showMonthAfterYear: false,
startsWith: 'Starts with',
strong: 'Strong',
today: 'Today',
weekHeader: 'Wk',
firstDayOfWeek: 0,
showMonthAfterYear: true,
dateFormat: 'mm/dd/yy',
upload: 'Upload',
weak: 'Weak',
medium: 'Medium',
strong: 'Strong',
passwordPrompt: 'Enter a password',
emptyFilterMessage: 'No available options',
emptyMessage: 'No results found',
weekHeader: 'Wk',
aria: {
trueLabel: 'True',
falseLabel: 'False',
nullLabel: 'Not Selected',
star: '1 star',
stars: '{star} stars',
selectAll: 'All items selected',
unselectAll: 'All items unselected',
cancelEdit: 'Cancel Edit',
close: 'Close',
previous: 'Previous',
next: 'Next',
navigation: 'Navigation',
scrollTop: 'Scroll Top',
moveTop: 'Move Top',
moveUp: 'Move Up',
moveDown: 'Move Down',
moveBottom: 'Move Bottom',
moveToTarget: 'Move to Target',
moveToSource: 'Move to Source',
moveAllToTarget: 'Move All to Target',
moveAllToSource: 'Move All to Source',
pageLabel: 'Page {page}',
collapseRow: 'Row Collapsed',
editRow: 'Edit Row',
expandRow: 'Row Expanded',
falseLabel: 'False',
filterConstraint: 'Filter Constraint',
filterOperator: 'Filter Operator',
firstPageLabel: 'First Page',
gridView: 'Grid View',
hideFilterMenu: 'Hide Filter Menu',
jumpToPageDropdownLabel: 'Jump to Page Dropdown',
jumpToPageInputLabel: 'Jump to Page Input',
lastPageLabel: 'Last Page',
listView: 'List View',
moveAllToSource: 'Move All to Source',
moveAllToTarget: 'Move All to Target',
moveBottom: 'Move Bottom',
moveDown: 'Move Down',
moveToSource: 'Move to Source',
moveToTarget: 'Move to Target',
moveTop: 'Move Top',
moveUp: 'Move Up',
navigation: 'Navigation',
next: 'Next',
nextPageLabel: 'Next Page',
nullLabel: 'Not Selected',
pageLabel: 'Page {page}',
otpLabel: 'Please enter one time password character {0}',
passwordHide: 'Hide Password',
passwordShow: 'Show Password',
previous: 'Previous',
previousPageLabel: 'Previous Page',
rotateLeft: 'Rotate Left',
rotateRight: 'Rotate Right',
rowsPerPageLabel: 'Rows per page',
jumpToPageDropdownLabel: 'Jump to Page Dropdown',
jumpToPageInputLabel: 'Jump to Page Input',
saveEdit: 'Save Edit',
scrollTop: 'Scroll Top',
selectAll: 'All items selected',
selectRow: 'Row Selected',
unselectRow: 'Row Unselected',
expandRow: 'Row Expanded',
collapseRow: 'Row Collapsed',
showFilterMenu: 'Show Filter Menu',
hideFilterMenu: 'Hide Filter Menu',
filterOperator: 'Filter Operator',
filterConstraint: 'Filter Constraint',
editRow: 'Row Edit',
saveEdit: 'Save Edit',
cancelEdit: 'Cancel Edit',
listView: 'List View',
gridView: 'Grid View',
slide: 'Slide',
slideNumber: '{slideNumber}',
star: '1 star',
stars: '{star} stars',
trueLabel: 'True',
unselectAll: 'All items unselected',
unselectRow: 'Row Unselected',
zoomImage: 'Zoom Image',
zoomIn: 'Zoom In',
zoomOut: 'Zoom Out',
rotateRight: 'Rotate Right',
rotateLeft: 'Rotate Left',
selectLabel: 'Select',
unselectLabel: 'Unselect',
expandLabel: 'Expand',
collapseLabel: 'Collapse'
zoomOut: 'Zoom Out'
}
}
};
Expand Down
9 changes: 5 additions & 4 deletions components/lib/inputotp/InputOtp.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { useRef, useContext, useState } from 'react';
import { useMergeProps } from '../hooks/Hooks';
import { PrimeReactContext } from '../api/Api';
import { InputOtpBase } from './BaseInputOtp';
import { InputText } from '@/components/lib/inputtext/InputText';
import React, { useContext, useRef, useState } from 'react';
import { PrimeReactContext, ariaLabel } from '../api/Api';
import { useHandleStyle } from '../componentbase/ComponentBase';
import { useMergeProps } from '../hooks/Hooks';
import { ObjectUtils } from '../utils/Utils';
import { InputOtpBase } from './BaseInputOtp';

export const InputOtp = React.memo(
React.forwardRef((inProps, ref) => {
Expand Down Expand Up @@ -179,6 +179,7 @@ export const InputOtp = React.memo(
invalid: props?.invalid,
tabIndex: props?.tabIndex,
unstyled: props?.unstyled,
'aria-label': ariaLabel('otpLabel', { 0: inputElementIndex + 1 }),
className: cx('input')
},
ptm('input')
Expand Down

0 comments on commit 9253f35

Please sign in to comment.