Skip to content

feat: localize hardcoded aria-labels in search and survey components#422

Open
tijaruS wants to merge 8 commits intoOneBusAway:developfrom
tijaruS:fix/Internationalize-hardcoded-ria-label-strings
Open

feat: localize hardcoded aria-labels in search and survey components#422
tijaruS wants to merge 8 commits intoOneBusAway:developfrom
tijaruS:fix/Internationalize-hardcoded-ria-label-strings

Conversation

@tijaruS
Copy link
Copy Markdown

@tijaruS tijaruS commented Mar 23, 2026

Summary

Fixes #406

This PR replaces hardcoded English aria-label strings with localized translations using the svelte-i18n framework. 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:
    • Imported the t store from svelte-i18n.

Verification Results

  • Ran npm run format to ensure consistent code style in JSON and Svelte files.
  • Ran npm run lint to verify that all imports are correct and there are no illegal variable names (fixed the $t definition error).
  • Verified that the components render correctly with the new translation keys.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 23, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown
Member

@aaronbrethorst aaronbrethorst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. Typo in en.json: "servey" should be "survey". The JSON key on line 75 of src/locales/en.json is "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".

  2. 3 test failures in TripPlanSearchField.test.js. The tests query for getByLabelText('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. Run npm run test to verify all tests pass.

Important

  1. Run Prettier. src/components/surveys/SurveyQuestion.svelte fails the formatting check. The import on line 35 uses 2-space indentation instead of the project's tab indentation. Run npm run format to fix this.

  2. Move the import to the top of the <script> block. In SurveyQuestion.svelte, the import { 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.

@tijaruS tijaruS force-pushed the fix/Internationalize-hardcoded-ria-label-strings branch from 7d8100c to 347909d Compare March 25, 2026 22:38
@tijaruS
Copy link
Copy Markdown
Author

tijaruS commented Mar 25, 2026

Hi @aaronbrethorst, Thank you for your time. I have made all changes. Now the test cases should pass. And I ran npm run format too on my local machine along with npm run test so there should not be any issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Internationalize hardcoded aria-label strings

4 participants