Skip to content

Commit 6508244

Browse files
feat(localization): adding localization support for the entityTabs title coming from dynamic-plugins.default.yaml and defaultTabs.tsx (#3503)
* feat(localization): add localization support for entityTabs Signed-off-by: its-mitesh-kumar <[email protected]> * translating default tab Signed-off-by: its-mitesh-kumar <[email protected]> * removing translation ref from default Signed-off-by: its-mitesh-kumar <[email protected]> * moving prefix of key from app to catalog Signed-off-by: its-mitesh-kumar <[email protected]> * fixing buld fail Signed-off-by: its-mitesh-kumar <[email protected]> * trying by passing titleKey in scorecard Signed-off-by: its-mitesh-kumar <[email protected]> * passing trnaslated tab component Signed-off-by: its-mitesh-kumar <[email protected]> * adding back comment Signed-off-by: its-mitesh-kumar <[email protected]> * keeping previous type Signed-off-by: its-mitesh-kumar <[email protected]> --------- Signed-off-by: its-mitesh-kumar <[email protected]>
1 parent ea12935 commit 6508244

File tree

15 files changed

+217
-13
lines changed

15 files changed

+217
-13
lines changed

.ibm/pipelines/value_files/values_showcase-rbac.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ global:
118118
entityTabs:
119119
- path: "/scorecard"
120120
title: Scorecard
121+
titleKey: catalog.entityPage.scorecard.title
121122
mountPoint: entity.page.scorecard
122123
mountPoints:
123124
- mountPoint: entity.page.scorecard/cards

dynamic-plugins.default.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,6 +1326,7 @@ plugins:
13261326
entityTabs:
13271327
- path: /workflows
13281328
title: Workflows
1329+
titleKey: catalog.entityPage.workflows.title
13291330
mountPoint: entity.page.workflows
13301331
mountPoints:
13311332
- mountPoint: entity.page.workflows/cards

packages/app/src/components/DynamicRoot/DynamicRoot.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,14 +443,14 @@ export const DynamicRoot = ({
443443
}, []);
444444

445445
const entityTabOverrides = entityTabs.reduce<EntityTabOverrides>(
446-
(acc, { path, title, mountPoint, scope, priority }) => {
446+
(acc, { path, title, titleKey, mountPoint, scope, priority }) => {
447447
if (acc[path]) {
448448
// eslint-disable-next-line no-console
449449
console.warn(
450450
`Plugin ${scope} is not configured properly: a tab has already been configured for "${path}", ignoring entry with title: "${title}" and mountPoint: "${mountPoint}"`,
451451
);
452452
} else {
453-
acc[path] = { title, mountPoint, priority };
453+
acc[path] = { title, titleKey, mountPoint, priority };
454454
}
455455
return acc;
456456
},

packages/app/src/components/catalog/EntityPage/DiagramTabContent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const DiagramTabContent = () => {
2727
<EntityCatalogGraphCard
2828
variant="gridItem"
2929
direction={Direction.TOP_BOTTOM}
30-
title={t('app.entityPage.diagram.title')}
30+
title={t('catalog.entityPage.diagram.title')}
3131
height={700}
3232
relations={[
3333
RELATION_PART_OF,

packages/app/src/components/catalog/EntityPage/DynamicEntityTab.tsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,44 @@
1+
import { forwardRef } from 'react';
2+
13
import { Entity } from '@backstage/catalog-model';
4+
import { Link } from '@backstage/core-components';
25
import { ApiHolder } from '@backstage/core-plugin-api';
36
import { EntityLayout, EntitySwitch } from '@backstage/plugin-catalog';
47

58
import Box from '@mui/material/Box';
69
import { DynamicRootConfig } from '@red-hat-developer-hub/plugin-utils';
710

11+
import { useTranslation } from '../../../hooks/useTranslation';
812
import getDynamicRootConfig from '../../../utils/dynamicUI/getDynamicRootConfig';
913
import getMountPointData from '../../../utils/dynamicUI/getMountPointData';
14+
import { getTranslatedTextWithFallback } from '../../../utils/translations';
1015
import Grid from '../Grid';
1116

17+
const TranslatedTab = forwardRef<
18+
any,
19+
{
20+
title?: string;
21+
titleKey?: string;
22+
path?: string;
23+
children?: React.ReactNode;
24+
[key: string]: any;
25+
}
26+
>((props, ref) => {
27+
const { title, titleKey, path, children, ...otherProps } = props;
28+
const { t } = useTranslation();
29+
30+
const translatedText = getTranslatedTextWithFallback(t, titleKey, title);
31+
return (
32+
<Link ref={ref} to={path} {...otherProps}>
33+
{translatedText}
34+
</Link>
35+
);
36+
});
37+
1238
export type DynamicEntityTabProps = {
1339
path: string;
1440
title: string;
41+
titleKey?: string;
1542
mountPoint: string;
1643
if?: (entity: Entity) => boolean;
1744
children?: React.ReactNode;
@@ -30,6 +57,7 @@ export type DynamicEntityTabProps = {
3057
export const dynamicEntityTab = ({
3158
path,
3259
title,
60+
titleKey,
3361
mountPoint,
3462
children,
3563
if: condition,
@@ -38,6 +66,12 @@ export const dynamicEntityTab = ({
3866
key={`${path}`}
3967
path={path}
4068
title={title}
69+
tabProps={{
70+
component: TranslatedTab,
71+
title: title,
72+
titleKey: titleKey,
73+
path: path,
74+
}}
4175
if={entity =>
4276
(condition
4377
? errorWrappedCondition(

packages/app/src/components/catalog/EntityPage/defaultTabs.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,62 +18,77 @@ export const defaultTabs: Record<
1818
> = {
1919
'/': {
2020
title: 'Overview',
21+
titleKey: 'catalog.entityPage.overview.title',
2122
mountPoint: 'entity.page.overview',
2223
},
2324
'/topology': {
2425
title: 'Topology',
26+
titleKey: 'catalog.entityPage.topology.title',
2527
mountPoint: 'entity.page.topology',
2628
},
2729
'/issues': {
2830
title: 'Issues',
31+
titleKey: 'catalog.entityPage.issues.title',
2932
mountPoint: 'entity.page.issues',
3033
},
3134
'/pr': {
3235
title: 'Pull/Merge Requests',
36+
titleKey: 'catalog.entityPage.pullRequests.title',
3337
mountPoint: 'entity.page.pull-requests',
3438
},
3539
'/ci': {
3640
title: 'CI',
41+
titleKey: 'catalog.entityPage.ci.title',
3742
mountPoint: 'entity.page.ci',
3843
},
3944
'/cd': {
4045
title: 'CD',
46+
titleKey: 'catalog.entityPage.cd.title',
4147
mountPoint: 'entity.page.cd',
4248
},
4349
'/kubernetes': {
4450
title: 'Kubernetes',
51+
titleKey: 'catalog.entityPage.kubernetes.title',
4552
mountPoint: 'entity.page.kubernetes',
4653
},
4754
'/image-registry': {
4855
title: 'Image Registry',
56+
titleKey: 'catalog.entityPage.imageRegistry.title',
4957
mountPoint: 'entity.page.image-registry',
5058
},
5159
'/monitoring': {
5260
title: 'Monitoring',
61+
titleKey: 'catalog.entityPage.monitoring.title',
5362
mountPoint: 'entity.page.monitoring',
5463
},
5564
'/lighthouse': {
5665
title: 'Lighthouse',
66+
titleKey: 'catalog.entityPage.lighthouse.title',
5767
mountPoint: 'entity.page.lighthouse',
5868
},
5969
'/api': {
6070
title: 'Api',
71+
titleKey: 'catalog.entityPage.api.title',
6172
mountPoint: 'entity.page.api',
6273
},
6374
'/dependencies': {
6475
title: 'Dependencies',
76+
titleKey: 'catalog.entityPage.dependencies.title',
6577
mountPoint: 'entity.page.dependencies',
6678
},
6779
'/docs': {
6880
title: 'Docs',
81+
titleKey: 'catalog.entityPage.docs.title',
6982
mountPoint: 'entity.page.docs',
7083
},
7184
'/definition': {
7285
title: 'Definition',
86+
titleKey: 'catalog.entityPage.definition.title',
7387
mountPoint: 'entity.page.definition',
7488
},
7589
'/system': {
7690
title: 'Diagram',
91+
titleKey: 'catalog.entityPage.diagram.title',
7792
mountPoint: 'entity.page.diagram',
7893
},
7994
};

packages/app/src/translations/rhdh/de.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,23 @@ export default createTranslationMessages({
4343
'menuItem.orchestrator': 'Orchestrator',
4444
'menuItem.adoptionInsights': 'Einführungseinblicke',
4545

46+
'catalog.entityPage.overview.title': 'Übersicht',
47+
'catalog.entityPage.topology.title': 'Topologie',
48+
'catalog.entityPage.issues.title': 'Issues',
49+
'catalog.entityPage.pullRequests.title': 'Pull/Merge Requests',
50+
'catalog.entityPage.ci.title': 'CI',
51+
'catalog.entityPage.cd.title': 'CD',
52+
'catalog.entityPage.kubernetes.title': 'Kubernetes',
53+
'catalog.entityPage.imageRegistry.title': 'Image Registry',
54+
'catalog.entityPage.monitoring.title': 'Überwachung',
55+
'catalog.entityPage.lighthouse.title': 'Lighthouse',
56+
'catalog.entityPage.api.title': 'API',
57+
'catalog.entityPage.dependencies.title': 'Abhängigkeiten',
58+
'catalog.entityPage.docs.title': 'Dokumentation',
59+
'catalog.entityPage.definition.title': 'Definition',
60+
'catalog.entityPage.diagram.title': 'Systemdiagramm',
61+
'catalog.entityPage.workflows.title': 'Workflows',
62+
4663
'sidebar.menu': 'Menü',
4764
'sidebar.home': 'Startseite',
4865
'sidebar.homeLogo': 'Startseite-Logo',
@@ -88,7 +105,6 @@ export default createTranslationMessages({
88105
'app.learningPaths.title': 'Lernpfade',
89106
'app.learningPaths.error.title': 'Daten konnten nicht abgerufen werden.',
90107
'app.learningPaths.error.unknownError': 'Unbekannter Fehler',
91-
'app.entityPage.diagram.title': 'Systemdiagramm',
92108
'app.userSettings.infoCard.title': 'RHDH-Metadaten',
93109
'app.userSettings.infoCard.metadataCopied':
94110
'Metadaten in die Zwischenablage kopiert',

packages/app/src/translations/rhdh/es.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,23 @@ export default createTranslationMessages({
4343
'menuItem.orchestrator': 'Orquestador',
4444
'menuItem.adoptionInsights': 'Insights de adopción',
4545

46+
'catalog.entityPage.overview.title': 'Resumen',
47+
'catalog.entityPage.topology.title': 'Topología',
48+
'catalog.entityPage.issues.title': 'Problemas',
49+
'catalog.entityPage.pullRequests.title': 'Pull/Merge Requests',
50+
'catalog.entityPage.ci.title': 'CI',
51+
'catalog.entityPage.cd.title': 'CD',
52+
'catalog.entityPage.kubernetes.title': 'Kubernetes',
53+
'catalog.entityPage.imageRegistry.title': 'Registro de Imágenes',
54+
'catalog.entityPage.monitoring.title': 'Monitoreo',
55+
'catalog.entityPage.lighthouse.title': 'Lighthouse',
56+
'catalog.entityPage.api.title': 'API',
57+
'catalog.entityPage.dependencies.title': 'Dependencias',
58+
'catalog.entityPage.docs.title': 'Documentación',
59+
'catalog.entityPage.definition.title': 'Definición',
60+
'catalog.entityPage.diagram.title': 'Diagrama del Sistema',
61+
'catalog.entityPage.workflows.title': 'Flujos de trabajo',
62+
4663
'sidebar.menu': 'Menú',
4764
'sidebar.home': 'Inicio',
4865
'sidebar.homeLogo': 'Logo de inicio',
@@ -89,7 +106,6 @@ export default createTranslationMessages({
89106
'app.learningPaths.title': 'Rutas de aprendizaje',
90107
'app.learningPaths.error.title': 'No se pudieron obtener los datos.',
91108
'app.learningPaths.error.unknownError': 'Error desconocido',
92-
'app.entityPage.diagram.title': 'Diagrama del sistema',
93109
'app.userSettings.infoCard.title': 'Metadatos RHDH',
94110
'app.userSettings.infoCard.metadataCopied':
95111
'Metadatos copiados al portapapeles',

packages/app/src/translations/rhdh/fr.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,23 @@ export default createTranslationMessages({
4343
'menuItem.orchestrator': 'Orchestrateur',
4444
'menuItem.adoptionInsights': "Insights d'adoption",
4545

46+
'catalog.entityPage.overview.title': 'Aperçu',
47+
'catalog.entityPage.topology.title': 'Topologie',
48+
'catalog.entityPage.issues.title': 'Problèmes',
49+
'catalog.entityPage.pullRequests.title': 'Pull/Merge Requests',
50+
'catalog.entityPage.ci.title': 'CI',
51+
'catalog.entityPage.cd.title': 'CD',
52+
'catalog.entityPage.kubernetes.title': 'Kubernetes',
53+
'catalog.entityPage.imageRegistry.title': "Registre d'Images",
54+
'catalog.entityPage.monitoring.title': 'Surveillance',
55+
'catalog.entityPage.lighthouse.title': 'Lighthouse',
56+
'catalog.entityPage.api.title': 'API',
57+
'catalog.entityPage.dependencies.title': 'Dépendances',
58+
'catalog.entityPage.docs.title': 'Documentation',
59+
'catalog.entityPage.definition.title': 'Définition',
60+
'catalog.entityPage.diagram.title': 'Diagramme du Système',
61+
'catalog.entityPage.workflows.title': 'Flux de travail',
62+
4663
'sidebar.menu': 'Menu',
4764
'sidebar.home': 'Accueil',
4865
'sidebar.homeLogo': "Logo d'accueil",
@@ -89,7 +106,6 @@ export default createTranslationMessages({
89106
'app.learningPaths.title': "Parcours d'apprentissage",
90107
'app.learningPaths.error.title': 'Impossible de récupérer les données.',
91108
'app.learningPaths.error.unknownError': 'Erreur inconnue',
92-
'app.entityPage.diagram.title': 'Diagramme système',
93109
'app.userSettings.infoCard.title': 'Métadonnées RHDH',
94110
'app.userSettings.infoCard.metadataCopied':
95111
'Métadonnées copiées dans le presse-papiers',

packages/app/src/translations/rhdh/it.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,23 @@ export default createTranslationMessages({
4343
'menuItem.orchestrator': 'Orchestratore',
4444
'menuItem.adoptionInsights': 'Insights di adozione',
4545

46+
'catalog.entityPage.overview.title': 'Panoramica',
47+
'catalog.entityPage.topology.title': 'Topologia',
48+
'catalog.entityPage.issues.title': 'Problemi',
49+
'catalog.entityPage.pullRequests.title': 'Pull/Merge Requests',
50+
'catalog.entityPage.ci.title': 'CI',
51+
'catalog.entityPage.cd.title': 'CD',
52+
'catalog.entityPage.kubernetes.title': 'Kubernetes',
53+
'catalog.entityPage.imageRegistry.title': 'Registro Immagini',
54+
'catalog.entityPage.monitoring.title': 'Monitoraggio',
55+
'catalog.entityPage.lighthouse.title': 'Lighthouse',
56+
'catalog.entityPage.api.title': 'API',
57+
'catalog.entityPage.dependencies.title': 'Dipendenze',
58+
'catalog.entityPage.docs.title': 'Documentazione',
59+
'catalog.entityPage.definition.title': 'Definizione',
60+
'catalog.entityPage.diagram.title': 'Diagramma del Sistema',
61+
'catalog.entityPage.workflows.title': 'Flussi di lavoro',
62+
4663
'sidebar.menu': 'Menu',
4764
'sidebar.home': 'Home',
4865
'sidebar.homeLogo': 'Logo principale',
@@ -88,7 +105,6 @@ export default createTranslationMessages({
88105
'app.learningPaths.title': 'Percorsi di apprendimento',
89106
'app.learningPaths.error.title': 'Impossibile recuperare i dati.',
90107
'app.learningPaths.error.unknownError': 'Errore sconosciuto',
91-
'app.entityPage.diagram.title': 'Diagramma di sistema',
92108
'app.userSettings.infoCard.title': 'Metadati RHDH',
93109
'app.userSettings.infoCard.metadataCopied':
94110
'Metadati copiati negli appunti',

0 commit comments

Comments
 (0)