Skip to content

Commit a2539b1

Browse files
authored
Merge pull request #3894 from avinxshKD/fix/i18n-hardcoded-aria-labels
Replace hardcoded aria-labels with i18n
2 parents 5bc0741 + c6c61f6 commit a2539b1

23 files changed

+227
-106
lines changed

client/modules/IDE/components/AddToCollectionSketchList.unit.test.jsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ describe('<AddToCollectionSketchList />', () => {
119119

120120
const before = requestCount;
121121

122-
fireEvent.click(screen.getByRole('button', { name: 'Next Page' }));
122+
fireEvent.click(
123+
screen.getByRole('button', { name: 'Pagination.NextPageARIA' })
124+
);
123125

124126
await waitFor(() => {
125127
expect(requestCount).toBeGreaterThan(before);
@@ -134,7 +136,7 @@ describe('<AddToCollectionSketchList />', () => {
134136
await screen.findByText('page1-sketch-1');
135137

136138
expect(
137-
screen.getByRole('button', { name: 'Previous Page' })
139+
screen.getByRole('button', { name: 'Pagination.PreviousPageARIA' })
138140
).toBeDisabled();
139141
});
140142

@@ -165,7 +167,7 @@ describe('<AddToCollectionSketchList />', () => {
165167
await screen.findByText('AddToCollectionSketchList.NoCollections');
166168

167169
expect(
168-
screen.queryByRole('button', { name: 'Next Page' })
170+
screen.queryByRole('button', { name: 'Pagination.NextPageARIA' })
169171
).not.toBeInTheDocument();
170172
});
171173

@@ -253,13 +255,17 @@ describe('<AddToCollectionSketchList />', () => {
253255
let info = document.querySelector('.pagination-info');
254256
expect(info.textContent.replace(/\s+/g, ' ').trim()).toContain('1 - 10');
255257

256-
fireEvent.click(screen.getByRole('button', { name: 'Next Page' }));
258+
fireEvent.click(
259+
screen.getByRole('button', { name: 'Pagination.NextPageARIA' })
260+
);
257261
await screen.findByText('page2-sketch-1');
258262

259263
info = document.querySelector('.pagination-info');
260264
expect(info.textContent.replace(/\s+/g, ' ').trim()).toContain('11 - 20');
261265

262-
fireEvent.click(screen.getByRole('button', { name: 'Next Page' }));
266+
fireEvent.click(
267+
screen.getByRole('button', { name: 'Pagination.NextPageARIA' })
268+
);
263269
await screen.findByText('page3-sketch-1');
264270

265271
info = document.querySelector('.pagination-info');

client/modules/IDE/components/Pagination.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const Pagination = ({
2626
className="page-link"
2727
onClick={() => onPageChange(page - 1)}
2828
disabled={page === 1}
29-
aria-label="Previous Page"
29+
aria-label={t('Pagination.PreviousPageARIA')}
3030
>
3131
{t('Pagination.Previous')}
3232
</button>
@@ -51,7 +51,7 @@ const Pagination = ({
5151
onPageChange(page + 1);
5252
}}
5353
disabled={page === totalPages}
54-
aria-label="Next Page"
54+
aria-label={t('Pagination.NextPageARIA')}
5555
>
5656
{t('Pagination.Next')}
5757
</button>

client/modules/IDE/components/QuickAddList/Icons.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3+
import { useTranslation } from 'react-i18next';
34
import CloseIcon from '../../../../images/close.svg';
45
import CheckIcon from '../../../../images/check_encircled.svg';
56

67
const Icons = ({ isAdded }) => {
8+
const { t } = useTranslation();
79
const classes = [
810
'quick-add__icon',
911
isAdded
@@ -16,13 +18,13 @@ const Icons = ({ isAdded }) => {
1618
<CloseIcon
1719
className="quick-add__remove-icon"
1820
role="img"
19-
aria-label="Descending"
21+
aria-label={t('QuickAddList.ButtonRemoveARIA')}
2022
focusable="false"
2123
/>
2224
<CheckIcon
2325
className="quick-add__add-icon"
2426
role="img"
25-
aria-label="Descending"
27+
aria-label={t('QuickAddList.ButtonAddToCollectionARIA')}
2628
focusable="false"
2729
/>
2830
</div>

client/modules/IDE/components/SketchList.unit.test.jsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ describe('<SketchList />', () => {
134134

135135
expect(screen.queryByRole('table')).not.toBeInTheDocument();
136136
expect(
137-
screen.queryByRole('button', { name: 'Next Page' })
137+
screen.queryByRole('button', { name: 'Pagination.NextPageARIA' })
138138
).not.toBeInTheDocument();
139139
});
140140

@@ -195,7 +195,9 @@ describe('<SketchList />', () => {
195195

196196
const before = requestCount;
197197

198-
fireEvent.click(screen.getByRole('button', { name: 'Next Page' }));
198+
fireEvent.click(
199+
screen.getByRole('button', { name: 'Pagination.NextPageARIA' })
200+
);
199201

200202
await waitFor(() => {
201203
expect(requestCount).toBeGreaterThan(before);
@@ -209,7 +211,9 @@ describe('<SketchList />', () => {
209211
subject();
210212
await screen.findByText('page1-sketch-1');
211213

212-
const prev = screen.getByRole('button', { name: 'Previous Page' });
214+
const prev = screen.getByRole('button', {
215+
name: 'Pagination.PreviousPageARIA'
216+
});
213217
expect(prev).toBeDisabled();
214218
});
215219

@@ -245,10 +249,10 @@ describe('<SketchList />', () => {
245249
await screen.findByText('singlePage-sketch-1');
246250

247251
expect(
248-
screen.queryByRole('button', { name: 'Previous Page' })
252+
screen.queryByRole('button', { name: 'Pagination.PreviousPageARIA' })
249253
).not.toBeInTheDocument();
250254
expect(
251-
screen.queryByRole('button', { name: 'Next Page' })
255+
screen.queryByRole('button', { name: 'Pagination.NextPageARIA' })
252256
).not.toBeInTheDocument();
253257
});
254258
});

client/modules/IDE/components/TextArea.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default function TextArea({ src, className }) {
3232
<TextAreaWrapper>
3333
<textarea className={className}>{src}</textarea>
3434
<CornerButton onClick={copyTextToClipboard}>
35-
<CopyIcon aria-label="Copy" />
35+
<CopyIcon aria-label={t('TextArea.CopyARIA')} />
3636
</CornerButton>
3737
</TextAreaWrapper>
3838
);

client/modules/IDE/components/Toast.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default function Toast() {
1818
<button
1919
className="toast__close"
2020
onClick={() => dispatch(hideToast())}
21-
aria-label="Close Alert"
21+
aria-label={t('Toast.CloseAlertARIA')}
2222
>
2323
<ExitIcon focusable="false" aria-hidden="true" />
2424
</button>

client/modules/IDE/components/VersionPicker.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ const VersionPicker = React.forwardRef(({ onChangeVersion }, ref) => {
7777
return (
7878
<VersionDropdownMenu
7979
className="versionPicker"
80-
aria-label="Select p5.js version"
80+
aria-label={t('Toolbar.SelectVersionARIA')}
8181
anchor={
8282
<VersionPickerButton ref={ref}>
8383
<VersionPickerText>

translations/locales/bn/translations.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@
140140
"IncorrectCurrentPass": "বর্তমান পাসওয়ার্ডটি ভুল।",
141141
"DefaultError": "কিছু সমস্যা হয়েছে।",
142142
"UserNotFound": "ব্যবহারকারী খুঁজে পাওয়া যায়নি",
143-
"NetworkError": "নেটওয়ার্ক ত্রুটি"
143+
"NetworkError": "নেটওয়ার্ক ত্রুটি",
144+
"CloseAlertARIA": "Close Alert"
144145
},
145146
"Toolbar": {
146147
"Preview": "ফলাফল",
@@ -154,7 +155,8 @@
154155
"By": " দ্বারা ",
155156
"CustomLibraryVersion": "কাস্টম p5.js সংস্করণ",
156157
"VersionPickerARIA": "সংস্করণ চয়নকারী",
157-
"NewVersionPickerARIA": "সংস্করণ চয়নকারী"
158+
"NewVersionPickerARIA": "সংস্করণ চয়নকারী",
159+
"SelectVersionARIA": "Select p5.js version"
158160
},
159161
"Console": {
160162
"Title": "কনসোল",
@@ -541,7 +543,9 @@
541543
"Pagination": {
542544
"Next": "Next",
543545
"Previous": "Previous",
544-
"Of": "of"
546+
"Of": "of",
547+
"PreviousPageARIA": "Previous Page",
548+
"NextPageARIA": "Next Page"
545549
},
546550
"SketchList": {
547551
"Title": "p5.js ওয়েব এডিটর | আমার স্কেচগুলি",
@@ -632,5 +636,8 @@
632636
"Label": "ব্যক্তিগত"
633637
},
634638
"Changed": "'{{projectName}}' এখন {{newVisibility}}..."
639+
},
640+
"TextArea": {
641+
"CopyARIA": "Copy"
635642
}
636643
}

translations/locales/de/translations.json

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
"LogoARIA": "{{serviceauth}} logo"
8888
},
8989
"About": {
90-
"Title": "Über",
90+
"Title": "Über",
9191
"TitleHelmet": "p5.js Web Editor | Über",
9292
"Contribute": "Mitwirken",
9393
"NewP5": "Neu bei p5.js?",
@@ -112,7 +112,8 @@
112112
"SketchFailedSave": "Fehler beim Sichern Deines Sketches.",
113113
"AutosaveEnabled": "Automatisches Sichern aktiviert.",
114114
"LangChange": "Sprache geändert",
115-
"SettingsSaved": "Einstellungen gespeichert."
115+
"SettingsSaved": "Einstellungen gespeichert.",
116+
"CloseAlertARIA": "Close Alert"
116117
},
117118
"Toolbar": {
118119
"Preview": "Vorschau",
@@ -123,7 +124,8 @@
123124
"StopSketchARIA": "Sketch stoppen",
124125
"EditSketchARIA": "Sketch Namen bearbeiten",
125126
"NewSketchNameARIA": "Neuer Sketch name",
126-
"By": " von "
127+
"By": " von ",
128+
"SelectVersionARIA": "Select p5.js version"
127129
},
128130
"Console": {
129131
"Title": "Konsole",
@@ -280,7 +282,7 @@
280282
"errorEmptyPassword": "Gib bitte ein Passwort ein",
281283
"errorShortPassword": "Das Passwort muss mindestens aus 6 Zeichen bestehen",
282284
"errorConfirmPassword": "Gib bitte das Passwort erneut ein",
283-
"errorNewPasswordRepeat":"Your New Password must differ from the current one.",
285+
"errorNewPasswordRepeat": "Your New Password must differ from the current one.",
284286
"errorNewPassword": "Gib bitte ein neues Passwort ein oder lass dieses Feld frei.",
285287
"errorEmptyUsername": "Gib bitte einen Nutzernamen ein.",
286288
"errorLongUsername": "Der Nutzername muss weniger als 20 Zeichen haben.",
@@ -401,7 +403,6 @@
401403
"FileUploader": {
402404
"DictDefaultMessage": "Ziehe Dateien hierhin oder klicke um den Dateibrowser zu verwenden."
403405
},
404-
405406
"ErrorModal": {
406407
"MessageLogin": "Um Deinen Sketch sichern zu können musst Du angemeldet sein. Bitte ",
407408
"Login": "Melde Dich an",
@@ -508,7 +509,9 @@
508509
"Pagination": {
509510
"Next": "Next",
510511
"Previous": "Previous",
511-
"Of": "of"
512+
"Of": "of",
513+
"PreviousPageARIA": "Previous Page",
514+
"NextPageARIA": "Next Page"
512515
},
513516
"SketchList": {
514517
"View": "Öffnen",
@@ -593,8 +596,8 @@
593596
"Off": "Aus"
594597
},
595598
"MobileDashboardView": {
596-
"Examples": "Beispiele",
597-
"Sketches": "Sketche",
599+
"Examples": "Beispiele",
600+
"Sketches": "Sketche",
598601
"Collections": "Sammlungen",
599602
"Assets": "Assets",
600603
"MyStuff": "Mein Zeug",
@@ -603,6 +606,8 @@
603606
},
604607
"Explorer": {
605608
"Files": "Dateien"
609+
},
610+
"TextArea": {
611+
"CopyARIA": "Copy"
606612
}
607613
}
608-

translations/locales/en-US/translations.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@
157157
"IncorrectCurrentPass": "Current password is incorrect",
158158
"DefaultError": "Something went wrong",
159159
"UserNotFound": "User not found",
160-
"NetworkError": "Network error"
160+
"NetworkError": "Network error",
161+
"CloseAlertARIA": "Close Alert"
161162
},
162163
"Toolbar": {
163164
"Preview": "Preview",
@@ -171,7 +172,8 @@
171172
"By": " by ",
172173
"CustomLibraryVersion": "Custom p5.js version",
173174
"VersionPickerARIA": "Version picker",
174-
"NewVersionPickerARIA": "Version picker"
175+
"NewVersionPickerARIA": "Version picker",
176+
"SelectVersionARIA": "Select p5.js version"
175177
},
176178
"Console": {
177179
"Title": "Console",
@@ -576,6 +578,9 @@
576578
"Overlay": {
577579
"AriaLabel": "Close {{title}} overlay"
578580
},
581+
"TextArea": {
582+
"CopyARIA": "Copy"
583+
},
579584
"QuickAddList": {
580585
"ButtonRemoveARIA": "Remove from collection",
581586
"ButtonAddToCollectionARIA": "Add to collection",
@@ -584,7 +589,9 @@
584589
"Pagination": {
585590
"Next": "Next",
586591
"Previous": "Previous",
587-
"Of": "of"
592+
"Of": "of",
593+
"PreviousPageARIA": "Previous Page",
594+
"NextPageARIA": "Next Page"
588595
},
589596
"SketchList": {
590597
"View": "View",

0 commit comments

Comments
 (0)