Complete the code to import the translation function in a Next.js server component.
import { [1] } from 'next-intl/server';
The getTranslations function is imported from next-intl/server to fetch translations in server components.
Complete the code to get the locale from the Next.js params in a server component.
export default async function Page({ params }: { params: { locale: string } }) {
const locale = params.[1];
}The locale is accessed from params.locale as defined in the route parameters.
Fix the error in the code to load translations for the current locale.
const t = await [1]();useTranslations which is a hook and cannot be awaited.fetchTranslations.The getTranslations function is used to load translations asynchronously in server components.
Fill both blanks to create a translated heading and paragraph in a server component.
return ( <> <h1>[1]('home.title')</h1> <p>[2]('home.description')</p> </> );
useTranslations directly in JSX without calling it.The translation function t is called with keys to render translated text.
Fill all three blanks to correctly import, load, and use translations in a Next.js server component.
import { [1] } from 'next-intl/server'; export default async function Page({ params }) { const t = await [2](); return <h1>[3]('welcome.message')</h1>; }
useRouter instead of translation functions.First, import getTranslations. Then, load translations with getTranslations. Finally, use the translation function t to render text.