Challenge - 5 Problems
Content Translation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2:00remaining
How does Next.js handle static content translation with i18n routing?
Given a Next.js app configured with i18n locales ['en', 'fr'], what will be the URL path for the French version of the homepage?
Attempts:
2 left
💡 Hint
Next.js i18n routing prefixes the locale as a path segment by default.
✗ Incorrect
Next.js automatically prefixes the locale code as the first path segment for localized routes. So the French homepage is at /fr.
❓ state_output
intermediate2:00remaining
What is the output of this Next.js translation hook usage?
Consider this React component using next-i18next's useTranslation hook:
If the 'common' namespace JSON for English contains {"welcome_message": "Hello!"}, what will render on the page?
import { useTranslation } from 'next-i18next';
export default function Greeting() {
const { t } = useTranslation('common');
return <h1>{t('welcome_message')}</h1>;
}If the 'common' namespace JSON for English contains {"welcome_message": "Hello!"}, what will render on the page?
NextJS
import { useTranslation } from 'next-i18next'; export default function Greeting() { const { t } = useTranslation('common'); return <h1>{t('welcome_message')}</h1>; }
Attempts:
2 left
💡 Hint
The t function returns the translated string for the given key.
✗ Incorrect
The t function looks up the key welcome_message in the 'common' namespace and returns "Hello!" which is rendered inside the <h1> tag.
📝 Syntax
advanced2:00remaining
Which Next.js i18n config snippet correctly sets up English and Spanish locales with English as default?
Choose the valid Next.js configuration for internationalized routing with locales 'en' and 'es', defaulting to 'en'.
Attempts:
2 left
💡 Hint
The order of keys in the config object does not matter, but defaultLocale must be one of the locales.
✗ Incorrect
Option A correctly sets defaultLocale to 'en' and includes both locales. The order of keys in the object is irrelevant in JavaScript.
🔧 Debug
advanced2:00remaining
Why does this Next.js translation not update when locale changes?
A component uses useTranslation('common') and renders t('greeting'). The translation JSONs are correct. However, when switching locale, the text does not update. What is the likely cause?
NextJS
import { useTranslation } from 'next-i18next'; export default function Welcome() { const { t } = useTranslation('common'); return <p>{t('greeting')}</p>; }
Attempts:
2 left
💡 Hint
Next-i18next requires a provider or HOC to detect locale changes.
✗ Incorrect
If the app is not wrapped with appWithTranslation or the proper provider, the translation hook won't detect locale changes and won't update the text.
🧠 Conceptual
expert3:00remaining
What is the main advantage of using Next.js Server Components for content translation?
Select the best explanation for why Server Components improve content translation management in Next.js.
Attempts:
2 left
💡 Hint
Think about where translation data is fetched and rendered.
✗ Incorrect
Server Components fetch and render translation data on the server, so the client receives fully translated HTML. This reduces client JavaScript and improves SEO.