Skip to content

Commit 8e44577

Browse files
vicbmhevery
authored andcommitted
fix(compiler): fix ICU select messages to use male/female/other (#21713)
related to #21694 PR Close #21713
1 parent 6921c20 commit 8e44577

File tree

5 files changed

+78
-78
lines changed

5 files changed

+78
-78
lines changed

packages/compiler/test/i18n/integration_common.ts

+15-15
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ export function validateHtml(
7171
expect(el.query(By.css('#i18n-14')).nativeElement).toHaveText('beaucoup');
7272
expect(el.query(By.css('#i18n-17')).nativeElement).toHaveText('beaucoup');
7373

74-
cmp.sex = 'm';
75-
cmp.sexB = 'f';
74+
cmp.sex = 'male';
75+
cmp.sexB = 'female';
7676
tb.detectChanges();
7777
expect(el.query(By.css('#i18n-8')).nativeElement).toHaveText('homme');
7878
expect(el.query(By.css('#i18n-8b')).nativeElement).toHaveText('femme');
79-
cmp.sex = 'f';
79+
cmp.sex = 'female';
8080
tb.detectChanges();
8181
expect(el.query(By.css('#i18n-8')).nativeElement).toHaveText('femme');
8282
cmp.sex = '0';
@@ -107,38 +107,38 @@ function expectHtml(el: DebugElement, cssSelector: string): any {
107107
export const HTML = `
108108
<div>
109109
<h1 i18n>i18n attribute on tags</h1>
110-
110+
111111
<div id="i18n-1"><p i18n>nested</p></div>
112-
112+
113113
<div id="i18n-2"><p i18n="different meaning|">nested</p></div>
114-
114+
115115
<div id="i18n-3"><p i18n><i>with placeholders</i></p></div>
116116
<div id="i18n-3b"><p i18n><i class="preserved-on-placeholders">with placeholders</i></p></div>
117117
<div id="i18n-3c"><div i18n><div>with <div>nested</div> placeholders</div></div></div>
118-
118+
119119
<div>
120120
<p id="i18n-4" i18n-title title="on not translatable node"></p>
121121
<p id="i18n-5" i18n i18n-title title="on translatable node"></p>
122122
<p id="i18n-6" i18n-title title></p>
123123
</div>
124-
125-
<!-- no ph below because the ICU node is the only child of the div, i.e. no text nodes -->
124+
125+
<!-- no ph below because the ICU node is the only child of the div, i.e. no text nodes -->
126126
<div i18n id="i18n-7">{count, plural, =0 {zero} =1 {one} =2 {two} other {<b>many</b>}}</div>
127-
127+
128128
<div i18n id="i18n-8">
129-
{sex, select, m {male} f {female} 0 {other}}
129+
{sex, select, male {m} female {f} other {other}}
130130
</div>
131131
<div i18n id="i18n-8b">
132-
{sexB, select, m {male} f {female}}
132+
{sexB, select, male {m} female {f}}
133133
</div>
134-
134+
135135
<div i18n id="i18n-9">{{ "count = " + count }}</div>
136136
<div i18n id="i18n-10">sex = {{ sex }}</div>
137-
<div i18n id="i18n-11">{{ "custom name" //i18n(ph="CUSTOM_NAME") }}</div>
137+
<div i18n id="i18n-11">{{ "custom name" //i18n(ph="CUSTOM_NAME") }}</div>
138138
</div>
139139
140140
<!-- i18n -->
141-
<h1 id="i18n-12" >Markers in html comments</h1>
141+
<h1 id="i18n-12" >Markers in html comments</h1>
142142
<div id="i18n-13" i18n-title title="in a translatable section"></div>
143143
<div id="i18n-14">{count, plural, =0 {zero} =1 {one} =2 {two} other {<b>many</b>}}</div>
144144
<!-- /i18n -->

packages/compiler/test/i18n/integration_xliff2_spec.ts

+25-25
Original file line numberDiff line numberDiff line change
@@ -107,38 +107,38 @@ const XLIFF2_TOMERGE = `
107107
<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>
108108
</segment>
109109
</unit>
110-
<unit id="4360321700965841752">
110+
<unit id="703464324060964421">
111111
<segment>
112112
<source>
113-
<ph id="0" equiv="ICU" disp="{sex, select, 0 {...} m {...} f {...}}"/>
113+
<ph id="0" equiv="ICU" disp="{sex, select, other {...} male {...} female {...}}"/>
114114
</source>
115-
<target><ph id="0" equiv="ICU" disp="{sex, select, 0 {...} m {...} f {...}}"/></target>
115+
<target><ph id="0" equiv="ICU" disp="{sex, select, other {...} male {...} female {...}}"/></target>
116116
</segment>
117117
</unit>
118-
<unit id="5460933846928880074">
118+
<unit id="5430374139308914421">
119119
<notes>
120120
<note category="location">file.ts:23</note>
121121
</notes>
122122
<segment>
123-
<source>{VAR_SELECT, select, 0 {other} m {male} f {female} }</source>
124-
<target>{VAR_SELECT, select, 0 {autre} m {homme} f {femme} }</target>
123+
<source>{VAR_SELECT, select, other {other} male {m} female {female} }</source>
124+
<target>{VAR_SELECT, select, other {autre} male {homme} female {femme} }</target>
125125
</segment>
126126
</unit>
127-
<unit id="1746565782635215">
127+
<unit id="1300564767229037107">
128128
<notes>
129129
<note category="location">file.ts:25,27</note>
130130
</notes>
131131
<segment>
132132
<source>
133-
<ph id="0" equiv="ICU" disp="{sexB, select, m {...} f {...}}"/>
133+
<ph id="0" equiv="ICU" disp="{sexB, select, male {...} female {...}}"/>
134134
</source>
135-
<target><ph id="0" equiv="ICU" disp="{sexB, select, m {...} f {...}}"/></target>
135+
<target><ph id="0" equiv="ICU" disp="{sexB, select, male {...} female {...}}"/></target>
136136
</segment>
137137
</unit>
138-
<unit id="5868084092545682515">
138+
<unit id="2500580913783245106">
139139
<segment>
140-
<source>{VAR_SELECT, select, m {male} f {female} }</source>
141-
<target>{VAR_SELECT, select, m {homme} f {femme} }</target>
140+
<source>{VAR_SELECT, select, male {m} female {f} }</source>
141+
<target>{VAR_SELECT, select, male {homme} female {femme} }</target>
142142
</segment>
143143
</unit>
144144
<unit id="4851788426695310455">
@@ -165,15 +165,15 @@ const XLIFF2_TOMERGE = `
165165
<target>dans une section traductible</target>
166166
</segment>
167167
</unit>
168-
<unit id="2387287228265107305">
168+
<unit id="2329001734457059408">
169169
<segment>
170170
<source>
171-
<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>
171+
<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>
172172
<pc id="1" equivStart="START_TAG_DIV" equivEnd="CLOSE_TAG_DIV" type="other" dispStart="&lt;div&gt;" dispEnd="&lt;/div&gt;"></pc>
173173
<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>
174174
</source>
175175
<target>
176-
<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>
176+
<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>
177177
<pc id="1" equivStart="START_TAG_DIV" equivEnd="CLOSE_TAG_DIV" type="other" dispStart="&lt;div&gt;" dispEnd="&lt;/div&gt;"></pc>
178178
<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>
179179
</target>
@@ -284,40 +284,40 @@ const XLIFF2_EXTRACTED = `
284284
<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>
285285
</segment>
286286
</unit>
287-
<unit id="4360321700965841752">
287+
<unit id="703464324060964421">
288288
<notes>
289289
<note category="location">file.ts:22,24</note>
290290
</notes>
291291
<segment>
292292
<source>
293-
<ph id="0" equiv="ICU" disp="{sex, select, 0 {...} m {...} f {...}}"/>
293+
<ph id="0" equiv="ICU" disp="{sex, select, male {...} female {...} other {...}}"/>
294294
</source>
295295
</segment>
296296
</unit>
297-
<unit id="5460933846928880074">
297+
<unit id="5430374139308914421">
298298
<notes>
299299
<note category="location">file.ts:23</note>
300300
</notes>
301301
<segment>
302-
<source>{VAR_SELECT, select, 0 {other} m {male} f {female} }</source>
302+
<source>{VAR_SELECT, select, male {m} female {f} other {other} }</source>
303303
</segment>
304304
</unit>
305-
<unit id="1746565782635215">
305+
<unit id="1300564767229037107">
306306
<notes>
307307
<note category="location">file.ts:25,27</note>
308308
</notes>
309309
<segment>
310310
<source>
311-
<ph id="0" equiv="ICU" disp="{sexB, select, m {...} f {...}}"/>
311+
<ph id="0" equiv="ICU" disp="{sexB, select, male {...} female {...}}"/>
312312
</source>
313313
</segment>
314314
</unit>
315-
<unit id="5868084092545682515">
315+
<unit id="2500580913783245106">
316316
<notes>
317317
<note category="location">file.ts:26</note>
318318
</notes>
319319
<segment>
320-
<source>{VAR_SELECT, select, m {male} f {female} }</source>
320+
<source>{VAR_SELECT, select, male {m} female {f} }</source>
321321
</segment>
322322
</unit>
323323
<unit id="4851788426695310455">
@@ -353,13 +353,13 @@ const XLIFF2_EXTRACTED = `
353353
<source>in a translatable section</source>
354354
</segment>
355355
</unit>
356-
<unit id="2387287228265107305">
356+
<unit id="2329001734457059408">
357357
<notes>
358358
<note category="location">file.ts:34,38</note>
359359
</notes>
360360
<segment>
361361
<source>
362-
<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>
362+
<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>
363363
<pc id="1" equivStart="START_TAG_DIV" equivEnd="CLOSE_TAG_DIV" type="other" dispStart="&lt;div&gt;" dispEnd="&lt;/div&gt;"></pc>
364364
<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>
365365
</source>

packages/compiler/test/i18n/integration_xliff_spec.ts

+21-21
Original file line numberDiff line numberDiff line change
@@ -93,25 +93,25 @@ const XLIFF_TOMERGE = `
9393
<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>
9494
<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>
9595
</trans-unit>
96-
<trans-unit id="ba9106fca6e4e33a9b703a8c1927e2d1794dd9ff" datatype="html">
96+
<trans-unit id="49feb201083cbd2c8bfc48a4ae11f105fb984876" datatype="html">
9797
<source>
98-
<x id="ICU" equiv-text="{sex, select, m {...} f {...}}"/>
98+
<x id="ICU" equiv-text="{sex, select, male {...} female {...}}"/>
9999
</source>
100100
<target><x id="ICU"/></target>
101101
</trans-unit>
102-
<trans-unit id="7b7916d063ebaafcd2e9dcdf697b5e184fcb8099" datatype="html">
103-
<source>{VAR_SELECT, select, 0 {other} m {male} f {female} }</source>
104-
<target>{VAR_SELECT, select, 0 {autre} m {homme} f {femme}}</target>
102+
<trans-unit id="f3be30eb9a18f6e336cc3ca4dd66bbc3a35c5f97" datatype="html">
103+
<source>{VAR_SELECT, select, other {other} male {m} female {f} }</source>
104+
<target>{VAR_SELECT, select, other {autre} male {homme} female {femme}}</target>
105105
</trans-unit>
106-
<trans-unit id="078b7089573c5f66a2f78dce0adaa55e6715beb1" datatype="html">
106+
<trans-unit id="cc16e9745fa0b95b2ebc2f18b47ed8e64fe5f0f9" datatype="html">
107107
<source>
108108
<x id="ICU" equiv-text="{sexB, select, m {...} f {...}}"/>
109109
</source>
110110
<target><x id="ICU"/></target>
111111
</trans-unit>
112-
<trans-unit id="a25cf2e21a299f30be1392e731163825233edc61" datatype="html">
113-
<source>{VAR_SELECT, select, m {male} f {female} }</source>
114-
<target>{VAR_SELECT, select, m {homme} f {femme} }</target>
112+
<trans-unit id="4573f2edb0329d69afc2ab8c73c71e2f8b08f807" datatype="html">
113+
<source>{VAR_SELECT, select, male {m} female {f} }</source>
114+
<target>{VAR_SELECT, select, male {homme} female {femme} }</target>
115115
</trans-unit>
116116
<trans-unit id="d9879678f727b244bc7c7e20f22b63d98cb14890" datatype="html">
117117
<source><x id="INTERPOLATION" equiv-text="{{ &quot;count = &quot; + count }}"/></source>
@@ -129,9 +129,9 @@ const XLIFF_TOMERGE = `
129129
<source>in a translatable section</source>
130130
<target>dans une section traductible</target>
131131
</trans-unit>
132-
<trans-unit id="eee74a5be8a75881a4785905bd8302a71f7d9f75" datatype="html">
132+
<trans-unit id="7f6272480ea8e7ffab548da885ab8105ee2caa93" datatype="html">
133133
<source>
134-
<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;"/>
134+
<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;"/>
135135
<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;"/>
136136
<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;"/>
137137
</source>
@@ -233,33 +233,33 @@ const XLIFF_EXTRACTED = `
233233
<context context-type="linenumber">37</context>
234234
</context-group>
235235
</trans-unit>
236-
<trans-unit id="ba9106fca6e4e33a9b703a8c1927e2d1794dd9ff" datatype="html">
236+
<trans-unit id="49feb201083cbd2c8bfc48a4ae11f105fb984876" datatype="html">
237237
<source>
238-
<x id="ICU" equiv-text="{sex, select, 0 {...} m {...} f {...}}"/>
238+
<x id="ICU" equiv-text="{sex, select, male {...} female {...} other {...}}"/>
239239
</source>
240240
<context-group purpose="location">
241241
<context context-type="sourcefile">file.ts</context>
242242
<context context-type="linenumber">22</context>
243243
</context-group>
244244
</trans-unit>
245-
<trans-unit id="7b7916d063ebaafcd2e9dcdf697b5e184fcb8099" datatype="html">
246-
<source>{VAR_SELECT, select, 0 {other} m {male} f {female} }</source>
245+
<trans-unit id="f3be30eb9a18f6e336cc3ca4dd66bbc3a35c5f97" datatype="html">
246+
<source>{VAR_SELECT, select, male {m} female {f} other {other} }</source>
247247
<context-group purpose="location">
248248
<context context-type="sourcefile">file.ts</context>
249249
<context context-type="linenumber">23</context>
250250
</context-group>
251251
</trans-unit>
252-
<trans-unit id="078b7089573c5f66a2f78dce0adaa55e6715beb1" datatype="html">
252+
<trans-unit id="cc16e9745fa0b95b2ebc2f18b47ed8e64fe5f0f9" datatype="html">
253253
<source>
254-
<x id="ICU" equiv-text="{sexB, select, m {...} f {...}}"/>
254+
<x id="ICU" equiv-text="{sexB, select, male {...} female {...}}"/>
255255
</source>
256256
<context-group purpose="location">
257257
<context context-type="sourcefile">file.ts</context>
258258
<context context-type="linenumber">25</context>
259259
</context-group>
260260
</trans-unit>
261-
<trans-unit id="a25cf2e21a299f30be1392e731163825233edc61" datatype="html">
262-
<source>{VAR_SELECT, select, m {male} f {female} }</source>
261+
<trans-unit id="4573f2edb0329d69afc2ab8c73c71e2f8b08f807" datatype="html">
262+
<source>{VAR_SELECT, select, male {m} female {f} }</source>
263263
<context-group purpose="location">
264264
<context context-type="sourcefile">file.ts</context>
265265
<context context-type="linenumber">26</context>
@@ -297,9 +297,9 @@ const XLIFF_EXTRACTED = `
297297
<context context-type="linenumber">54</context>
298298
</context-group>
299299
</trans-unit>
300-
<trans-unit id="eee74a5be8a75881a4785905bd8302a71f7d9f75" datatype="html">
300+
<trans-unit id="7f6272480ea8e7ffab548da885ab8105ee2caa93" datatype="html">
301301
<source>
302-
<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;"/>
302+
<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;"/>
303303
<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;"/>
304304
<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;"/>
305305
</source>

0 commit comments

Comments
 (0)