diff --git a/.changeset/clear-bananas-end.md b/.changeset/clear-bananas-end.md
new file mode 100644
index 0000000000..50e722544c
--- /dev/null
+++ b/.changeset/clear-bananas-end.md
@@ -0,0 +1,5 @@
+---
+'@backstage/plugin-catalog-graph': patch
+---
+
+Catalog graph plugin support i18n
diff --git a/plugins/catalog-graph/report-alpha.api.md b/plugins/catalog-graph/report-alpha.api.md
index cf5835e35c..230edde3da 100644
--- a/plugins/catalog-graph/report-alpha.api.md
+++ b/plugins/catalog-graph/report-alpha.api.md
@@ -16,6 +16,35 @@ import { ExternalRouteRef } from '@backstage/frontend-plugin-api';
import { FrontendPlugin } from '@backstage/frontend-plugin-api';
import { JSX as JSX_2 } from 'react';
import { RouteRef } from '@backstage/frontend-plugin-api';
+import { TranslationRef } from '@backstage/frontend-plugin-api';
+
+// @alpha (undocumented)
+export const catalogGraphTranslationRef: TranslationRef<
+ 'catalog-graph',
+ {
+ readonly 'catalogGraphCard.title': 'Relations';
+ readonly 'catalogGraphCard.deepLinkTitle': 'View graph';
+ readonly 'catalogGraphPage.title': 'Catalog Graph';
+ readonly 'catalogGraphPage.filterToggleButtonTitle': 'Filters';
+ readonly 'catalogGraphPage.supportButtonDescription': 'Start tracking your component in by adding it to the software catalog.';
+ readonly 'catalogGraphPage.simplifiedSwitchLabel': 'Simplified';
+ readonly 'catalogGraphPage.mergeRelationsSwitchLabel': 'Merge relations';
+ readonly 'catalogGraphPage.zoomOutDescription': 'Use pinch & zoom to move around the diagram. Click to change active node, shift click to navigate to entity.';
+ readonly 'catalogGraphPage.curveFilter.title': 'Curve';
+ readonly 'catalogGraphPage.curveFilter.curveStepBefore': 'Step Before';
+ readonly 'catalogGraphPage.curveFilter.curveMonotoneX': 'Monotone X';
+ readonly 'catalogGraphPage.directionFilter.title': 'Direction';
+ readonly 'catalogGraphPage.directionFilter.leftToRight': 'Left to right';
+ readonly 'catalogGraphPage.directionFilter.rightToLeft': 'Right to left';
+ readonly 'catalogGraphPage.directionFilter.topToBottom': 'Top to bottom';
+ readonly 'catalogGraphPage.directionFilter.bottomToTop': 'Bottom to top';
+ readonly 'catalogGraphPage.maxDepthFilter.title': 'Max depth';
+ readonly 'catalogGraphPage.maxDepthFilter.inputPlaceholder': '∞ Infinite';
+ readonly 'catalogGraphPage.maxDepthFilter.clearButtonAriaLabel': 'clear max depth';
+ readonly 'catalogGraphPage.selectedKindsFilter.title': 'Kinds';
+ readonly 'catalogGraphPage.selectedRelationsFilter.title': 'Relations';
+ }
+>;
// @public (undocumented)
const _default: FrontendPlugin<
diff --git a/plugins/catalog-graph/src/alpha.tsx b/plugins/catalog-graph/src/alpha.tsx
index aa1f6a05cf..6ee16be1c4 100644
--- a/plugins/catalog-graph/src/alpha.tsx
+++ b/plugins/catalog-graph/src/alpha.tsx
@@ -96,3 +96,5 @@ export default createFrontendPlugin({
},
extensions: [CatalogGraphPage, CatalogGraphEntityCard],
});
+
+export { catalogGraphTranslationRef } from './translation';
diff --git a/plugins/catalog-graph/src/components/CatalogGraphCard/CatalogGraphCard.test.tsx b/plugins/catalog-graph/src/components/CatalogGraphCard/CatalogGraphCard.test.tsx
index e09d57bd31..ed8069a8f4 100644
--- a/plugins/catalog-graph/src/components/CatalogGraphCard/CatalogGraphCard.test.tsx
+++ b/plugins/catalog-graph/src/components/CatalogGraphCard/CatalogGraphCard.test.tsx
@@ -34,6 +34,7 @@ import userEvent from '@testing-library/user-event';
import { catalogGraphRouteRef } from '../../routes';
import { CatalogGraphCard } from './CatalogGraphCard';
import Button from '@material-ui/core/Button';
+import { translationApiRef } from '@backstage/core-plugin-api/alpha';
describe('', () => {
let entity: Entity;
@@ -52,7 +53,10 @@ describe('', () => {
namespace: 'd',
},
};
- apis = TestApiRegistry.from([catalogApiRef, catalog]);
+ apis = TestApiRegistry.from(
+ [catalogApiRef, catalog],
+ [translationApiRef, mockApis.translation()],
+ );
wrapper = (
@@ -213,7 +217,12 @@ describe('', () => {
const analyticsApi = mockApis.analytics();
await renderInTestApp(
-
+
{wrapper}
,
{
diff --git a/plugins/catalog-graph/src/components/CatalogGraphCard/CatalogGraphCard.tsx b/plugins/catalog-graph/src/components/CatalogGraphCard/CatalogGraphCard.tsx
index a75993a1bc..733f209990 100644
--- a/plugins/catalog-graph/src/components/CatalogGraphCard/CatalogGraphCard.tsx
+++ b/plugins/catalog-graph/src/components/CatalogGraphCard/CatalogGraphCard.tsx
@@ -38,6 +38,8 @@ import {
EntityRelationsGraph,
EntityRelationsGraphProps,
} from '../EntityRelationsGraph';
+import { useTranslationRef } from '@backstage/frontend-plugin-api';
+import { catalogGraphTranslationRef } from '../../translation';
/** @public */
export type CatalogGraphCardClassKey = 'card' | 'graph';
@@ -66,6 +68,7 @@ export const CatalogGraphCard = (
action?: ReactNode;
},
) => {
+ const { t } = useTranslationRef(catalogGraphTranslationRef);
const {
variant = 'gridItem',
relationPairs = ALL_RELATION_PAIRS,
@@ -81,7 +84,7 @@ export const CatalogGraphCard = (
action,
rootEntityNames,
onNodeClick,
- title = 'Relations',
+ title = t('catalogGraphCard.title'),
zoom = 'enable-on-click',
} = props;
@@ -133,7 +136,7 @@ export const CatalogGraphCard = (
variant={variant}
noPadding
deepLink={{
- title: 'View graph',
+ title: t('catalogGraphCard.deepLinkTitle'),
link: catalogGraphUrl,
}}
>
diff --git a/plugins/catalog-graph/src/components/CatalogGraphPage/CatalogGraphPage.tsx b/plugins/catalog-graph/src/components/CatalogGraphPage/CatalogGraphPage.tsx
index cf3e628a98..69cb04bf3a 100644
--- a/plugins/catalog-graph/src/components/CatalogGraphPage/CatalogGraphPage.tsx
+++ b/plugins/catalog-graph/src/components/CatalogGraphPage/CatalogGraphPage.tsx
@@ -50,6 +50,8 @@ import { SelectedKindsFilter } from './SelectedKindsFilter';
import { SelectedRelationsFilter } from './SelectedRelationsFilter';
import { SwitchFilter } from './SwitchFilter';
import { useCatalogGraphPage } from './useCatalogGraphPage';
+import { useTranslationRef } from '@backstage/frontend-plugin-api';
+import { catalogGraphTranslationRef } from '../../translation';
/** @public */
export type CatalogGraphPageClassKey =
@@ -136,7 +138,7 @@ export const CatalogGraphPage = (
initialState,
entityFilter,
} = props;
-
+ const { t } = useTranslationRef(catalogGraphTranslationRef);
const navigate = useNavigate();
const classes = useStyles();
const catalogEntityRoute = useRouteRef(entityRouteRef);
@@ -192,7 +194,7 @@ export const CatalogGraphPage = (
return (
humanizeEntityRef(e)).join(', ')}
/>
@@ -203,13 +205,12 @@ export const CatalogGraphPage = (
selected={showFilters}
onChange={() => toggleShowFilters()}
>
- Filters
+ {t('catalogGraphPage.filterToggleButtonTitle')}
}
>
- Start tracking your component in by adding it to the software
- catalog.
+ {t('catalogGraphPage.supportButtonDescription')}
@@ -230,12 +231,12 @@ export const CatalogGraphPage = (
)}
@@ -247,9 +248,8 @@ export const CatalogGraphPage = (
display="block"
className={classes.legend}
>
- Use pinch & zoom to move
- around the diagram. Click to change active node, shift click to
- navigate to entity.
+ {' '}
+ {t('catalogGraphPage.zoomOutDescription')}
', () => {
- test('should display current curve label', () => {
+ test('should display current curve label', async () => {
const onChange = jest.fn();
- render();
+ await renderInTestApp(
+ ,
+ );
expect(screen.getByText('Monotone X')).toBeInTheDocument();
});
test('should select an alternative curve factory', async () => {
const onChange = jest.fn();
- render();
+ await renderInTestApp(
+ ,
+ );
expect(screen.getByText('Step Before')).toBeInTheDocument();
diff --git a/plugins/catalog-graph/src/components/CatalogGraphPage/CurveFilter.tsx b/plugins/catalog-graph/src/components/CatalogGraphPage/CurveFilter.tsx
index 411c144b05..0e6a941b1a 100644
--- a/plugins/catalog-graph/src/components/CatalogGraphPage/CurveFilter.tsx
+++ b/plugins/catalog-graph/src/components/CatalogGraphPage/CurveFilter.tsx
@@ -16,12 +16,10 @@
import { Select, SelectedItems } from '@backstage/core-components';
import Box from '@material-ui/core/Box';
import { useCallback } from 'react';
+import { catalogGraphTranslationRef } from '../../translation';
+import { useTranslationRef } from '@backstage/frontend-plugin-api';
type Curve = 'curveStepBefore' | 'curveMonotoneX';
-const CURVE_DISPLAY_NAMES: Record = {
- curveMonotoneX: 'Monotone X',
- curveStepBefore: 'Step Before',
-};
export type Props = {
value: Curve;
@@ -31,6 +29,12 @@ export type Props = {
const curves: Array = ['curveMonotoneX', 'curveStepBefore'];
export const CurveFilter = ({ value, onChange }: Props) => {
+ const { t } = useTranslationRef(catalogGraphTranslationRef);
+ const CURVE_DISPLAY_NAMES: Record = {
+ curveMonotoneX: t('catalogGraphPage.curveFilter.curveMonotoneX'),
+ curveStepBefore: t('catalogGraphPage.curveFilter.curveStepBefore'),
+ };
+
const handleChange = useCallback(
(v: SelectedItems) => onChange(v as Curve),
[onChange],
@@ -39,7 +43,7 @@ export const CurveFilter = ({ value, onChange }: Props) => {
return (