Added German language

This commit is contained in:
Sebastian Seedorf
2022-08-20 00:30:49 +02:00
parent f826537aec
commit 3fea0f851f
11 changed files with 155 additions and 33 deletions

View File

@@ -1,11 +1,20 @@
import { FC } from 'react'
import { FormattedMessage } from 'react-intl'
import { ComponentProps, FC } from 'react'
import { FormattedMessage, IntlShape } from 'react-intl'
import { useMessages } from '../../../src/i18n'
import { FormatXMLElementFn, PrimitiveType } from 'intl-messageformat'
interface Props {
interface Props extends ComponentProps<typeof FormattedMessage> {
id: keyof ReturnType<typeof useMessages>['en']
}
export const I18n: FC<Props> = ({ id }) => {
return <FormattedMessage id={id} />
export const I18n: FC<Props> = ({ children, ...props }) => {
return <FormattedMessage {...props}>{children}</FormattedMessage>
}
export const i18n = (
intl: IntlShape,
id: keyof ReturnType<typeof useMessages>['en'],
values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>
) => {
return intl.formatMessage({ id }, values, { ignoreTag: true })
}