Skip to content

Commit 7cf6d61

Browse files
fix(global-header): localize search All results and clear control (#3052)
Wire search autocomplete strings to plugin translations with locale bundles; update SearchOption tests to use shared translation mocks; refresh API reports. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent cab4992 commit 7cf6d61

12 files changed

Lines changed: 45 additions & 2 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@red-hat-developer-hub/backstage-plugin-global-header': patch
3+
---
4+
5+
Add missing translations for the global header search experience: localize the autocomplete "All results" link and the clear control tooltip/accessible label (`search.allResults`, `search.clear`), with locale strings for German, Spanish, French, Italian, and Japanese.

workspaces/global-header/plugins/global-header/report-alpha.api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,8 @@ export const globalHeaderTranslationRef: TranslationRef<
10241024
readonly 'search.placeholder': string;
10251025
readonly 'search.noResults': string;
10261026
readonly 'search.errorFetching': string;
1027+
readonly 'search.allResults': string;
1028+
readonly 'search.clear': string;
10271029
readonly 'help.tooltip': string;
10281030
readonly 'help.noSupportLinks': string;
10291031
readonly 'help.noSupportLinksSubtitle': string;

workspaces/global-header/plugins/global-header/report.api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ export const globalHeaderTranslationRef: TranslationRef<
8888
readonly 'search.placeholder': string;
8989
readonly 'search.noResults': string;
9090
readonly 'search.errorFetching': string;
91+
readonly 'search.allResults': string;
92+
readonly 'search.clear': string;
9193
readonly 'help.tooltip': string;
9294
readonly 'help.noSupportLinks': string;
9395
readonly 'help.noSupportLinksSubtitle': string;

workspaces/global-header/plugins/global-header/src/components/SearchComponent/SearchBar.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ export const SearchBar = (props: SearchBarProps) => {
9090
: '0 2px 6px 2px rgba(0, 0, 0, 0.15), 0 1px 2px 0 rgba(0, 0, 0, 0.30)',
9191
},
9292
},
93+
clearIndicator: {
94+
title: t('search.clear'),
95+
'aria-label': t('search.clear'),
96+
},
9397
}}
9498
sx={{
9599
width: '100%',

workspaces/global-header/plugins/global-header/src/components/SearchComponent/SearchOption.test.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,23 @@
1515
*/
1616

1717
import { render, screen } from '@testing-library/react';
18-
import { SearchOption } from './SearchOption';
1918
import { BrowserRouter as Router } from 'react-router-dom';
2019
import { Result, SearchDocument } from '@backstage/plugin-search-common';
2120

21+
import {
22+
MockTrans,
23+
mockUseTranslation,
24+
} from '../../test-utils/mockTranslations';
25+
import { SearchOption } from './SearchOption';
26+
27+
jest.mock('../../hooks/useTranslation', () => ({
28+
useTranslation: mockUseTranslation,
29+
}));
30+
31+
jest.mock('../../components/Trans', () => ({
32+
Trans: MockTrans,
33+
}));
34+
2235
jest.mock('./SearchResultItem', () => ({
2336
SearchResultItem: jest.fn(({ option }) => <div>{option}</div>),
2437
}));

workspaces/global-header/plugins/global-header/src/components/SearchComponent/SearchOption.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import ArrowForwardIcon from '@mui/icons-material/ArrowForward';
2323
import { SearchResultItem } from './SearchResultItem';
2424
import { Result, SearchDocument } from '@backstage/plugin-search-common';
2525
import { SearchResultProps } from '@backstage/plugin-search-react';
26+
import { useTranslation } from '../../hooks/useTranslation';
2627

2728
interface SearchOptionProps {
2829
option: string;
@@ -43,6 +44,8 @@ export const SearchOption = ({
4344
renderProps,
4445
searchLink,
4546
}: SearchOptionProps) => {
47+
const { t } = useTranslation();
48+
4649
if (option === query?.term && index === options.length - 1) {
4750
return (
4851
<Box key="all-results" id="all-results">
@@ -54,7 +57,9 @@ export const SearchOption = ({
5457
className="allResultsOption"
5558
>
5659
<Box sx={{ display: 'flex', alignItems: 'center' }}>
57-
<Typography sx={{ flexGrow: 1 }}>All results</Typography>
60+
<Typography sx={{ flexGrow: 1 }}>
61+
{t('search.allResults')}
62+
</Typography>
5863
<ArrowForwardIcon fontSize="small" />
5964
</Box>
6065
</ListItem>

workspaces/global-header/plugins/global-header/src/translations/de.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ const globalHeaderTranslationDe = createTranslationMessages({
3737
'search.placeholder': 'Suchen...',
3838
'search.noResults': 'Keine Ergebnisse gefunden',
3939
'search.errorFetching': 'Fehler beim Abrufen der Ergebnisse',
40+
'search.allResults': 'Alle Ergebnisse',
41+
'search.clear': 'Löschen',
4042
'applicationLauncher.tooltip': 'Anwendungsstartprogramm',
4143
'applicationLauncher.noLinksTitle':
4244
'Keine Anwendungsverknüpfungen konfiguriert',

workspaces/global-header/plugins/global-header/src/translations/es.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ const globalHeaderTranslationEs = createTranslationMessages({
3737
'search.placeholder': 'Buscar...',
3838
'search.noResults': 'No se encontraron resultados',
3939
'search.errorFetching': 'Error al extraer los resultados',
40+
'search.allResults': 'Todos los resultados',
41+
'search.clear': 'Limpiar',
4042
'applicationLauncher.tooltip': 'Iniciador de aplicaciones',
4143
'applicationLauncher.noLinksTitle':
4244
'No hay enlaces de aplicación configurados',

workspaces/global-header/plugins/global-header/src/translations/fr.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ const globalHeaderTranslationFr = createTranslationMessages({
3737
'search.placeholder': 'Recherche...',
3838
'search.noResults': 'Aucun résultat trouvé',
3939
'search.errorFetching': 'Erreur lors de la récupération des résultats',
40+
'search.allResults': 'Tous les résultats',
41+
'search.clear': 'Effacer',
4042
'applicationLauncher.tooltip': "Lanceur d'applications",
4143
'applicationLauncher.noLinksTitle': "Aucun lien d'application configuré",
4244
'applicationLauncher.noLinksSubtitle':

workspaces/global-header/plugins/global-header/src/translations/it.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ const globalHeaderTranslationIt = createTranslationMessages({
3737
'search.placeholder': 'Cerca...',
3838
'search.noResults': 'Nessun risultato trovato',
3939
'search.errorFetching': 'Errore durante il recupero dei risultati',
40+
'search.allResults': 'Tutti i risultati',
41+
'search.clear': 'Cancella',
4042
'applicationLauncher.tooltip': 'Avvio applicazione',
4143
'applicationLauncher.noLinksTitle':
4244
"Nessun collegamento all'applicazione configurato",

0 commit comments

Comments
 (0)