fix: StackDetails support translations

Signed-off-by: rui ma <ruima@alauda.io>
This commit is contained in:
rui ma
2024-02-18 11:20:19 +08:00
parent 0afea5c0ed
commit 8ab41e507a
3 changed files with 9 additions and 2 deletions
@@ -33,6 +33,8 @@ export const coreComponentsTranslationRef: TranslationRef<
readonly 'errorPage.title': 'Looks like someone dropped the mic!';
readonly 'errorPage.subtitle': 'ERROR {{status}}: {{statusMessage}}';
readonly 'errorPage.goBack': 'Go back';
readonly 'errorPage.showMoreDetails': 'Show more details';
readonly 'errorPage.showLessDetails': 'Show less details';
readonly 'emptyState.missingAnnotation.title': 'Missing Annotation';
readonly 'emptyState.missingAnnotation.actionTitle': 'Add the annotation to your component YAML as shown in the highlighted example below:';
readonly 'emptyState.missingAnnotation.readMore': 'Read more';
@@ -19,6 +19,8 @@ import { useState } from 'react';
import { Link } from '../../components/Link';
import { CodeSnippet } from '../../components';
import { makeStyles } from '@material-ui/core/styles';
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
import { coreComponentsTranslationRef } from '../../translation';
interface IStackDetailsProps {
stack: string;
@@ -46,6 +48,7 @@ const useStyles = makeStyles(
export function StackDetails(props: IStackDetailsProps) {
const { stack } = props;
const classes = useStyles();
const { t } = useTranslationRef(coreComponentsTranslationRef);
const [detailsOpen, setDetailsOpen] = useState<boolean>(false);
@@ -53,7 +56,7 @@ export function StackDetails(props: IStackDetailsProps) {
return (
<Typography variant="h6" className={classes.title}>
<Link to="#" onClick={() => setDetailsOpen(true)}>
Show more details
{t('errorPage.showMoreDetails')}
</Link>
</Typography>
);
@@ -63,7 +66,7 @@ export function StackDetails(props: IStackDetailsProps) {
<>
<Typography variant="h6" className={classes.title}>
<Link to="#" onClick={() => setDetailsOpen(false)}>
Show less details
{t('errorPage.showLessDetails')}
</Link>
</Typography>
<CodeSnippet
@@ -54,6 +54,8 @@ export const coreComponentsTranslationRef = createTranslationRef({
subtitle: 'ERROR {{status}}: {{statusMessage}}',
title: 'Looks like someone dropped the mic!',
goBack: 'Go back',
showMoreDetails: 'Show more details',
showLessDetails: 'Show less details',
},
emptyState: {
missingAnnotation: {