Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is Angular i18n built-in support?
Angular i18n built-in support is a feature that helps developers create applications that can display content in different languages by using Angular's tools and syntax for translation.
Click to reveal answer
beginner
How do you mark text for translation in Angular templates?
You mark text for translation by adding the i18n attribute to HTML elements or Angular components in your template.
Click to reveal answer
intermediate
What command extracts translation messages from Angular templates?
The command ng extract-i18n extracts all marked messages into a translation source file, usually in XLIFF format.
Click to reveal answer
intermediate
How does Angular handle multiple languages at build time?
Angular uses different build configurations to generate separate versions of the app for each language by replacing the translation files during the build process.
Click to reveal answer
advanced
What is the role of the i18n-select and i18n-plural directives?
i18n-select chooses text based on a variable's value, and i18n-plural handles plural forms in translations, helping to show correct messages depending on numbers or conditions.
Click to reveal answer
Which attribute do you add to an HTML element to mark it for translation in Angular?
Atranslate
Bi18n
Cng-translate
Dlocalize
✗ Incorrect
Angular uses the i18n attribute to mark text for translation.
What file format does Angular commonly use for translation source files?
AXLIFF
BYAML
CJSON
DCSV
✗ Incorrect
Angular typically uses XLIFF files to store extracted translation messages.
Which Angular CLI command extracts translation messages from your app?
Ang extract-i18n
Bng serve
Cng generate i18n
Dng build
✗ Incorrect
The ng extract-i18n command extracts marked messages for translation.
How does Angular apply different languages in the app?
AUsing CSS classes
BAt runtime by switching files
CBy generating separate builds per language
DBy changing the HTML tag
✗ Incorrect
Angular creates separate builds for each language during build time.
What does the i18n-plural directive help with?
ATranslating images
BChanging font size
CSwitching themes
DHandling plural forms in translations
✗ Incorrect
i18n-plural helps show correct text based on plural rules.
Explain how Angular's built-in i18n support helps create multilingual apps.
Think about how you prepare text for translation and how Angular uses those translations.
You got /4 concepts.
Describe the purpose of the i18n-select and i18n-plural directives in Angular.
Consider how messages change depending on conditions or numbers.
You got /4 concepts.
Practice
(1/5)
1. What is the primary purpose of the i18n attribute in Angular templates?
easy
A. To mark text for translation into different languages
B. To apply CSS styles conditionally
C. To bind data to the component
D. To define event handlers for user actions
Solution
Step 1: Understand the role of i18n in Angular
The i18n attribute is used to identify text in templates that should be translated for internationalization.
Step 2: Compare with other options
The other options relate to styling, data binding, and events, which are unrelated to translation.
Final Answer:
To mark text for translation into different languages -> Option A
Quick Check:
i18n attribute = mark text for translation [OK]
Hint: Remember: i18n means internationalization, so it marks text for translation [OK]
Common Mistakes:
Confusing i18n with data binding syntax
Thinking i18n applies styles or events
Assuming i18n is a directive instead of an attribute
2. Which of the following is the correct syntax to mark a paragraph for translation in Angular?
easy
A.
Hello, welcome!
B.
Hello, welcome!
C.
Hello, welcome!
D.
Hello, welcome!
Solution
Step 1: Recall Angular i18n attribute usage
The i18n attribute is added directly to the element without brackets or asterisk.
Step 2: Analyze each option
Hello, welcome!
uses i18n correctly.
Hello, welcome!
uses property binding syntax which is incorrect.
Hello, welcome!
uses structural directive syntax which is invalid here.
Hello, welcome!
uses a non-existent attribute i18n-text.
Final Answer:
<p i18n>Hello, welcome!</p> -> Option D
Quick Check:
Use plain i18n attribute without brackets or asterisk [OK]
Hint: Use plain i18n attribute on elements, no brackets or asterisks [OK]
Common Mistakes:
Using property binding syntax [i18n]
Using structural directive syntax *i18n
Inventing attributes like i18n-text
3. 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?
medium
A. Welcome, !
B. Welcome, {{ userName }}!
C. Welcome, Alice!
D. Error: Missing translation
Solution
Step 1: Understand interpolation with i18n
The i18n attribute marks the text for translation but Angular still processes interpolation expressions like {{ userName }}.
Step 2: Consider the locale and variable value
With English locale and userName as 'Alice', the text renders with the variable replaced by 'Alice'.
Final Answer:
Welcome, Alice! -> Option C
Quick Check:
i18n with interpolation outputs translated text with variables replaced [OK]
Hint: 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
4. You run ng extract-i18n but the generated translation file is empty. What is the most likely cause?
medium
A. The Angular CLI version is outdated
B. No i18n attributes found in templates
C. The app has no components
D. The translation file path is incorrect
Solution
Step 1: Understand what ng extract-i18n does
This command extracts marked text with i18n attributes from templates into translation files.
Step 2: Analyze why the file might be empty
If no i18n attributes exist, there is nothing to extract, resulting in an empty file.
Final Answer:
No i18n attributes found in templates -> Option B
Quick Check:
Empty extraction file means no i18n markers found [OK]
Hint: Check templates for i18n attributes before extracting [OK]
Common Mistakes:
Assuming CLI version causes empty file
Thinking app components absence causes empty file
Confusing file path issues with extraction content
5. You want to build your Angular app to support English and French using built-in i18n. Which steps are required to serve users in their language?
hard
A. Extract translations, provide French translation file, build app twice with different locales
B. Add i18n attribute, write translations inline, build once
C. Use runtime translation service only, no build changes needed
D. Create separate components for each language manually
Solution
Step 1: Extract translations and provide translation files
Use Angular CLI to extract text marked with i18n and create translation files for English and French.
Step 2: Build the app separately for each locale
Build the app twice, once with English locale and once with French locale, so each build contains the correct translations.
Final Answer:
Extract translations, provide French translation file, build app twice with different locales -> Option A
Quick Check:
Angular i18n requires extraction, translation files, and separate builds [OK]
Hint: Extract, translate, build per locale to support multiple languages [OK]