-
Notifications
You must be signed in to change notification settings - Fork 120
feat(#4655): add AI Catalog translations for supported RHDH locales #4841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
00f528e
feat(#4655): add AI Catalog translations for supported RHDH locales
fullsend-ai-coder[bot] 608bf2e
fix: address review feedback on PR #4841
fullsend-ai-coder[bot] fd6feb3
fix: resolve CI failures in translation e2e tests for PR #4841
fullsend-ai-coder[bot] 32e0c61
fix: move accessibility check to empty-state test to avoid color-cont…
fullsend-ai-coder[bot] d00b6ee
fix(boost): make locale switching update catalog UI
rohitkrai03 1c12fb8
chore(boost): refresh API reports
rohitkrai03 107f1f2
chore(boost): refresh API reports for CI
rohitkrai03 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@red-hat-developer-hub/backstage-plugin-boost': minor | ||
| --- | ||
|
|
||
| Add German, Spanish, French, Italian, and Japanese translation files for the AI Catalog frontend. Register all five locales as lazy imports in the translation resource. Add focused tests for locale key parity, interpolation placeholder preservation, and Playwright locale coverage. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,162 @@ | ||
| /* | ||
| * Copyright Red Hat, Inc. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import { expect, test, type Page, type Route } from '@playwright/test'; | ||
|
|
||
| import { runAccessibilityTests } from './utils/accessibility'; | ||
| import { getTranslations, type BoostMessages } from './utils/translations'; | ||
|
|
||
| const LOCALE_DISPLAY_NAMES: Record<string, string> = { | ||
| en: 'English', | ||
| de: 'Deutsch', | ||
| es: 'Español', | ||
| fr: 'Français', | ||
| it: 'Italiano', | ||
| ja: '日本語', | ||
| }; | ||
|
|
||
| const skillEntity = { | ||
| apiVersion: 'backstage.io/v1alpha1', | ||
| kind: 'AiResource', | ||
| metadata: { | ||
| name: 'code-review-skill', | ||
| title: 'Code Review Skill', | ||
| description: 'Automated code review for common issues.', | ||
| namespace: 'default', | ||
| uid: 'uid-1', | ||
| tags: ['security'], | ||
| annotations: { 'rhdh.io/ai-asset-source': 'github' }, | ||
| }, | ||
| spec: { type: 'skill', lifecycle: 'production', owner: 'team-ai-platform' }, | ||
| }; | ||
|
|
||
| function isCatalogEntitiesPath(url: URL): boolean { | ||
| return ( | ||
| url.pathname.endsWith('/api/catalog/entities') && | ||
| !url.pathname.includes('/by-query') | ||
| ); | ||
| } | ||
|
|
||
| async function mockCatalogEntities(page: Page, items: unknown[]) { | ||
| const fulfillItemsWrapper = async (route: Route) => | ||
| route.fulfill({ | ||
| status: 200, | ||
| contentType: 'application/json', | ||
| body: JSON.stringify({ items }), | ||
| }); | ||
|
|
||
| await page.route('**/api/catalog/entities/by-query**', fulfillItemsWrapper); | ||
| await page.route(isCatalogEntitiesPath, async route => { | ||
| if (route.request().method() === 'GET') { | ||
| await route.fulfill({ | ||
| status: 200, | ||
| contentType: 'application/json', | ||
| body: JSON.stringify(items), | ||
| }); | ||
| return; | ||
| } | ||
| await fulfillItemsWrapper(route); | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Sign in as a guest, switch the app language through Settings, and wait for | ||
| * the authenticated app shell to render. | ||
| */ | ||
| async function signInAndSwitchLocale( | ||
| page: Page, | ||
| locale: string, | ||
| ): Promise<void> { | ||
| page.on('dialog', dialog => dialog.accept()); | ||
| await page.goto('/'); | ||
| const enter = page.getByRole('button', { name: 'Enter' }); | ||
| const settingsLink = page.getByRole('link', { name: 'Settings' }); | ||
| await expect(enter.or(settingsLink).first()).toBeVisible({ | ||
| timeout: 30_000, | ||
| }); | ||
| if (await enter.isVisible()) { | ||
| await enter.click(); | ||
| await settingsLink.waitFor({ state: 'visible', timeout: 30_000 }); | ||
| } | ||
|
|
||
| const baseLocale = locale.split('-')[0]; | ||
| if (baseLocale !== 'en') { | ||
| await settingsLink.click(); | ||
| await page.getByRole('button', { name: 'English' }).click(); | ||
| await page | ||
| .getByRole('option', { name: LOCALE_DISPLAY_NAMES[baseLocale] }) | ||
| .click(); | ||
| } | ||
| } | ||
|
|
||
| test.describe('Boost AI Catalog translations', () => { | ||
| test('renders representative strings in the configured locale', async ({ | ||
| page, | ||
| }) => { | ||
| const currentLocale = await page.evaluate( | ||
| () => globalThis.navigator.language, | ||
| ); | ||
| const baseLocale = currentLocale.split('-')[0]; | ||
| const translations: BoostMessages = getTranslations(baseLocale); | ||
|
|
||
| await mockCatalogEntities(page, [skillEntity]); | ||
| await signInAndSwitchLocale(page, currentLocale); | ||
|
|
||
| await page.getByRole('link', { name: translations.nav.aiCatalog }).click(); | ||
|
|
||
| // This heading is rendered by the page component so it updates at runtime. | ||
| await expect( | ||
| page.getByRole('heading', { name: translations.catalog.page.title }), | ||
| ).toBeVisible(); | ||
| // Verify translated controls from both the filter sidebar and toolbar. | ||
| await expect( | ||
| page.getByRole('navigation', { | ||
| name: translations.catalog.filter.title, | ||
| }), | ||
| ).toBeVisible(); | ||
| await expect( | ||
| page.getByRole('searchbox', { | ||
| name: translations.catalog.toolbar.search, | ||
| }), | ||
| ).toBeVisible(); | ||
| }); | ||
|
|
||
| test('renders empty state in the configured locale', async ({ | ||
| page, | ||
| }, testInfo) => { | ||
| const currentLocale = await page.evaluate( | ||
| () => globalThis.navigator.language, | ||
| ); | ||
| const baseLocale = currentLocale.split('-')[0]; | ||
| const translations: BoostMessages = getTranslations(baseLocale); | ||
|
|
||
| await mockCatalogEntities(page, []); | ||
| await signInAndSwitchLocale(page, currentLocale); | ||
|
|
||
| await page.getByRole('link', { name: translations.nav.aiCatalog }).click(); | ||
|
|
||
| await expect( | ||
| page.getByText(translations.catalog.empty.title), | ||
| ).toBeVisible(); | ||
| await expect( | ||
| page.getByRole('button', { name: translations.catalog.empty.refresh }), | ||
| ).toBeVisible(); | ||
|
|
||
| // Accessibility check on the empty state avoids the known | ||
| // color-contrast violation on category badges (RHDHBUGS-3738). | ||
| await runAccessibilityTests(page, testInfo); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /* | ||
| * Copyright Red Hat, Inc. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import { test, type TestInfo } from '@playwright/test'; | ||
|
|
||
| /** | ||
| * Skips the current test when the project (locale) is in the given list. | ||
| * Call at the start of a test so it still runs on other locales. | ||
| */ | ||
| export function skipIfLocales( | ||
| testInfo: TestInfo, | ||
| locales: string[], | ||
| reason: string, | ||
| ): void { | ||
| if (locales.includes(testInfo.project.name)) { | ||
| test.skip(true, reason); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| /* | ||
| * Copyright Red Hat, Inc. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| // These translation files are not exported by the package, so relative imports are necessary for e2e tests | ||
| /* eslint-disable @backstage/no-relative-monorepo-imports */ | ||
| import { boostMessages } from '../../plugins/boost/src/translations/ref.js'; | ||
| import boostTranslationDe from '../../plugins/boost/src/translations/de.js'; | ||
| import boostTranslationEs from '../../plugins/boost/src/translations/es.js'; | ||
| import boostTranslationFr from '../../plugins/boost/src/translations/fr.js'; | ||
| import boostTranslationIt from '../../plugins/boost/src/translations/it.js'; | ||
| import boostTranslationJa from '../../plugins/boost/src/translations/ja.js'; | ||
| /* eslint-enable @backstage/no-relative-monorepo-imports */ | ||
|
|
||
| export type BoostMessages = typeof boostMessages; | ||
|
|
||
| function transformFlatMessagesIntoTree( | ||
| flatMessages: typeof boostTranslationDe.messages, | ||
| ) { | ||
| const messages = {} as Record<string, any>; | ||
| for (const key of Object.keys(flatMessages)) { | ||
| const path = key.split('.'); | ||
| let current = messages; | ||
| for (let i = 0; i < path.length - 1; i++) { | ||
| current[path[i]] = current[path[i]] || {}; | ||
| current = current[path[i]] as Record<string, any>; | ||
| } | ||
| current[path[path.length - 1]] = | ||
|
Check warning on line 40 in workspaces/boost/e2e-tests/utils/translations.ts
|
||
| flatMessages[key as keyof typeof flatMessages]; | ||
| } | ||
| return messages as BoostMessages; | ||
| } | ||
|
|
||
| export function getTranslations(locale: string): BoostMessages { | ||
| switch (locale) { | ||
| case 'en': | ||
| return boostMessages; | ||
| case 'de': | ||
| return transformFlatMessagesIntoTree(boostTranslationDe.messages); | ||
| case 'es': | ||
| return transformFlatMessagesIntoTree(boostTranslationEs.messages); | ||
| case 'fr': | ||
| return transformFlatMessagesIntoTree(boostTranslationFr.messages); | ||
| case 'it': | ||
| return transformFlatMessagesIntoTree(boostTranslationIt.messages); | ||
| case 'ja': | ||
| return transformFlatMessagesIntoTree(boostTranslationJa.messages); | ||
| default: | ||
| return boostMessages; | ||
| } | ||
| } | ||
13 changes: 0 additions & 13 deletions
13
workspaces/boost/openspec/changes/ai-catalog-frontend-translations/tasks.md
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions
13
...t/openspec/changes/archive/2026-09-17-ai-catalog-frontend-translations/tasks.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Tasks: AI Catalog frontend translations (RHIDP-15479) | ||
|
|
||
| - [x] 1. Translation module auto-discovery entry (`./translations`) already exists | ||
| - [x] 2. Create `src/translations/de.ts` | ||
| - [x] 3. Create `src/translations/es.ts` | ||
| - [x] 4. Create `src/translations/fr.ts` | ||
| - [x] 5. Create `src/translations/it.ts` | ||
| - [x] 6. Create `src/translations/ja.ts` | ||
| - [x] 7. Register lazy locale imports in `src/translations/index.ts` | ||
| - [x] 8. Audit user-facing strings against `ref.ts` | ||
| - [x] 9. Preserve interpolation placeholders in all locale files | ||
| - [ ] 10. ~~Verify locale switching in the dev app~~ — deferred: requires a live RHDH instance with the Settings language selector | ||
| - [ ] 11. ~~Verify English fallback for missing keys~~ — deferred: requires a live RHDH instance; Backstage's `createTranslationRef` provides English fallback by design |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.