Skip to content

Commit

Permalink
add i18n for video component
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenliang committed Feb 14, 2025
1 parent 5aab5fe commit 662903e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
6 changes: 4 additions & 2 deletions frontend/apps/marketing/public/locales/en-US/common.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"hello": "Hello World!"
}
"hello": "Hello World!",
"videoErrorBody": "This video is blocked on your network.",
"videoErrorHeading": "Video unavailable"
}
24 changes: 24 additions & 0 deletions frontend/apps/marketing/src/components/video/Video.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use client';
import '@code-dot-org/component-library/video/index.css';
import initTranslations from "@/app/i18n";

import { Video as DscoVideo, VideoProps } from '@code-dot-org/component-library/video';
import { useEffect, useState } from 'react';

const Video = (props: VideoProps) => {
const [errorBody, setErrorBody] = useState<string | undefined>(undefined);
const [errorHeading, setErrorHeading] = useState<string | undefined>(undefined);

useEffect(() => {
initTranslations('zh-CN', ['common']).then(({ t }) => {
setErrorHeading(t('videoErrorHeading'));
setErrorBody(t('videoErrorBody'));
})
}, [])
//const { t, i18n } = useTranslation();

return <DscoVideo errorHeading={errorHeading} errorBody={errorBody} {...props} />
//return <DscoVideo errorHeading={t('videoErrorHeading')} errorBody={t('videoErrorBody')} {...props} />
}

export default Video;
6 changes: 4 additions & 2 deletions frontend/apps/marketing/src/components/video/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import '@code-dot-org/component-library/video/index.css';
import initTranslations from "@/app/i18n";

// Export the Component Definition for use in Contentful Studio
export {VideoContentfulComponentDefinition} from './videoContentfulDefinition';
export {default} from '@code-dot-org/component-library/video';
export { VideoContentfulComponentDefinition } from './videoContentfulDefinition';

export { default as default } from './Video';

0 comments on commit 662903e

Please sign in to comment.