Skip to content

Commit

Permalink
feat: Add Translation UI component
Browse files Browse the repository at this point in the history
  • Loading branch information
SkrzypMajster committed Oct 5, 2023
1 parent 531e31e commit 526d30b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/ui/translation/Translation.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { useLocale } from 'hooks/useLocale/useLocale';
import { AppMessages } from 'i18n/messages';

import { TranslationProps } from './Translation.types';

export const Translation = ({ id, values }: TranslationProps) => {
const { formatMessage } = useLocale();

return <>{formatMessage({ id: AppMessages[id] }, values)}</>;
};
8 changes: 8 additions & 0 deletions src/ui/translation/Translation.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { PrimitiveType } from 'react-intl';

import { Translation } from 'i18n/messages';

export type TranslationProps = {
id: Translation;
values?: Record<string, PrimitiveType>;
};

0 comments on commit 526d30b

Please sign in to comment.