-
-
Notifications
You must be signed in to change notification settings - Fork 283
/
Copy pathAsyncComponent.tsx
46 lines (37 loc) · 1022 Bytes
/
AsyncComponent.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import {getTranslations} from 'next-intl/server';
export default async function AsyncComponent() {
const t = await getTranslations('AsyncComponent');
return (
<div data-testid="AsyncComponent">
<p>{t('basic')}</p>
<p>{t.rich('rich', {important: (chunks) => <b>{chunks}</b>})}</p>
<p>
{t.markup('markup', {
important: (chunks) => `<b>${chunks}</b>`
})}
</p>
<p>{String(t.has('basic'))}</p>
</div>
);
}
export async function AsyncComponentGerman() {
const t = await getTranslations({locale: 'de', namespace: 'AsyncComponent'});
return (
<p data-testid="AsyncComponentGerman" lang="de">
{t('basic')}
</p>
);
}
export async function TypeTest() {
const t = await getTranslations('AsyncComponent');
// @ts-expect-error
await getTranslations('Unknown');
// @ts-expect-error
t('unknown');
// @ts-expect-error
t.rich('unknown');
// @ts-expect-error
t.markup('unknown');
// @ts-expect-error
t.has('unknown');
}