0
0
NextJSframework~20 mins

Content translation management in NextJS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Content Translation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2: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?
A/fr
B/fr/home
C/home?lang=fr
D/?locale=fr
Attempts:
2 left
💡 Hint
Next.js i18n routing prefixes the locale as a path segment by default.
state_output
intermediate
2:00remaining
What is the output of this Next.js translation hook usage?
Consider this React component using next-i18next's useTranslation hook:
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>;
}
A<h1>common.welcome_message</h1>
B<h1>welcome_message</h1>
C<h1>Translation missing</h1>
D<h1>Hello!</h1>
Attempts:
2 left
💡 Hint
The t function returns the translated string for the given key.
📝 Syntax
advanced
2: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'.
A{ defaultLocale: 'en', locales: ['en', 'es'] }
B{ locales: ['en', 'es'], defaultLocale: 'en' }
C{ locales: ['es', 'en'], defaultLocale: 'es' }
D{ locales: ['en', 'es'], defaultLocale: 'es' }
Attempts:
2 left
💡 Hint
The order of keys in the config object does not matter, but defaultLocale must be one of the locales.
🔧 Debug
advanced
2: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>;
}
AThe translation JSON files are missing the 'greeting' key.
BThe component is not wrapped with appWithTranslation HOC or provider.
CThe locale switcher is not updating the URL path.
DThe useTranslation hook is called outside a React component.
Attempts:
2 left
💡 Hint
Next-i18next requires a provider or HOC to detect locale changes.
🧠 Conceptual
expert
3: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.
AThey enable client-side translation switching without page reloads.
BThey automatically generate translation JSON files from server logs.
CThey allow translation data to be fetched and rendered on the server, reducing client bundle size and improving SEO.
DThey cache translations in the browser local storage for offline use.
Attempts:
2 left
💡 Hint
Think about where translation data is fetched and rendered.