'use client' import { useTranslation } from '@payloadcms/ui' import React from 'react' import type { CustomTranslationsKeys, CustomTranslationsObject } from './config.js' export const ComponentWithCustomI18n = () => { const { i18n, t } = useTranslation() const componentWithCustomI18nDefaultValidT = t('fields:addLink') // @ts-expect-error // Keep the ts-expect-error comment. This NEEDS to throw an error const componentWithCustomI18nDefaultInvalidT = t('fields:addLink2') const componentWithCustomI18nDefaultValidI18nT = i18n.t('fields:addLink') // @ts-expect-error // Keep the ts-expect-error comment. This NEEDS to throw an error const componentWithCustomI18nDefaultInvalidI18nT = i18n.t('fields:addLink2') const componentWithCustomI18nCustomValidT = t('general:test') const componentWithCustomI18nCustomValidI18nT = i18n.t('general:test') return (

ComponentWithCustomI18n Default :

ComponentWithCustomI18n Default Valid t:{' '} {componentWithCustomI18nDefaultValidT}
ComponentWithCustomI18n Default Valid i18n.t:{' '} {componentWithCustomI18nDefaultValidI18nT}
ComponentWithCustomI18n Default Invalid t:{' '} {componentWithCustomI18nDefaultInvalidT}
ComponentWithCustomI18n Default Invalid i18n.t: {' '} {componentWithCustomI18nDefaultInvalidI18nT}

ComponentWithCustomI18n Custom:


ComponentWithCustomI18n Custom Valid t:{' '} {componentWithCustomI18nCustomValidT}
ComponentWithCustomI18n Custom Valid i18n.t:{' '} {componentWithCustomI18nCustomValidI18nT}
) }