Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/compiler/src/ml_parser/lexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ function isExpansionFormStart(
}

function isExpansionCaseStart(peek: number): boolean {
return peek === chars.$EQ || chars.isAsciiLetter(peek);
return peek === chars.$EQ || chars.isAsciiLetter(peek) || chars.isDigit(peek);
}

function compareCharCodeCaseInsensitive(code1: number, code2: number): boolean {
Expand Down
5 changes: 4 additions & 1 deletion packages/compiler/test/i18n/integration_common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ export function validateHtml(
cmp.sex = 'f';
tb.detectChanges();
expect(el.query(By.css('#i18n-8')).nativeElement).toHaveText('femme');
cmp.sex = '0';
tb.detectChanges();
expect(el.query(By.css('#i18n-8')).nativeElement).toHaveText('autre');

cmp.count = 123;
tb.detectChanges();
Expand Down Expand Up @@ -121,7 +124,7 @@ export const HTML = `
<div i18n id="i18n-7">{count, plural, =0 {zero} =1 {one} =2 {two} other {<b>many</b>}}</div>

<div i18n id="i18n-8">
{sex, select, m {male} f {female}}
{sex, select, m {male} f {female} 0 {other}}
</div>
<div i18n id="i18n-8b">
{sexB, select, m {male} f {female}}
Expand Down
14 changes: 7 additions & 7 deletions packages/compiler/test/i18n/integration_xliff_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ const XLIFF_TOMERGE = `
<source>{VAR_PLURAL, plural, =0 {zero} =1 {one} =2 {two} other {<x id="START_BOLD_TEXT" ctype="x-b"/>many<x id="CLOSE_BOLD_TEXT" ctype="x-b"/>} }</source>
<target>{VAR_PLURAL, plural, =0 {zero} =1 {un} =2 {deux} other {<x id="START_BOLD_TEXT" ctype="x-b"/>beaucoup<x id="CLOSE_BOLD_TEXT" ctype="x-b"/>} }</target>
</trans-unit>
<trans-unit id="85ef51de59fe5a8d13fba977b6689f164420c8ca" datatype="html">
<trans-unit id="ba9106fca6e4e33a9b703a8c1927e2d1794dd9ff" datatype="html">
<source>
<x id="ICU"/>
</source>
<target><x id="ICU"/></target>
</trans-unit>
<trans-unit id="c0ca5e58fe954d528bbfa516007a5a11690a7e99" datatype="html">
<source>{VAR_SELECT, select, m {male} f {female} }</source>
<target>{VAR_SELECT, select, m {homme} f {femme} }</target>
<trans-unit id="7b7916d063ebaafcd2e9dcdf697b5e184fcb8099" datatype="html">
<source>{VAR_SELECT, select, 0 {other} m {male} f {female} }</source>
<target>{VAR_SELECT, select, 0 {autre} m {homme} f {femme}}</target>
</trans-unit>
<trans-unit id="078b7089573c5f66a2f78dce0adaa55e6715beb1" datatype="html">
<source>
Expand Down Expand Up @@ -218,7 +218,7 @@ const XLIFF_EXTRACTED = `
<context context-type="linenumber">36</context>
</context-group>
</trans-unit>
<trans-unit id="85ef51de59fe5a8d13fba977b6689f164420c8ca" datatype="html">
<trans-unit id="ba9106fca6e4e33a9b703a8c1927e2d1794dd9ff" datatype="html">
<source>
<x id="ICU"/>
</source>
Expand All @@ -227,8 +227,8 @@ const XLIFF_EXTRACTED = `
<context context-type="linenumber">21</context>
</context-group>
</trans-unit>
<trans-unit id="c0ca5e58fe954d528bbfa516007a5a11690a7e99" datatype="html">
<source>{VAR_SELECT, select, m {male} f {female} }</source>
<trans-unit id="7b7916d063ebaafcd2e9dcdf697b5e184fcb8099" datatype="html">
<source>{VAR_SELECT, select, 0 {other} m {male} f {female} }</source>
<context-group purpose="location">
<context context-type="sourcefile">file.ts</context>
<context context-type="linenumber">22</context>
Expand Down
12 changes: 9 additions & 3 deletions packages/compiler/test/i18n/integration_xmb_xtb_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ const XTB = `
<translation id="5525133077318024839">sur des balises non traductibles</translation>
<translation id="8670732454866344690">sur des balises traductibles</translation>
<translation id="4593805537723189714">{VAR_PLURAL, plural, =0 {zero} =1 {un} =2 {deux} other {<ph name="START_BOLD_TEXT"/>beaucoup<ph name="CLOSE_BOLD_TEXT"/>}}</translation>
<translation id="4360321700965841752"><ph name="ICU"/></translation>
<translation id="5460933846928880074">{VAR_SELECT, select, 0 {autre} m {homme} f {femme} }</translation>
<translation id="1746565782635215"><ph name="ICU"/></translation>
<translation id="5868084092545682515">{VAR_SELECT, select, m {homme} f {femme}}</translation>
<translation id="4851788426695310455"><ph name="INTERPOLATION"/></translation>
Expand All @@ -84,17 +86,21 @@ const XTB = `
<translation id="5339604010413301604"><ph name="MAP_NAME"><ex>MAP_NAME</ex></ph></translation>
</translationbundle>`;

const XMB = ` <msg id="615790887472569365"><source>file.ts:3</source>i18n attribute on tags</msg>
const XMB = `<msg id="615790887472569365"><source>file.ts:3</source>i18n attribute on tags</msg>
<msg id="3707494640264351337"><source>file.ts:5</source>nested</msg>
<msg id="5539162898278769904" meaning="different meaning"><source>file.ts:7</source>nested</msg>
<msg id="3780349238193953556"><source>file.ts:9</source><source>file.ts:10</source><ph name="START_ITALIC_TEXT"><ex>&lt;i&gt;</ex></ph>with placeholders<ph name="CLOSE_ITALIC_TEXT"><ex>&lt;/i&gt;</ex></ph></msg>
<msg id="5525133077318024839"><source>file.ts:13</source>on not translatable node</msg>
<msg id="8670732454866344690"><source>file.ts:14</source>on translatable node</msg>
<msg id="4593805537723189714"><source>file.ts:19</source><source>file.ts:36</source>{VAR_PLURAL, plural, =0 {zero} =1 {one} =2 {two} other {<ph name="START_BOLD_TEXT"><ex>&lt;b&gt;</ex></ph>many<ph name="CLOSE_BOLD_TEXT"><ex>&lt;/b&gt;</ex></ph>} }</msg>
<msg id="1746565782635215"><source>file.ts:21,23</source><source>file.ts:24,26</source>
<msg id="4360321700965841752"><source>file.ts:21,23</source>
<ph name="ICU"><ex>ICU</ex></ph>
</msg>
<msg id="5868084092545682515"><source>file.ts:22</source><source>file.ts:25</source>{VAR_SELECT, select, m {male} f {female} }</msg>
<msg id="5460933846928880074"><source>file.ts:22</source>{VAR_SELECT, select, 0 {other} m {male} f {female} }</msg>
<msg id="1746565782635215"><source>file.ts:24,26</source>
<ph name="ICU"><ex>ICU</ex></ph>
</msg>
<msg id="5868084092545682515"><source>file.ts:25</source>{VAR_SELECT, select, m {male} f {female} }</msg>
<msg id="4851788426695310455"><source>file.ts:28</source><ph name="INTERPOLATION"><ex>INTERPOLATION</ex></ph></msg>
<msg id="9013357158046221374"><source>file.ts:29</source>sex = <ph name="INTERPOLATION"><ex>INTERPOLATION</ex></ph></msg>
<msg id="8324617391167353662"><source>file.ts:30</source><ph name="CUSTOM_NAME"><ex>CUSTOM_NAME</ex></ph></msg>
Expand Down
5 changes: 5 additions & 0 deletions packages/compiler/test/ml_parser/html_parser_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,11 @@ export function main() {
]);
});

it('should support ICU expressions with cases that contain numbers', () => {
const p = parser.parse(`{sex, select, male {m} female {f} 0 {other}}`, 'TestComp', true);
expect(p.errors.length).toEqual(0);
});

it('should error when expansion case is not closed', () => {
const p = parser.parse(`{messages.length, plural, =0 {one`, 'TestComp', true);
expect(humanizeErrors(p.errors)).toEqual([
Expand Down