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

Angular i18n - Current state and the future

Angular i18n - Current state and the future

Internationalization is a process of design and preparation application for easy adaptation to different region or culture.

This presentation is about how Angular Team approaches this problem and why we decided to go with official solution during adaptation to Chinese market even though official solution has few disadvantages.

I focus on official solution working during compile-time, sometimes comparing to libraries working in runtime.

Also, I present result of my research on current development process of this module, what we can expect in Angular 7 / 8.

Piotr Lewandowski

September 12, 2018
Tweet

More Decks by Piotr Lewandowski

Other Decks in Programming

Transcript

  1. <h1 i18n>Hello, {{ name }}!</h1> <img src="avatar.png" i18n-title title="It’s you!"

    /> <p i18n="UserModule|User Profile"> Last time seen at {{ lastVisited | date }} </p>
  2. <p>Alicja { count, plural, =0 { nie złapała Pokémona }

    one { złapała Pokémona } few { złapała {{count}} Pokémony } many { złapała {{count}} Pokémonów } other { złapała Pokémonów: {{count}} } }</p> Alicja złapała 5 Pokémonów count = 5
  3. <p>Brawo, { gender, select, male { złapałeś Pokémona } female

    { złapałaś Pokémona } other { Pokémon został złapany } }</p> Brawo, złapałeś Pokémona gender = ' male' '...'
  4. <h1 i18n="@@topbar.header"> Angular is cool </h1> <h1 i18n> Angular is

    cool </h1> Generated ID hash Content change = ID change Custom ID Never changes
  5. Mark HTML with i18n attributes Extract messages from HTML to

    XLIFF Copy & translate XLIFF Generate new app version for each language Outside Angular
  6. Currently... Everything at build time with AOT Duplicated builds for

    each locale Desired... ONE bundle for all locales Translating before application bootstraps
  7. On the roadmap since 2.0 Planned for Angular 7 with

    Ivy compiler Already in master since June 2018
  8. interface I18nDef { value: string; id?: string; meaning?: string; description?:

    string; } <h2 i18n="User profile@@page.header"> Hello, Gdańsk! </h2> interface I18nDef { value: 'Hello, Gdańsk!'; id?: 'page.header'; meaning?: undefined; description?: 'User profile'; }
  9. PR #24037 205 review comments ☺ Loading BEFORE Angular bootstraps

    All locales in ONE bundle Choose: AOT or RunTime ❔ XLIFF has to be in JS bundle
  10. Planned with Angular 7 with Ivy compiler Work in progress

    Polyfill already exists @ngx-translate/i18n-polyfill
  11. ✅ // tslint.json "i18n": [ true, "check-id", "check-text" ] *

    Requires codelyzer Optional, depending on your translation strategy
  12. <div> <div> Angular i18n is cool </div> </div> <article i18n>

    <h1 i18n="@@article.header"> Angular i18n is cool </h1> <p> ... </p> </article> Error: Could not mark an element as translatable inside a translatable section
  13. <div> <div> Angular i18n is cool </div> </div> <article> <h1

    i18n="@@article.header"> Angular i18n is cool </h1> <p i18n="@@article.content"> ... </p> </article>
  14. <div> <div> Angular i18n is cool </div> </div> <article i18n="@@article">

    <h1> Angular i18n is cool </h1> <p> ... </p> </article>
  15. Angular i18n: » Docs » Plans for v6 and v7

    General: » On i18n and l10n » i18nGuy - Guidelines
  16. Localization platforms: » Pootle » Transifex » POEditor » TextUnited

    Editors & scripts: » Virtaal » tiny ng-translator » ngx-i18nsupport (xliff merge)