Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Internationalization with @angular/localize

Marcell Kiss
September 27, 2023

Internationalization with @angular/localize

Internationalization with @angular/localize

Tags: i18n, angular

Marcell Kiss

September 27, 2023
Tweet

More Decks by Marcell Kiss

Other Decks in Technology

Transcript

  1. Intro Marcell Kiss, MSc 
 Senior Software Engineer, Architect @marcelltech

    @marcellkiss @marcellkiss marcell.tech Contractor #EnterpriseArchitecture Organizer of Angular Hungary 🇩🇪 🇭🇺 Trainer at Angular Architects
  2. Goal of the talk ✅ Give a high level overview

    ✅ Show implementation details ✅ Give con f idence to execute @marcelltech
  3. The Mental Model of i18n @marcelltech • What is i18n?

    • Di ff erent approches • The process of translation
  4. Formatting @marcelltech 9999.999 9,999.999 9,999.999 9.999,999 new Date(‘2023-12-31’) 31 Dec

    2024, 01:00:00 Dec 31, 2024, 1:00:00 AM 31 de dez. de 2024 01:00:00
  5. What is locale? @marcelltech “ parameters that de f ine

    the user's language and region {language}-{region}
  6. @marcelltech Multi-country language en-GB 
 en-US 
 en-AU 
 en-CA

    Multi language country de-CH 
 fr-CH 
 it-CH Locale examples
  7. Runtime vs Build Time Comparison @marcelltech Runtime Build Time Performance

    ✅ SEO compatibility ✅ SSR compatibility ✅ Build time ✅ Change language without reload ✅
  8. Angular i18n • Prepare .html + .ts f iles •

    Extract terms • Setup con f ig • Get translations • Build localized apps • Deploy & host? COMPLETE @marcelltech
  9. ICU expressions Intro @marcelltech { 
 component_property, // angular variable

    
 icu_clause, // ‘plural’ or ‘select’ 
 case_statements // conditional terms 
 }
  10. @marcelltech Build speed is quick… Building a multi library nx

    app With 1.000+ terms Raw size of ~1MB main.js + several lazy-loaded packages ~58.9ms and ~64.1 ms nx run my-app:build --localize --skip-nx-cache
  11. Summary • De f inition of i18n • De f

    inition of locale • Implementation approaches • The process overview • Usage of @angular/localize • i18n in .html & $localize in .ts • Extract terms • Translate terms • Build localized apps • Deployment & hosting What we learned @marcelltech
  12. Resources - [OSS] Nx Angular i18n Example on GitHub 


    https://github.com/marcellkiss/nx-angular-i18n-example - [OSS] Practice locales on Stackblitz 
 https://stackblitz.com/edit/stackblitz-starters-g1gkjb? f ile=src%2Fmain.ts - [Docs] O ff icial Angular Documentation 
 https://angular.io/guide/i18n-overview - [Resource] ISO Language Codes 
 https://www.andiamo.co.uk/resources/iso-language-codes/ - [Images] Images used for the slides 
 https://unsplash.com/, https://pexels.com/ 
 
 @marcelltech