Skip to content

Commit 1c6e61a

Browse files
committed
add test for explicit locale
1 parent e4eaf31 commit 1c6e61a

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

Diff for: examples/example-app-router-playground/messages/de.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"hello": "Hallo {name}!"
44
},
55
"AsyncComponent": {
6-
"basic": "AsyncComponent",
6+
"basic": "AsyncComponent (de)",
77
"markup": "Markup with <important>bold content</important>",
88
"rich": "This is a <important>rich</important> text."
99
},

Diff for: examples/example-app-router-playground/src/components/AsyncComponent.tsx

+9
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ export default async function AsyncComponent() {
1717
);
1818
}
1919

20+
export async function AsyncComponentGerman() {
21+
const t = await getTranslations({locale: 'de', namespace: 'AsyncComponent'});
22+
return (
23+
<p data-testid="AsyncComponentGerman" lang="de">
24+
{t('basic')}
25+
</p>
26+
);
27+
}
28+
2029
export async function TypeTest() {
2130
const t = await getTranslations('AsyncComponent');
2231

Diff for: examples/example-app-router-playground/tests/main.spec.ts

+7
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,13 @@ it('can use async APIs in async components', async ({page}) => {
659659
.getByText('AsyncComponent');
660660
});
661661

662+
it('can use an explicit locale in an async component', async ({page}) => {
663+
await page.goto('/de');
664+
await expect(page.getByTestId('AsyncComponentGerman')).toHaveText(
665+
'AsyncComponent (de)'
666+
);
667+
});
668+
662669
it('supports custom prefixes', async ({page}) => {
663670
await page.goto('/spain');
664671
await expect(page).toHaveURL('/spain');

0 commit comments

Comments
 (0)