@@ -46,6 +46,15 @@ const EXPECTED_XMB = `<?xml version="1.0" encoding="UTF-8" ?>
46
46
<msg id="8136548302122759730" desc="desc" meaning="meaning"><source>src/basic.html:1</source><source>src/comp2.ts:1</source><source>src/basic.html:1</source>translate me</msg>
47
47
<msg id="9038505069473852515"><source>src/basic.html:3,4</source><source>src/comp2.ts:3,4</source><source>src/comp2.ts:2,3</source><source>src/basic.html:3,4</source>
48
48
Welcome</msg>
49
+ <msg id="5611534349548281834" desc="with ICU"><source>src/icu.html:1,3</source><source>src/icu.html:5</source>{VAR_PLURAL, plural, =1 {book} other {books} }</msg>
50
+ <msg id="5811701742971715242" desc="with ICU and other things"><source>src/icu.html:4,6</source>
51
+ foo <ph name="ICU"><ex>{ count, plural, =1 {...} other {...}}</ex>{ count, plural, =1 {...} other {...}}</ph>
52
+ </msg>
53
+ <msg id="7254052530614200029" desc="with placeholders"><source>src/placeholders.html:1</source>Name: <ph name="START_BOLD_TEXT"><ex><b></ex><b></ph><ph name="NAME"><ex>{{
54
+ name // i18n(ph="name")
55
+ }}</ex>{{
56
+ name // i18n(ph="name")
57
+ }}</ph><ph name="CLOSE_BOLD_TEXT"><ex></b></ex></b></ph></msg>
49
58
</messagebundle>
50
59
` ;
51
60
@@ -90,6 +99,41 @@ const EXPECTED_XLIFF = `<?xml version="1.0" encoding="UTF-8" ?>
90
99
<context context-type="linenumber">3</context>
91
100
</context-group>
92
101
</trans-unit>
102
+ <trans-unit id="83937c05b1216e7f4c02a85454260e28fd72d1e3" datatype="html">
103
+ <source>{VAR_PLURAL, plural, =1 {book} other {books} }</source>
104
+ <context-group purpose="location">
105
+ <context context-type="sourcefile">src/icu.html</context>
106
+ <context context-type="linenumber">1</context>
107
+ </context-group>
108
+ <note priority="1" from="description">with ICU</note>
109
+ </trans-unit>
110
+ <trans-unit id="540c5f481129419ef21017f396b6c2d0869ca4d2" datatype="html">
111
+ <source>
112
+ foo <x id="ICU" equiv-text="{ count, plural, =1 {...} other {...}}"/>
113
+ </source>
114
+ <context-group purpose="location">
115
+ <context context-type="sourcefile">src/icu.html</context>
116
+ <context context-type="linenumber">4</context>
117
+ </context-group>
118
+ <note priority="1" from="description">with ICU and other things</note>
119
+ </trans-unit>
120
+ <trans-unit id="ca7678090fddd04441d63b1218177af65f23342d" datatype="html">
121
+ <source>{VAR_PLURAL, plural, =1 {book} other {books} }</source>
122
+ <context-group purpose="location">
123
+ <context context-type="sourcefile">src/icu.html</context>
124
+ <context context-type="linenumber">5</context>
125
+ </context-group>
126
+ </trans-unit>
127
+ <trans-unit id="9311399c1ca7c75f771d77acb129e50581c6ec1f" datatype="html">
128
+ <source>Name: <x id="START_BOLD_TEXT" ctype="x-b" equiv-text="<b>"/><x id="NAME" equiv-text="{{
129
+ name // i18n(ph="name")
130
+ }}"/><x id="CLOSE_BOLD_TEXT" ctype="x-b" equiv-text="</b>"/></source>
131
+ <context-group purpose="location">
132
+ <context context-type="sourcefile">src/placeholders.html</context>
133
+ <context context-type="linenumber">1</context>
134
+ </context-group>
135
+ <note priority="1" from="description">with placeholders</note>
136
+ </trans-unit>
93
137
</body>
94
138
</file>
95
139
</xliff>
@@ -122,6 +166,38 @@ const EXPECTED_XLIFF2 = `<?xml version="1.0" encoding="UTF-8" ?>
122
166
Welcome</source>
123
167
</segment>
124
168
</unit>
169
+ <unit id="5611534349548281834">
170
+ <notes>
171
+ <note category="description">with ICU</note>
172
+ <note category="location">src/icu.html:1,3</note>
173
+ <note category="location">src/icu.html:5</note>
174
+ </notes>
175
+ <segment>
176
+ <source>{VAR_PLURAL, plural, =1 {book} other {books} }</source>
177
+ </segment>
178
+ </unit>
179
+ <unit id="5811701742971715242">
180
+ <notes>
181
+ <note category="description">with ICU and other things</note>
182
+ <note category="location">src/icu.html:4,6</note>
183
+ </notes>
184
+ <segment>
185
+ <source>
186
+ foo <ph id="0" equiv="ICU" disp="{ count, plural, =1 {...} other {...}}"/>
187
+ </source>
188
+ </segment>
189
+ </unit>
190
+ <unit id="7254052530614200029">
191
+ <notes>
192
+ <note category="description">with placeholders</note>
193
+ <note category="location">src/placeholders.html:1</note>
194
+ </notes>
195
+ <segment>
196
+ <source>Name: <pc id="0" equivStart="START_BOLD_TEXT" equivEnd="CLOSE_BOLD_TEXT" type="fmt" dispStart="<b>" dispEnd="</b>"><ph id="1" equiv="NAME" disp="{{
197
+ name // i18n(ph="name")
198
+ }}"/></pc></source>
199
+ </segment>
200
+ </unit>
125
201
</file>
126
202
</xliff>
127
203
` ;
@@ -132,7 +208,7 @@ describe('extract_i18n command line', () => {
132
208
let write : ( fileName : string , content : string ) => void ;
133
209
let errorSpy : jasmine . Spy & ( ( s : string ) => void ) ;
134
210
135
- function writeConfig ( tsconfig : string = '{"extends": "./tsconfig-base.json"}' ) {
211
+ function writeConfig ( tsconfig = '{"extends": "./tsconfig-base.json"}' ) {
136
212
write ( 'tsconfig.json' , tsconfig ) ;
137
213
}
138
214
@@ -147,7 +223,7 @@ describe('extract_i18n command line', () => {
147
223
basePath = makeTempDir ( ) ;
148
224
write = ( fileName : string , content : string ) => {
149
225
const dir = path . dirname ( fileName ) ;
150
- if ( dir != '.' ) {
226
+ if ( dir !== '.' ) {
151
227
const newDir = path . join ( basePath , dir ) ;
152
228
if ( ! fs . existsSync ( newDir ) ) fs . mkdirSync ( newDir ) ;
153
229
}
@@ -223,14 +299,54 @@ describe('extract_i18n command line', () => {
223
299
})
224
300
export class BasicCmp3 {}` ) ;
225
301
302
+ write ( 'src/placeholders.html' , `<div i18n="with placeholders">Name: <b>{{
303
+ name // i18n(ph="name")
304
+ }}</b></div>` ) ;
305
+
306
+ write ( 'src/placeholder_cmp.ts' , `
307
+ import {Component} from '@angular/core';
308
+
309
+ @Component({
310
+ selector: 'placeholders',
311
+ templateUrl: './placeholders.html',
312
+ })
313
+ export class PlaceholderCmp { name = 'whatever'; }` ) ;
314
+
315
+ write ( 'src/icu.html' , `<div i18n="with ICU">{
316
+ count, plural, =1 {book} other {books}
317
+ }</div>
318
+ <div i18n="with ICU and other things">
319
+ foo { count, plural, =1 {book} other {books} }
320
+ </div>` ) ;
321
+
322
+ write ( 'src/icu_cmp.ts' , `
323
+ import {Component} from '@angular/core';
324
+
325
+ @Component({
326
+ selector: 'icu',
327
+ templateUrl: './icu.html',
328
+ })
329
+ export class IcuCmp { count = 3; }` ) ;
330
+
226
331
write ( 'src/module.ts' , `
227
332
import {NgModule} from '@angular/core';
333
+ import {CommonModule} from '@angular/common';
228
334
import {BasicCmp1} from './comp1';
229
335
import {BasicCmp2, BasicCmp4} from './comp2';
230
336
import {BasicCmp3} from './comp3';
337
+ import {PlaceholderCmp} from './placeholder_cmp';
338
+ import {IcuCmp} from './icu_cmp';
231
339
232
340
@NgModule({
233
- declarations: [BasicCmp1, BasicCmp2, BasicCmp3, BasicCmp4]
341
+ declarations: [
342
+ BasicCmp1,
343
+ BasicCmp2,
344
+ BasicCmp3,
345
+ BasicCmp4,
346
+ PlaceholderCmp,
347
+ IcuCmp,
348
+ ],
349
+ imports: [CommonModule],
234
350
})
235
351
export class I18nModule {}
236
352
` ) ;
0 commit comments