Complete the code to import the NextIntlProvider component from the next-intl library.
import { [1] } from 'next-intl';
The NextIntlProvider component is imported from 'next-intl' to provide internationalization support in Next.js apps.
Complete the code to load locale messages asynchronously in a Next.js page.
export async function getStaticProps({ params }) {
const messages = await import(`../messages/$[1].json`);
return { props: { messages: messages.default } };
}The 'locale' parameter contains the current locale string, used to load the correct messages file.
Fix the error in the NextIntlProvider usage by completing the missing prop.
<NextIntlProvider locale={locale} messages={messages} [1]>
<Component {...pageProps} />
</NextIntlProvider>The 'fallbackLocale' prop specifies which locale to use if the current locale messages are missing.
Fill both blanks to create a translation hook and use it to translate a key.
import { useTranslations } from 'next-intl'; export default function Greeting() { const t = [1](); return <p>{t([2])}</p>; }
The hook 'useTranslations' returns a function 't' to translate keys like 'greeting.hello'.
Fill all three blanks to define a messages object, load it, and pass it to NextIntlProvider.
const messages = [1]; export async function getStaticProps() { return { props: { messages: [2] } }; } export default function App({ Component, pageProps }) { return ( <NextIntlProvider locale="en" messages=[3]> <Component {...pageProps} /> </NextIntlProvider> ); }
We define a messages object, return it in getStaticProps, and pass pageProps.messages to NextIntlProvider.