Bird
0
0

You want to support English (US), French (France), and German (Germany) locales in your Angular app with dynamic switching. Which approach correctly sets this up?

hard📝 component behavior Q8 of 15
Angular - Internationalization and Accessibility
You want to support English (US), French (France), and German (Germany) locales in your Angular app with dynamic switching. Which approach correctly sets this up?
ARegister all locale data with registerLocaleData(), inject LOCALE_ID dynamically via a service, and update it on user selection.
BSet LOCALE_ID to 'en-US' in providers and rebuild app for each locale change.
CUse multiple LOCALE_ID providers, one for each locale, and Angular picks automatically.
DOnly register English locale data and rely on browser language for others.
Step-by-Step Solution
Solution:
  1. Step 1: Understand multi-locale support

    Register all needed locale data upfront to enable formatting for each language.
  2. Step 2: Enable dynamic switching

    Inject LOCALE_ID dynamically via a service to change locale at runtime based on user choice.
  3. Step 3: Evaluate incorrect options

    Rebuilding app or multiple providers is inefficient or invalid; relying on browser alone is incomplete.
  4. Final Answer:

    Register all locale data with registerLocaleData(), inject LOCALE_ID dynamically via a service, and update it on user selection. -> Option A
  5. Quick Check:

    Multi-locale dynamic switching = register all + dynamic LOCALE_ID [OK]
Quick Trick: Register all locales and update LOCALE_ID dynamically [OK]
Common Mistakes:
  • Rebuilding app for each locale
  • Using multiple LOCALE_ID providers
  • Relying only on browser language

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes