Bird
0
0

What will be the rendered output of this React component using Remix i18n if the translation key 'greeting' is 'Hello' in English and 'Hola' in Spanish, and the current locale is 'es'?

medium📝 Predict Output Q5 of 15
Remix - Advanced Patterns
What will be the rendered output of this React component using Remix i18n if the translation key 'greeting' is 'Hello' in English and 'Hola' in Spanish, and the current locale is 'es'?
function Greeting() {
  const { t } = useTranslation();
  return <h1>{t('greeting')}</h1>;
}
AError: Missing translation
B<h1>Hello</h1>
C<h1>greeting</h1>
D<h1>Hola</h1>
Step-by-Step Solution
Solution:
  1. Step 1: Identify current locale and translation key

    The locale is 'es' (Spanish), so the translation for 'greeting' is 'Hola'.
  2. Step 2: Understand useTranslation output

    The t function returns the translated string for the key based on locale.
  3. Final Answer:

    <h1>Hola</h1> -> Option D
  4. Quick Check:

    Translation key 'greeting' in 'es' = 'Hola' [OK]
Quick Trick: t('key') returns translation for current locale [OK]
Common Mistakes:
MISTAKES
  • Expecting English output when locale is Spanish
  • Thinking t returns the key string
  • Assuming error if translation exists

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Remix Quizzes