feat: localize hardcoded aria-labels in search and survey components#422
feat: localize hardcoded aria-labels in search and survey components#422tijaruS wants to merge 8 commits intoOneBusAway:developfrom
Conversation
…eated consoleSpy boilerplate, Use path alias in events.test.js import Signed-off-by: Bikram Ghuku <bikramghuku05@gmail.com>
Add followup improvements from Analytics OneBusAway#332 PR
Release 2026.4
aaronbrethorst
left a comment
There was a problem hiding this comment.
Hey Surajit, I appreciate you working on localizing these hardcoded aria-labels — accessibility and i18n are both important, and this PR addresses them together. I found a few things that need to be fixed before we can merge:
Critical
-
Typo in
en.json:"servey"should be"survey". The JSON key on line 75 ofsrc/locales/en.jsonis"servey", but the component uses$t('survey.required_question'). This means the translation lookup will fail at runtime, and users will see the raw key string"survey.required_question"instead of "Required question". Fix the key to"survey". -
3 test failures in
TripPlanSearchField.test.js. The tests query forgetByLabelText('Clear'), but the clear button now uses$t('search.clear'). Since the i18n mock returns the key as a string, the rendered aria-label becomes"search.clear". Update the 3 failing test assertions to match the new translated label. Runnpm run testto verify all tests pass.
Important
-
Run Prettier.
src/components/surveys/SurveyQuestion.sveltefails the formatting check. The import on line 35 uses 2-space indentation instead of the project's tab indentation. Runnpm run formatto fix this. -
Move the import to the top of the
<script>block. InSurveyQuestion.svelte, theimport { t } from 'svelte-i18n'is at line 35, after all the component logic. It should be at the top with the other imports (after line 2). The project convention is imports first, then component logic.
Thanks again, and I look forward to merging this change.
7d8100c to
347909d
Compare
|
Hi @aaronbrethorst, Thank you for your time. I have made all changes. Now the test cases should pass. And I ran |
Summary
Fixes #406
This PR replaces hardcoded English
aria-labelstrings with localized translations using thesvelte-i18nframework. This ensures that screen reader users in other languages hear correctly translated labels instead of English defaults.Key Changes
src/locales/en.json: Added new translation keys:search.clear:"Clear"survey.required_question:"Required question"src/components/trip-planner/TripPlanSearchField.svelte: Updated the clear button to use the$t('search.clear')translation.src/components/surveys/SurveyQuestion.svelte:tstore fromsvelte-i18n.Verification Results
npm run formatto ensure consistent code style in JSON and Svelte files.npm run lintto verify that all imports are correct and there are no illegal variable names (fixed the$tdefinition error).