question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New localize extractor tool: incorrect source/target with plural forms

See original GitHub issue

🐞 bug report

Affected Package

The issue seems to be caused by package @angular/localize

Is this a regression?

No because it’s a new tool, but yes because the old extractor worked.

Description

When using the new extractor tool introduced in https://github.com/angular/angular/pull/32912 (./node_modules/.bin/localize-extract), it seems to create an XLIFF 1.2 file with invalid source when using plural in templates. For example with the following template:

<span i18n>Updated {minutes, plural, =0 {just now} =1 {one minute ago} other {{{minutes}} minutes ago}}</span>

It creates this element

<trans-unit id="5a134dee893586d02bffc9611056b9cadf9abfad" datatype="html">
  <source>{VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other {{INTERPOLATION} minutes ago}}</source>
  <context-group purpose="location">
    <context context-type="sourcefile">../app/app.component.html</context>
    <context context-type="linenumber">1</context>
  </context-group>
</trans-unit>

If we use the source as a target:

<trans-unit id="5a134dee893586d02bffc9611056b9cadf9abfad" datatype="html">
  <source>{VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other {{INTERPOLATION} minutes ago}}</source>
  <target>{VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other {{INTERPOLATION} minutes ago}}</target>
  <context-group purpose="location">
    <context context-type="sourcefile">../app/app.component.html</context>
    <context context-type="linenumber">1</context>
  </context-group>
</trans-unit>

Then we can’t build the application:

Error: Unexpected character "EOF" (Do you have an unescaped "{" in your template? Use "{{ '{' }}") to escape it.)
Error: Invalid ICU message. Missing '}'.

πŸ”¬ Minimal Reproduction

https://github.com/Chocobozzz/angular-test

πŸ”₯ Exception or Error

Error: Unexpected character "EOF" (Do you have an unescaped "{" in your template? Use "{{ '{' }}") to escape it.)
Error: Invalid ICU message. Missing '}'.

🌍 Your Environment

Angular Version:

Angular CLI: 10.1.0-next.4
Node: 12.18.3
OS: linux x64

Angular: 10.1.0-next.5
... animations, common, compiler, compiler-cli, core, forms
... localize, platform-browser, platform-browser-dynamic, router
... service-worker
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.1001.0-next.4
@angular-devkit/build-angular     0.1001.0-next.4
@angular-devkit/build-optimizer   0.1001.0-next.4
@angular-devkit/build-webpack     0.1001.0-next.4
@angular-devkit/core              10.1.0-next.4
@angular-devkit/schematics        10.1.0-next.4
@angular/cli                      10.1.0-next.4
@ngtools/webpack                  10.1.0-next.4
@schematics/angular               10.1.0-next.4
@schematics/update                0.1001.0-next.4
rxjs                              6.6.2
typescript                        3.9.7
webpack                           4.44.1

Anything else relevant?

The issue seems to be {INTERPOLATION}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
petebacondarwincommented, Aug 25, 2020

Right! I have a plan to work on a migration tool for these purposes when we look at deprecating and removing the legacy ids.

1reaction
Chocobozzzcommented, Aug 25, 2020

I tested the latest angular release and it works. Thanks @petebacondarwin for your work on localization, that allowed us to reduce our build time by 10 with reduced localized bundle sizes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Localizing strings that contain plurals - Apple Developer
stringsdict file using the source editor, Control-click it and choose Open As > Source Code. A new .stringsdict file contains a dictionary with...
Read more >
evernote-serge/general - Gitter
Hi @ilearnf ,. (1) Plural forms are quite hard to support that way (not all file formats can be used; TMS/CAT tools don't...
Read more >
Localization - Lit.dev
Run lit-localize extract to generate an XLIFF file (details). Edit the generated XLIFF file to add a <target> translation tag (details).
Read more >
SwiftUI Localization Tutorial for iOS: Getting Started
Export and import strings from and to your project. Preview localizations while developing. Use new techniques to work with localized strings.
Read more >
Angular i18n: internationalization & localization with examples
In this article you will learn with examples how to get started with Angular I18n using the built-in internationalization module.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found