mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-29 00:24:28 -05:00
fix(frontend): Fix i18n types
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
43ada39a1c
commit
6f81c5e194
4 changed files with 9 additions and 7 deletions
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
import { ExternalLink } from './external-link'
|
||||
import type { TranslatedLinkProps } from './types'
|
||||
import React from 'react'
|
||||
import React, { useMemo } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
/**
|
||||
|
@ -17,5 +17,6 @@ import { useTranslation } from 'react-i18next'
|
|||
*/
|
||||
export const TranslatedExternalLink: React.FC<TranslatedLinkProps> = ({ i18nKey, i18nOption, ...props }) => {
|
||||
const { t } = useTranslation()
|
||||
return <ExternalLink text={t(i18nKey, i18nOption)} {...props} />
|
||||
const text = useMemo(() => (i18nOption ? t(i18nKey, i18nOption) : t(i18nKey)), [i18nKey, i18nOption, t])
|
||||
return <ExternalLink text={text} {...props} />
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
import { InternalLink } from './internal-link'
|
||||
import type { TranslatedLinkProps } from './types'
|
||||
import React from 'react'
|
||||
import React, { useMemo } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
/**
|
||||
|
@ -17,5 +17,6 @@ import { useTranslation } from 'react-i18next'
|
|||
*/
|
||||
export const TranslatedInternalLink: React.FC<TranslatedLinkProps> = ({ i18nKey, i18nOption, ...props }) => {
|
||||
const { t } = useTranslation()
|
||||
return <InternalLink text={t(i18nKey, i18nOption)} {...props} />
|
||||
const text = useMemo(() => (i18nOption ? t(i18nKey, i18nOption) : t(i18nKey)), [i18nKey, i18nOption, t])
|
||||
return <InternalLink text={text} {...props} />
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import type { IconName } from '../fork-awesome/fork-awesome-icon'
|
||||
import type { TOptions } from 'i18next'
|
||||
import type { TOptionsBase } from 'i18next'
|
||||
|
||||
interface GeneralLinkProp {
|
||||
href: string
|
||||
|
@ -20,5 +20,5 @@ export interface LinkWithTextProps extends GeneralLinkProp {
|
|||
|
||||
export interface TranslatedLinkProps extends GeneralLinkProp {
|
||||
i18nKey: string
|
||||
i18nOption?: TOptions
|
||||
i18nOption?: TOptionsBase & Record<string, unknown>
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ export const UiNotificationBoundary: React.FC<PropsWithChildren> = ({ children }
|
|||
)
|
||||
|
||||
const showErrorNotification = useCallback(
|
||||
(messageI18nKey: string, messageI18nOptions?: TOptions) =>
|
||||
(messageI18nKey: string, messageI18nOptions: Record<string, unknown> = {}) =>
|
||||
(error: Error): void => {
|
||||
log.error(t(messageI18nKey, messageI18nOptions), error)
|
||||
void dispatchUiNotification('common.errorOccurred', messageI18nKey, {
|
||||
|
|
Loading…
Reference in a new issue