Skip to content

Commit

Permalink
fix(compiler): fix ICU select messages to use male/female/other (#21713)
Browse files Browse the repository at this point in the history
related to #21694

PR Close #21713
  • Loading branch information
vicb authored and mhevery committed Jan 24, 2018
1 parent 6921c20 commit 8e44577
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 78 deletions.
30 changes: 15 additions & 15 deletions packages/compiler/test/i18n/integration_common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ export function validateHtml(
expect(el.query(By.css('#i18n-14')).nativeElement).toHaveText('beaucoup');
expect(el.query(By.css('#i18n-17')).nativeElement).toHaveText('beaucoup');

cmp.sex = 'm';
cmp.sexB = 'f';
cmp.sex = 'male';
cmp.sexB = 'female';
tb.detectChanges();
expect(el.query(By.css('#i18n-8')).nativeElement).toHaveText('homme');
expect(el.query(By.css('#i18n-8b')).nativeElement).toHaveText('femme');
cmp.sex = 'f';
cmp.sex = 'female';
tb.detectChanges();
expect(el.query(By.css('#i18n-8')).nativeElement).toHaveText('femme');
cmp.sex = '0';
Expand Down Expand Up @@ -107,38 +107,38 @@ function expectHtml(el: DebugElement, cssSelector: string): any {
export const HTML = `
<div>
<h1 i18n>i18n attribute on tags</h1>
<div id="i18n-1"><p i18n>nested</p></div>
<div id="i18n-2"><p i18n="different meaning|">nested</p></div>
<div id="i18n-3"><p i18n><i>with placeholders</i></p></div>
<div id="i18n-3b"><p i18n><i class="preserved-on-placeholders">with placeholders</i></p></div>
<div id="i18n-3c"><div i18n><div>with <div>nested</div> placeholders</div></div></div>
<div>
<p id="i18n-4" i18n-title title="on not translatable node"></p>
<p id="i18n-5" i18n i18n-title title="on translatable node"></p>
<p id="i18n-6" i18n-title title></p>
</div>
<!-- no ph below because the ICU node is the only child of the div, i.e. no text nodes -->
<!-- no ph below because the ICU node is the only child of the div, i.e. no text nodes -->
<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} 0 {other}}
{sex, select, male {m} female {f} other {other}}
</div>
<div i18n id="i18n-8b">
{sexB, select, m {male} f {female}}
{sexB, select, male {m} female {f}}
</div>
<div i18n id="i18n-9">{{ "count = " + count }}</div>
<div i18n id="i18n-10">sex = {{ sex }}</div>
<div i18n id="i18n-11">{{ "custom name" //i18n(ph="CUSTOM_NAME") }}</div>
<div i18n id="i18n-11">{{ "custom name" //i18n(ph="CUSTOM_NAME") }}</div>
</div>
<!-- i18n -->
<h1 id="i18n-12" >Markers in html comments</h1>
<h1 id="i18n-12" >Markers in html comments</h1>
<div id="i18n-13" i18n-title title="in a translatable section"></div>
<div id="i18n-14">{count, plural, =0 {zero} =1 {one} =2 {two} other {<b>many</b>}}</div>
<!-- /i18n -->
Expand Down
50 changes: 25 additions & 25 deletions packages/compiler/test/i18n/integration_xliff2_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,38 +107,38 @@ const XLIFF2_TOMERGE = `
<target>{VAR_PLURAL, plural, =0 {zero} =1 {un} =2 {deux} other {<pc id="0" equivStart="START_BOLD_TEXT" equivEnd="CLOSE_BOLD_TEXT" type="fmt" dispStart="&lt;b&gt;" dispEnd="&lt;/b&gt;">beaucoup</pc>} }</target>
</segment>
</unit>
<unit id="4360321700965841752">
<unit id="703464324060964421">
<segment>
<source>
<ph id="0" equiv="ICU" disp="{sex, select, 0 {...} m {...} f {...}}"/>
<ph id="0" equiv="ICU" disp="{sex, select, other {...} male {...} female {...}}"/>
</source>
<target><ph id="0" equiv="ICU" disp="{sex, select, 0 {...} m {...} f {...}}"/></target>
<target><ph id="0" equiv="ICU" disp="{sex, select, other {...} male {...} female {...}}"/></target>
</segment>
</unit>
<unit id="5460933846928880074">
<unit id="5430374139308914421">
<notes>
<note category="location">file.ts:23</note>
</notes>
<segment>
<source>{VAR_SELECT, select, 0 {other} m {male} f {female} }</source>
<target>{VAR_SELECT, select, 0 {autre} m {homme} f {femme} }</target>
<source>{VAR_SELECT, select, other {other} male {m} female {female} }</source>
<target>{VAR_SELECT, select, other {autre} male {homme} female {femme} }</target>
</segment>
</unit>
<unit id="1746565782635215">
<unit id="1300564767229037107">
<notes>
<note category="location">file.ts:25,27</note>
</notes>
<segment>
<source>
<ph id="0" equiv="ICU" disp="{sexB, select, m {...} f {...}}"/>
<ph id="0" equiv="ICU" disp="{sexB, select, male {...} female {...}}"/>
</source>
<target><ph id="0" equiv="ICU" disp="{sexB, select, m {...} f {...}}"/></target>
<target><ph id="0" equiv="ICU" disp="{sexB, select, male {...} female {...}}"/></target>
</segment>
</unit>
<unit id="5868084092545682515">
<unit id="2500580913783245106">
<segment>
<source>{VAR_SELECT, select, m {male} f {female} }</source>
<target>{VAR_SELECT, select, m {homme} f {femme} }</target>
<source>{VAR_SELECT, select, male {m} female {f} }</source>
<target>{VAR_SELECT, select, male {homme} female {femme} }</target>
</segment>
</unit>
<unit id="4851788426695310455">
Expand All @@ -165,15 +165,15 @@ const XLIFF2_TOMERGE = `
<target>dans une section traductible</target>
</segment>
</unit>
<unit id="2387287228265107305">
<unit id="2329001734457059408">
<segment>
<source>
<pc id="0" equivStart="START_HEADING_LEVEL1" equivEnd="CLOSE_HEADING_LEVEL1" type="other" dispStart="&lt;h1&gt;" dispEnd="&lt;/h1&gt;">Markers in html comments</pc>
<pc id="0" equivStart="START_HEADING_LEVEL1" equivEnd="CLOSE_HEADING_LEVEL1" type="other" dispStart="&lt;h1&gt;" dispEnd="&lt;/h1&gt;">Markers in html comments</pc>
<pc id="1" equivStart="START_TAG_DIV" equivEnd="CLOSE_TAG_DIV" type="other" dispStart="&lt;div&gt;" dispEnd="&lt;/div&gt;"></pc>
<pc id="2" equivStart="START_TAG_DIV_1" equivEnd="CLOSE_TAG_DIV" type="other" dispStart="&lt;div&gt;" dispEnd="&lt;/div&gt;"><ph id="3" equiv="ICU" disp="{count, plural, =0 {...} =1 {...} =2 {...} other {...}}"/></pc>
</source>
<target>
<pc id="0" equivStart="START_HEADING_LEVEL1" equivEnd="CLOSE_HEADING_LEVEL1" type="other" dispStart="&lt;h1&gt;" dispEnd="&lt;/h1&gt;">Balises dans les commentaires html</pc>
<pc id="0" equivStart="START_HEADING_LEVEL1" equivEnd="CLOSE_HEADING_LEVEL1" type="other" dispStart="&lt;h1&gt;" dispEnd="&lt;/h1&gt;">Balises dans les commentaires html</pc>
<pc id="1" equivStart="START_TAG_DIV" equivEnd="CLOSE_TAG_DIV" type="other" dispStart="&lt;div&gt;" dispEnd="&lt;/div&gt;"></pc>
<pc id="2" equivStart="START_TAG_DIV_1" equivEnd="CLOSE_TAG_DIV" type="other" dispStart="&lt;div&gt;" dispEnd="&lt;/div&gt;"><ph id="3" equiv="ICU" disp="{count, plural, =0 {...} =1 {...} =2 {...} other {...}}"/></pc>
</target>
Expand Down Expand Up @@ -284,40 +284,40 @@ const XLIFF2_EXTRACTED = `
<source>{VAR_PLURAL, plural, =0 {zero} =1 {one} =2 {two} other {<pc id="0" equivStart="START_BOLD_TEXT" equivEnd="CLOSE_BOLD_TEXT" type="fmt" dispStart="&lt;b&gt;" dispEnd="&lt;/b&gt;">many</pc>} }</source>
</segment>
</unit>
<unit id="4360321700965841752">
<unit id="703464324060964421">
<notes>
<note category="location">file.ts:22,24</note>
</notes>
<segment>
<source>
<ph id="0" equiv="ICU" disp="{sex, select, 0 {...} m {...} f {...}}"/>
<ph id="0" equiv="ICU" disp="{sex, select, male {...} female {...} other {...}}"/>
</source>
</segment>
</unit>
<unit id="5460933846928880074">
<unit id="5430374139308914421">
<notes>
<note category="location">file.ts:23</note>
</notes>
<segment>
<source>{VAR_SELECT, select, 0 {other} m {male} f {female} }</source>
<source>{VAR_SELECT, select, male {m} female {f} other {other} }</source>
</segment>
</unit>
<unit id="1746565782635215">
<unit id="1300564767229037107">
<notes>
<note category="location">file.ts:25,27</note>
</notes>
<segment>
<source>
<ph id="0" equiv="ICU" disp="{sexB, select, m {...} f {...}}"/>
<ph id="0" equiv="ICU" disp="{sexB, select, male {...} female {...}}"/>
</source>
</segment>
</unit>
<unit id="5868084092545682515">
<unit id="2500580913783245106">
<notes>
<note category="location">file.ts:26</note>
</notes>
<segment>
<source>{VAR_SELECT, select, m {male} f {female} }</source>
<source>{VAR_SELECT, select, male {m} female {f} }</source>
</segment>
</unit>
<unit id="4851788426695310455">
Expand Down Expand Up @@ -353,13 +353,13 @@ const XLIFF2_EXTRACTED = `
<source>in a translatable section</source>
</segment>
</unit>
<unit id="2387287228265107305">
<unit id="2329001734457059408">
<notes>
<note category="location">file.ts:34,38</note>
</notes>
<segment>
<source>
<pc id="0" equivStart="START_HEADING_LEVEL1" equivEnd="CLOSE_HEADING_LEVEL1" type="other" dispStart="&lt;h1&gt;" dispEnd="&lt;/h1&gt;">Markers in html comments</pc>
<pc id="0" equivStart="START_HEADING_LEVEL1" equivEnd="CLOSE_HEADING_LEVEL1" type="other" dispStart="&lt;h1&gt;" dispEnd="&lt;/h1&gt;">Markers in html comments</pc>
<pc id="1" equivStart="START_TAG_DIV" equivEnd="CLOSE_TAG_DIV" type="other" dispStart="&lt;div&gt;" dispEnd="&lt;/div&gt;"></pc>
<pc id="2" equivStart="START_TAG_DIV_1" equivEnd="CLOSE_TAG_DIV" type="other" dispStart="&lt;div&gt;" dispEnd="&lt;/div&gt;"><ph id="3" equiv="ICU" disp="{count, plural, =0 {...} =1 {...} =2 {...} other {...}}"/></pc>
</source>
Expand Down
42 changes: 21 additions & 21 deletions packages/compiler/test/i18n/integration_xliff_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,25 +93,25 @@ const XLIFF_TOMERGE = `
<source>{VAR_PLURAL, plural, =0 {zero} =1 {one} =2 {two} other {<x id="START_BOLD_TEXT" ctype="x-b" equiv-text="&lt;b&gt;"/>many<x id="CLOSE_BOLD_TEXT" ctype="x-b" equiv-text="&lt;/b&gt;"/>} }</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="ba9106fca6e4e33a9b703a8c1927e2d1794dd9ff" datatype="html">
<trans-unit id="49feb201083cbd2c8bfc48a4ae11f105fb984876" datatype="html">
<source>
<x id="ICU" equiv-text="{sex, select, m {...} f {...}}"/>
<x id="ICU" equiv-text="{sex, select, male {...} female {...}}"/>
</source>
<target><x id="ICU"/></target>
</trans-unit>
<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 id="f3be30eb9a18f6e336cc3ca4dd66bbc3a35c5f97" datatype="html">
<source>{VAR_SELECT, select, other {other} male {m} female {f} }</source>
<target>{VAR_SELECT, select, other {autre} male {homme} female {femme}}</target>
</trans-unit>
<trans-unit id="078b7089573c5f66a2f78dce0adaa55e6715beb1" datatype="html">
<trans-unit id="cc16e9745fa0b95b2ebc2f18b47ed8e64fe5f0f9" datatype="html">
<source>
<x id="ICU" equiv-text="{sexB, select, m {...} f {...}}"/>
</source>
<target><x id="ICU"/></target>
</trans-unit>
<trans-unit id="a25cf2e21a299f30be1392e731163825233edc61" datatype="html">
<source>{VAR_SELECT, select, m {male} f {female} }</source>
<target>{VAR_SELECT, select, m {homme} f {femme} }</target>
<trans-unit id="4573f2edb0329d69afc2ab8c73c71e2f8b08f807" datatype="html">
<source>{VAR_SELECT, select, male {m} female {f} }</source>
<target>{VAR_SELECT, select, male {homme} female {femme} }</target>
</trans-unit>
<trans-unit id="d9879678f727b244bc7c7e20f22b63d98cb14890" datatype="html">
<source><x id="INTERPOLATION" equiv-text="{{ &quot;count = &quot; + count }}"/></source>
Expand All @@ -129,9 +129,9 @@ const XLIFF_TOMERGE = `
<source>in a translatable section</source>
<target>dans une section traductible</target>
</trans-unit>
<trans-unit id="eee74a5be8a75881a4785905bd8302a71f7d9f75" datatype="html">
<trans-unit id="7f6272480ea8e7ffab548da885ab8105ee2caa93" datatype="html">
<source>
<x id="START_HEADING_LEVEL1" ctype="x-h1" equiv-text="&lt;h1&gt;"/>Markers in html comments<x id="CLOSE_HEADING_LEVEL1" ctype="x-h1" equiv-text="&lt;/h1&gt;"/>
<x id="START_HEADING_LEVEL1" ctype="x-h1" equiv-text="&lt;h1&gt;"/>Markers in html comments<x id="CLOSE_HEADING_LEVEL1" ctype="x-h1" equiv-text="&lt;/h1&gt;"/>
<x id="START_TAG_DIV" ctype="x-div" equiv-text="&lt;div&gt;"/><x id="CLOSE_TAG_DIV" ctype="x-div" equiv-text="&lt;/div&gt;"/>
<x id="START_TAG_DIV_1" ctype="x-div" equiv-text="&lt;div&gt;"/><x id="ICU" equiv-text="{count, plural, =0 {...} =1 {...} =2 {...} other {...}}"/><x id="CLOSE_TAG_DIV" ctype="x-div" equiv-text="&lt;/div&gt;"/>
</source>
Expand Down Expand Up @@ -233,33 +233,33 @@ const XLIFF_EXTRACTED = `
<context context-type="linenumber">37</context>
</context-group>
</trans-unit>
<trans-unit id="ba9106fca6e4e33a9b703a8c1927e2d1794dd9ff" datatype="html">
<trans-unit id="49feb201083cbd2c8bfc48a4ae11f105fb984876" datatype="html">
<source>
<x id="ICU" equiv-text="{sex, select, 0 {...} m {...} f {...}}"/>
<x id="ICU" equiv-text="{sex, select, male {...} female {...} other {...}}"/>
</source>
<context-group purpose="location">
<context context-type="sourcefile">file.ts</context>
<context context-type="linenumber">22</context>
</context-group>
</trans-unit>
<trans-unit id="7b7916d063ebaafcd2e9dcdf697b5e184fcb8099" datatype="html">
<source>{VAR_SELECT, select, 0 {other} m {male} f {female} }</source>
<trans-unit id="f3be30eb9a18f6e336cc3ca4dd66bbc3a35c5f97" datatype="html">
<source>{VAR_SELECT, select, male {m} female {f} other {other} }</source>
<context-group purpose="location">
<context context-type="sourcefile">file.ts</context>
<context context-type="linenumber">23</context>
</context-group>
</trans-unit>
<trans-unit id="078b7089573c5f66a2f78dce0adaa55e6715beb1" datatype="html">
<trans-unit id="cc16e9745fa0b95b2ebc2f18b47ed8e64fe5f0f9" datatype="html">
<source>
<x id="ICU" equiv-text="{sexB, select, m {...} f {...}}"/>
<x id="ICU" equiv-text="{sexB, select, male {...} female {...}}"/>
</source>
<context-group purpose="location">
<context context-type="sourcefile">file.ts</context>
<context context-type="linenumber">25</context>
</context-group>
</trans-unit>
<trans-unit id="a25cf2e21a299f30be1392e731163825233edc61" datatype="html">
<source>{VAR_SELECT, select, m {male} f {female} }</source>
<trans-unit id="4573f2edb0329d69afc2ab8c73c71e2f8b08f807" datatype="html">
<source>{VAR_SELECT, select, male {m} female {f} }</source>
<context-group purpose="location">
<context context-type="sourcefile">file.ts</context>
<context context-type="linenumber">26</context>
Expand Down Expand Up @@ -297,9 +297,9 @@ const XLIFF_EXTRACTED = `
<context context-type="linenumber">54</context>
</context-group>
</trans-unit>
<trans-unit id="eee74a5be8a75881a4785905bd8302a71f7d9f75" datatype="html">
<trans-unit id="7f6272480ea8e7ffab548da885ab8105ee2caa93" datatype="html">
<source>
<x id="START_HEADING_LEVEL1" ctype="x-h1" equiv-text="&lt;h1&gt;"/>Markers in html comments<x id="CLOSE_HEADING_LEVEL1" ctype="x-h1" equiv-text="&lt;/h1&gt;"/>
<x id="START_HEADING_LEVEL1" ctype="x-h1" equiv-text="&lt;h1&gt;"/>Markers in html comments<x id="CLOSE_HEADING_LEVEL1" ctype="x-h1" equiv-text="&lt;/h1&gt;"/>
<x id="START_TAG_DIV" ctype="x-div" equiv-text="&lt;div&gt;"/><x id="CLOSE_TAG_DIV" ctype="x-div" equiv-text="&lt;/div&gt;"/>
<x id="START_TAG_DIV_1" ctype="x-div" equiv-text="&lt;div&gt;"/><x id="ICU" equiv-text="{count, plural, =0 {...} =1 {...} =2 {...} other {...}}"/><x id="CLOSE_TAG_DIV" ctype="x-div" equiv-text="&lt;/div&gt;"/>
</source>
Expand Down
Loading

0 comments on commit 8e44577

Please sign in to comment.