Bird
0
0

Given this Angular template snippet:

medium📝 component behavior Q13 of 15
Angular - Internationalization and Accessibility
Given this Angular template snippet:
<h1 i18n>Welcome, {{ userName }}!</h1>

What will be the output if userName is 'Alice' and the app is built with English locale?
AWelcome, !
BWelcome, {{ userName }}!
CWelcome, Alice!
DError: Missing translation
Step-by-Step Solution
Solution:
  1. Step 1: Understand interpolation with i18n

    The i18n attribute marks the text for translation but Angular still processes interpolation expressions like {{ userName }}.
  2. Step 2: Consider the locale and variable value

    With English locale and userName as 'Alice', the text renders with the variable replaced by 'Alice'.
  3. Final Answer:

    Welcome, Alice! -> Option C
  4. Quick Check:

    i18n with interpolation outputs translated text with variables replaced [OK]
Quick Trick: i18n marks text, interpolation fills variables at runtime [OK]
Common Mistakes:
  • Thinking interpolation is ignored inside i18n
  • Expecting raw {{ userName }} to show
  • Assuming missing translation error for default locale

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes