Bird
0
0

You want to mark multiple pieces of text in an Angular template for translation, each with a unique description. Which approach correctly applies this?

hard📝 Application Q15 of 15
Angular - Internationalization and Accessibility
You want to mark multiple pieces of text in an Angular template for translation, each with a unique description. Which approach correctly applies this?
A<h2 i18n="@@headerDesc">Welcome</h2> <p i18n="@@introDesc">This is the intro paragraph.</p>
B<h2 i18n-desc="headerDesc">Welcome</h2> <p i18n-desc="introDesc">This is the intro paragraph.</p>
C<h2 i18n="headerDesc">Welcome</h2> <p i18n="introDesc">This is the intro paragraph.</p>
D<h2 i18n="Welcome header">Welcome</h2> <p i18n="Intro paragraph">This is the intro paragraph.</p>
Step-by-Step Solution
Solution:
  1. Step 1: Use unique descriptions with @@ in i18n attribute

    Angular uses the syntax i18n="@@description" to add unique descriptions for each translatable text.
  2. Step 2: Evaluate each option

    Welcome

    This is the intro paragraph.

    correctly uses i18n="@@headerDesc" and i18n="@@introDesc".

    Welcome

    This is the intro paragraph.

    uses invalid i18n-desc.

    Welcome

    This is the intro paragraph.

    misses @@ prefix.

    Welcome

    This is the intro paragraph.

    uses plain text instead of description keys.
  3. Final Answer:

    <h2 i18n="@@headerDesc">Welcome</h2> <p i18n="@@introDesc">This is the intro paragraph.</p> -> Option A
  4. Quick Check:

    Use i18n="@@uniqueDescription" for each text [OK]
Quick Trick: Use @@ prefix in i18n for unique translation descriptions [OK]
Common Mistakes:
  • Using i18n-desc instead of i18n
  • Omitting @@ prefix for descriptions
  • Putting descriptions as plain text in i18n attribute

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes