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:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Right! I have a plan to work on a migration tool for these purposes when we look at deprecating and removing the legacy ids.
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.