-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCs.PoResource.targets
865 lines (713 loc) · 35.2 KB
/
Cs.PoResource.targets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
<?xml version="1.0" encoding="utf-8"?>
<!--
Layout:
=======
bundle1\.po\ $(PoBundleRootDir)
bundle1.fr-CH.po %(PoResource.PoBundlePath)
bundle1.de-CH.po
obj\Debug\ $(PoBundleIntDir)
LastSolution.zou $(LastSolutionSavePath)
PoModules.zou $(PoModuleReferencesPath)
- module1\.po\module1.fr-CH.po %(PoResource.PoModulePath)
PotDomains.zou $(PotDomainReferencesPath)
- project1\obj\Debug\domain1.pot %(PoResource.PotDomainPath)
- project1\obj\Debug\domain2.pot
PoDomains.zou $(PoDomainReferencesPath)
- project1\Resource\domain1.fr-CH.po %(PoResource.FullPath)
- project1\Resource\domain2.fr-CH.po
MoDomains.zou $(MoDomainReferencesPath)
-project1\bin\Debug\locale\fr-CH\LC_MESSAGES\domain1.mo %(PoResource.MoDomainPath)
-project1\bin\Debug\locale\fr-CH\LC_MESSAGES\domain2.mo
module1\.po\ $(PoModuleRootDir)
module1.fr-CH.po %(PoResource.PoModulePath)
module1.de-CH.po
project1\
Source\
*.cs
Resource\
domain1.fr-CH.po %(PoResource.FullPath)
domain1.de-CH.po
domain2.fr-CH.po
domain2.de-CH.po
obj\Debug\ $(PoIntDir)
domain1.pot.src.zou %(PoResource.PotSourcePath)
domain1.pot %(PoResource.PotDomainPath)
domain2.pot
bin\Debug\ $(TargetDir)
locale\fr-CH\LC_MESSAGES\ %(PoResource.MoDomainDir)
domain1.mo %(PoResource.MoDomainPath)
domain2.mo
where:
bundle1 $(BundleId)
module1 $(ModuleName)
domain1 %(PoResource.DomainName)
fr-CH %(PoResource.Culture)
bundle1.fr-CH.po %(PoResource.PoBundleFileName)
module1.fr-CH.po %(PoResource.PoModuleFileName)
Temporary
=========
$(PoBundleIntDir)/**/*.zou
$(PoIntDir)/**/*.zou
$(PoIntDir)/**/*.pot
$(TargetDir)/**/*.mo
-->
<!--
PoResource metadata:
====================
BundleDir = .../bundle
InitPoResources:
Culture // fr-CH, fr, ..., default to en-US
DomainName // file name without culture extension
PotSourcePath // .../bundle/module/**/project/obj/Debug/%(DomainName).pot.src.zou
PotDomainPath // .../bundle/module/**/project/obj/Debug/%(DomainName).pot
PoBundleFileName // bundle.fr-CH.po
PoModuleFileName // module.fr-CH.po
MoDomainFileName // domain.mo
PoBundlePath // .../bundle/.po/bundle.fr-CH.po
PoModulePath // .../bundle/module/.po/module.fr-CH.po
MoDomainDir // .../bundle/module/**/project/bin/Debug/locale/fr-CH/LC_MESSAGES/
MoDomainPath // .../bundle/module/**/project/bin/Debug/locale/fr-CH/LC_MESSAGES/domain.mo
CopyToOutputDirectory // default to PreserveNewest
Exists
Length
IsReadOnly
-->
<!--
Pseudo-code:
============
PoModuleReferencesPath // .../bundle/.po/obj/debug/PoModules.zou -> { module\.po\module.fr-CH.po }
PoDomainReferencesPath // .../bundle/.po/obj/debug/PoDomains.zou -> { module\**\project\Resource\domain.fr-CH.po }
MoDomainReferencesPath // .../bundle/.po/obj/debug/MoDomains.zou -> { project\bin\Debug\locale\fr-CH\LC_MESSAGES\domain.mo }
foreach (project in solution)
{
PotSource = *.cs // source files
PotDomain = xgettext(PotSource) // message IDs
PoDomain = not initialized
? msginit (PotDomain)
: msgmerge(culture, PoDomain, PotDomain)
PoBundle = msgcat (culture, PoBundle, PoDomains) // concat domain changes into bundle
PoModule = msgcat (culture, PoModule, PoDomains) // import bundle changes into modules
foreach (PoDomain)
PoDomain = msgmerge(culture, -C PoBundle, nul, PotDomain) // import bundle changes into domains
PoTouch = PoBundle, PoModules, PoDomains, PotDomains
Touch(PoBundle, PoTouch) if PoTouch changed
foreach (MoDomain)
MoDomain = msgfmt(PoDomain) // compile domains
}
-->
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" InitialTargets="SetPoIntDir" TreatAsLocalProperty="PoNoLocation">
<Import Project="Cs.Boot.props" Condition="'$(ZouImported)' == ''"/>
<!--=========================================================================-->
<!-- Constants -->
<!--=========================================================================-->
<Target Name="SetPoIntDir">
<PropertyGroup>
<PoIntDir>$(ProjectDir)$(IntermediateOutputPath)</PoIntDir>
</PropertyGroup>
</Target>
<PropertyGroup>
<PoTrace Condition="'$(PoTrace)' == ''">false</PoTrace>
<PoTraceResources Condition="'$(PoTraceResources)' == ''">false</PoTraceResources>
<PoReset Condition="'$(PoReset)' == ''">false</PoReset>
<PoPurge Condition="'$(PoPurge)' == ''">false</PoPurge>
<ContinueMessage>Press [Enter] to continue...</ContinueMessage>
<Interactive Condition="'$(Interactive)' == ''">false</Interactive>
<PoNoFuzzy Condition="'$(PoNoFuzzy)' == ''">false</PoNoFuzzy>
<PoNoClean Condition="'$(PoNoClean)' == ''">false</PoNoClean>
<PoNoLocation Condition="'$(PoNoLocation)' == ''">true</PoNoLocation>
<NoPotCreationDate Condition="'$(NoPotCreationDate)' == ''">true</NoPotCreationDate>
<NoPoRevisionDate Condition="'$(NoPoRevisionDate)' == ''">true</NoPoRevisionDate>
<PoBundleRootDir>$(BundleDir).po\</PoBundleRootDir>
<PoBundleIntDir>$(PoBundleRootDir)obj\$(Configuration)\</PoBundleIntDir>
<LastSolutionSavePath>$(PoBundleIntDir)LastSolution.zou</LastSolutionSavePath>
<PotDomainReferencesPath>$(PoBundleIntDir)PotDomains.zou</PotDomainReferencesPath>
<PoModuleReferencesPath>$(PoBundleIntDir)PoModules.zou</PoModuleReferencesPath>
<PoDomainReferencesPath>$(PoBundleIntDir)PoDomains.zou</PoDomainReferencesPath>
<MoDomainReferencesPath>$(PoBundleIntDir)MoDomains.zou</MoDomainReferencesPath>
<PoModuleRootDir Condition="'$(ModuleName)' != ''">$(ModuleDir).po\</PoModuleRootDir>
<!-- gettext binaries -->
<PoBinDir Condition="$([MSBuild]::IsOsPlatform('Windows'))">$(ZouBinzOsDir)</PoBinDir>
<XGetText>$(PoBinDir)xgettext</XGetText>
<MsgInit>$(PoBinDir)msginit</MsgInit>
<MsgMerge>$(PoBinDir)msgmerge</MsgMerge>
<MsgCat>$(PoBinDir)msgcat</MsgCat>
<MsgFmt>$(PoBinDir)msgfmt</MsgFmt>
<MsgAttrib>$(PoBinDir)msgattrib</MsgAttrib>
<PoCopyright>EPSITEC SA, CH-1400 Yverdon-les-Bains, Switzerland</PoCopyright>
<PoPackageName Condition="'$(ModuleName)' == ''">'$(BundleId)'</PoPackageName>
<PoPackageName Condition="'$(ModuleName)' != ''">'$(ModuleName)'</PoPackageName>
<!-- Use default keyword to extract messages (same as NGetText.Catalog methods) -->
<PoKeywordSpec></PoKeywordSpec>
</PropertyGroup>
<Target Name="PoTraceConstants" Condition="'$(PoTrace)' == 'true'">
<Message Text="OutputPath = $(OutputPath)" Importance="high" />
<Message Text="IntermediateOutputPath = $(IntermediateOutputPath)" Importance="high" />
<Message Text="PoPurge = $(PoPurge)" Importance="high" />
<Message Text="PoReset = $(PoReset)" Importance="high" />
<Message Text="PoIntDir = $(PoIntDir)" Importance="high" />
<Message Text="TargetDir = $(TargetDir)" Importance="high" />
<Message Text="ModuleName = $(ModuleName)" Importance="high" />
<Message Text="LastSolutionSavePath = $(LastSolutionSavePath)" Importance="high" />
<Message Text="PoBundleRootDir = $(PoBundleRootDir)" Importance="high" />
<Message Text="PoBundleIntDir = $(PoBundleIntDir)" Importance="high" />
<Message Text="PotDomainReferencesPath = $(PotDomainReferencesPath)" Importance="high" />
<Message Text="PoModuleRootDir = $(PoModuleRootDir)" Importance="high" />
</Target>
<!--=========================================================================-->
<!-- Initialization -->
<!--=========================================================================-->
<ItemGroup>
<!-- Make sure that PoResource is available in VisualStudio's Build Action combo -->
<AvailableItemName Include="PoResource" />
</ItemGroup>
<ItemDefinitionGroup>
<ImportProject>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</ImportProject>
<PoResource>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Culture>en-US</Culture>
</PoResource>
</ItemDefinitionGroup>
<Target Name="InitPoResources">
<!-- Extract Culture metadata from PO project resource name (exemple: Project1.fr-CH.po) -->
<AssignCulture Files="@(PoResource)">
<Output TaskParameter="AssignedFilesWithCulture" ItemName="PoResourceWithCulture" />
<Output TaskParameter="AssignedFilesWithNoCulture" ItemName="PoResourceWithNoCulture" />
</AssignCulture>
<!-- Add Exists, Length and IsReadOnly metadata -->
<AddFileInfo Files="@(PoResourceWithCulture);@(PoResourceWithNoCulture)">
<Output TaskParameter="OutputFiles" ItemName="PoResourceWithInfo" />
</AddFileInfo>
<!-- Add metadata helpers -->
<ItemGroup>
<PoResource Remove="@(PoResourceWithInfo)" />
<PoResource Include="@(PoResourceWithInfo)" />
<PoResource>
<BundleRelativePath>$([MSBuild]::MakeRelative($(BundleDir), %(FullPath)))</BundleRelativePath>
<!-- PO resource is considered initialized if not empty. -->
<Initialized Condition="'%(Length)' > '10'">true</Initialized>
<DomainName Condition="'%(WithCulture)' == 'true'">$([System.IO.Path]::GetFileNameWithoutExtension('%(Filename)'))</DomainName>
<DomainName Condition="'%(WithCulture)' != 'true'">%(Filename)</DomainName>
</PoResource>
<PoResource>
<DomainId>$(ProjectId):%(DomainName)</DomainId>
<PotSourcePath>$(PoIntDir)%(DomainName).pot.src.zou</PotSourcePath>
<PotDomainPath>$(PoIntDir)%(DomainName).pot</PotDomainPath>
<PoBundleFileName>$(BundleId).%(Culture).po</PoBundleFileName>
<PoModuleFileName Condition="'$(ModuleName)' != ''">$(ModuleName).%(Culture).po</PoModuleFileName>
<MoDomainLinkDir>locale\%(Culture)\LC_MESSAGES\</MoDomainLinkDir>
<MoDomainFileName>%(DomainName).mo</MoDomainFileName>
</PoResource>
<PoResource>
<DomainId Condition="'$(RuntimeIdentifier)' != ''">%(DomainId):$(RuntimeIdentifier)</DomainId>
<PoBundlePath>$(PoBundleRootDir)%(PoBundleFileName)</PoBundlePath>
<PoModulePath Condition="'$(ModuleName)' != ''">$(PoModuleRootDir)%(PoModuleFileName)</PoModulePath>
<MoDomainDir>$(TargetDir)%(MoDomainLinkDir)</MoDomainDir>
</PoResource>
<PoResource>
<MoDomainPath>%(MoDomainDir)%(MoDomainFileName)</MoDomainPath>
</PoResource>
<PoResource>
<PotDomainRelativePath>$([MSBuild]::MakeRelative($(BundleDir), %(PotDomainPath)))</PotDomainRelativePath>
</PoResource>
</ItemGroup>
<LogItems Items="@(PoResource)" Title="PoResource" Condition="'$(PoTraceResources)' == 'true'"/>
</Target>
<Target Name="PoCreateBundleIntDir">
<MakeDir Directories="$(PoBundleIntDir)" />
</Target>
<!--=========================================================================-->
<!-- CREATE PO DOMAIN FOR CURRENT PROJECT -->
<!--=========================================================================-->
<!-- POT source -->
<Target Name="InitPotSources"
Returns="@(PotSource)">
<ItemGroup>
<PotSource Include="@(Compile)" Exclude="$(TMP)\*;$(PoIntDir)\*;Properties\Resources.Designer.cs;Properties\AssemblyInfo.cs" />
<PotSource>
<RelativePath>$([MSBuild]::MakeRelative($(BundleDir), %(PotSource.FullPath)))</RelativePath>
</PotSource>
</ItemGroup>
<!--<LogItems Items="@(PotSource)" Title="PotSource" AllMetadata="true"/>-->
</Target>
<Target Name="CreatePotSource"
DependsOnTargets="InitPoResources;InitPotSources"
Inputs="@(PotSource)"
Outputs="%(PoResource.PotSourcePath)">
<WriteLinesToFile File="%(PoResource.PotSourcePath)" Lines="@(PotSource->'%(RelativePath)')" Overwrite="true" />
<Message Text='Created POT source file: "%(PoResource.PotSourcePath)"' />
<Prompt Text="$ create => %(PoResource.PotSourcePath) -- $(ContinueMessage)"
Condition="'$(Interactive)' == 'True'" />
</Target>
<!-- POT domain-->
<Target Name="CreatePotDomain"
DependsOnTargets="CreatePotSource"
Inputs="%(PoResource.PotSourcePath)"
Outputs="%(PoResource.PotDomainPath)">
<!-- PotDomain = xgettext(PotSource) -->
<PropertyGroup>
<_Options>--from-code=UTF-8 --no-wrap -D"$(BundleDir)." -f"%(PoResource.PotSourcePath)" -o"%(PoResource.PotDomainPath)"</_Options>
<_Options Condition="'$(PoNoLocation)' == 'true'">$(_Options) --no-location</_Options>
<_Options Condition="'$(PoCopyright)' != ''">$(_Options) --copyright-holder="$(PoCopyright)"</_Options>
<_Options Condition="'$(PoPackageName)' != ''">$(_Options) --package-name="$(PoPackageName)"</_Options>
<_Options Condition="'$(PoKeywordSpec)' != ''">$(_Options) --keyword="$(PoKeywordSpec)"</_Options>
</PropertyGroup>
<Exec Command='"$(XGetText)" $(_Options)' />
<Error Code="$(ErrorPoNoMessageIdCode)" Text="$(ErrorPoNoMessageId)" Condition="!Exists(%(PoResource.PotDomainPath))" ContinueOnError="false" />
<!-- Replace CHARSET with UTF-8 and remove BOM -->
<FileUpdate Files="%(PoResource.PotDomainPath)" Multiline="true" IgnoreCase="true" Encoding="utf-8-without-bom"
Regex='^("Content-Type.+?charset=)(CHARSET)(.*)$' ReplacementText="$1UTF-8$3"/>
<Prompt Text="$ xgettext => %(PoResource.PotDomainPath) -- $(ContinueMessage)"
Condition="'$(Interactive)' == 'True'" />
</Target>
<!-- PO domain -->
<Target Name="InitPoDomain"
DependsOnTargets="InitPoResources;CreatePotDomain"
Inputs="%(PoResource.PotDomainPath)"
Outputs="%(FullPath)">
<!-- PoResource = msginit(PotDomain) - fuzzy marker (if not initialized) -->
<PropertyGroup>
<_Options>--no-wrap --no-translator --locale=%(PoResource.Culture)</_Options>
<_Options>$(_Options) -o"%(PoResource.FullPath)" -i"%(PoResource.PotDomainPath)"</_Options>
</PropertyGroup>
<MakeDir Directories="%(PoResource.RootDir)%(Directory)" />
<Exec Command='"$(MsgInit)" $(_Options)' />
<Prompt Text="$ msginit => %(PoResource.FullPath) -- $(ContinueMessage)" Condition="'$(Interactive)' == 'True'" />
<!-- PoResource -= header's fuzzy marker -->
<PropertyGroup>
<_Options>-o"%(PoResource.FullPath)"</_Options>
<_Options Condition="'$(PoNoFuzzy)' == 'true'">$(_Options) --clear-fuzzy</_Options>
<_Options Condition="'$(PoNoLocation)' == 'true'">$(_Options) --no-location</_Options>
</PropertyGroup>
<Exec Command='"$(MsgAttrib)" $(_Options) "%(PoResource.FullPath)"' Condition="'$(PoNoFuzzy)' == 'true'" />
<!-- Clean -->
<ItemGroup>
<_PoFile Include="%(PoResource.FullPath)">
<Bundle>$(BundleId)</Bundle>
<Module>$(ModuleName)</Module>
<DomainName>%(PoResource.DomainName)</DomainName>
<NoPotCreationDate>$(NoPotCreationDate)</NoPotCreationDate>
<NoPoRevisionDate>$(NoPoRevisionDate)</NoPoRevisionDate>
</_PoFile>
</ItemGroup>
<CleanPoFile SourceFiles="@(_PoFile)" Condition="'$(PoNoClean)' != 'true'"/>
<ItemGroup>
<_PoFile Remove="@(_PoFile)" />
</ItemGroup>
</Target>
<Target Name="UpdatePoDomain"
DependsOnTargets="InitPoResources;CreatePotDomain"
Inputs="%(PoResource.PotDomainPath)"
Outputs="%(FullPath)">
<!-- PoDomain = msmerge(culture, PoDomain, PotDomain) -->
<PropertyGroup>
<_Options>-q --no-wrap -D"$(BundleDir)." --lang=%(PoResource.Culture)</_Options>
<_Options Condition="'$(PoNoLocation)' == 'true'">$(_Options) --no-location</_Options>
<_Options Condition="Exists(%(PoResource.PoBundlePath))">$(_Options) -C"%(PoResource.PoBundlePath)"</_Options>
<_Options>$(_Options) -o"%(PoResource.FullPath)"</_Options>
</PropertyGroup>
<Exec Command='"$(MsgMerge)" $(_Options) "%(PoResource.FullPath)" "%(PoResource.PotDomainPath)"' />
<Prompt Text="$ msgmerge => %(PoResource.FullPath) -- $(ContinueMessage)" Condition="'$(Interactive)' == 'True'" />
<!-- Clean -->
<ItemGroup>
<_PoFile Include="%(PoResource.FullPath)">
<Bundle>$(BundleId)</Bundle>
<Module>$(ModuleName)</Module>
<DomainName>%(PoResource.DomainName)</DomainName>
<NoPotCreationDate>$(NoPotCreationDate)</NoPotCreationDate>
<NoPoRevisionDate>$(NoPoRevisionDate)</NoPoRevisionDate>
</_PoFile>
</ItemGroup>
<CleanPoFile SourceFiles="@(_PoFile)" Condition="'$(PoNoClean)' != 'true'"/>
<ItemGroup>
<_PoFile Remove="@(_PoFile)" />
</ItemGroup>
</Target>
<Target Name ="CreatePoDomain" DependsOnTargets="InitPoResources" Returns="%(PoResource.Identity)">
<CallTarget Targets="InitPoDomain" Condition="'%(PoResource.Initialized)' != 'true'" />
<CallTarget Targets="UpdatePoDomain" Condition="'%(PoResource.Initialized)' == 'true'" />
</Target>
<!--=========================================================================-->
<!-- CONSOLIDATE PO DATABASE -->
<!--=========================================================================-->
<Target Name="InitPotDomains"
DependsOnTargets="InitPoResources;PoCreateBundleIntDir"
Outputs="$(PotDomainReferencesPath)">
<ItemGroup>
<_PotDomain Include="%(PoResource.PotDomainPath)">
<ModuleId>$(ModuleId)</ModuleId>
<DomainId>%(PoResource.DomainId)</DomainId>
</_PotDomain>
</ItemGroup>
<SaveItems File="$(PotDomainReferencesPath)" Items="@(_PotDomain)" RelativeTo="$(BundleDir)" Metadata="ModuleId;DomainId">
<Output TaskParameter="NewItems" ItemName="PotDomain" />
</SaveItems>
<ItemGroup>
<_PotDomain Remove="@(_PotDomain)" />
</ItemGroup>
<!--<Message Text='Added "%(PoResource.PotDomainPath)" to "$(PotDomainReferencesPath)"' />-->
<!--<LogItems Items="@(PotDomain)" Title="PotDomain"/>-->
</Target>
<Target Name="InitPoDomains"
DependsOnTargets="InitPotDomains"
Outputs="$(PoDomainReferencesPath)">
<ItemGroup>
<_PoDomain1 Include="%(PoResource.FullPath)">
<Culture>%(PoResource.Culture)</Culture>
<ModuleId>$(ModuleId)</ModuleId>
<ModuleName>$(ModuleName)</ModuleName>
<DomainId>%(PoResource.DomainId)</DomainId>
<DomainName>%(PoResource.DomainName)</DomainName>
</_PoDomain1>
</ItemGroup>
<SaveItems File="$(PoDomainReferencesPath)" Items="@(_PoDomain1)" RelativeTo="$(BundleDir)" Metadata="Culture;ModuleId;ModuleName;DomainId;DomainName">
<Output TaskParameter="NewItems" ItemName="_PoDomain2" />
</SaveItems>
<ItemGroup>
<_PoDomain1 Remove="@(_PoDomain1)" />
</ItemGroup>
<!-- Update dependencies -->
<GroupJoin Outer="@(_PoDomain2)" Inner="@(PotDomain)" Keys="DomainId" Modifiers="PotPath=FullPath">
<Output TaskParameter="Result" ItemName="_PoDomain1" />
</GroupJoin>
<ItemGroup>
<_PoDomain2 Remove="@(_PoDomain2)" />
<PoDomain Include="@(_PoDomain1)" Condition="Exists(%(Identity))">
<BundlePath>$(PoBundleRootDir)$(BundleId).%(Culture).po</BundlePath>
</PoDomain>
<_PoDomain1 Remove="@(_PoDomain1)" />
</ItemGroup>
<!--<Message Text='Added "%(PoResource.FullPath)" to "$(PoDomainReferencesPath)"' />-->
<!--<LogItems Items="@(PoDomain)" Title="PoDomain"/>-->
</Target>
<!--=========================================================================-->
<!-- CREATE PO MODULE -->
<!--=========================================================================-->
<Target Name="InitPoModules"
DependsOnTargets="InitPoDomains"
Outputs="$(PoModuleReferencesPath)">
<ItemGroup>
<_PoModule1 Include="%(PoResource.PoModulePath)">
<Culture>%(PoResource.Culture)</Culture>
<ModuleId>$(ModuleId)</ModuleId>
<ModuleName>$(ModuleName)</ModuleName>
</_PoModule1>
</ItemGroup>
<SaveItems File="$(PoModuleReferencesPath)" Items="@(_PoModule1)" RelativeTo="$(BundleDir)" Metadata="Culture;ModuleId;ModuleName">
<Output TaskParameter="NewItems" ItemName="_PoModule2" />
</SaveItems>
<ItemGroup>
<_PoModule1 Remove="@(_PoModule1)" />
</ItemGroup>
<!-- Update dependencies -->
<GroupJoin Outer="@(_PoModule2)" Inner="@(PoDomain)" Keys="Culture;ModuleId" Modifiers="PoItems=FullPath">
<Output TaskParameter="Result" ItemName="_PoModule1" />
</GroupJoin>
<ItemGroup>
<_PoModule2 Remove="@(_PoModule2)" />
<PoModule Include="@(_PoModule1)">
<BundlePath>$(PoBundleRootDir)$(BundleId).%(Culture).po</BundlePath>
</PoModule>
<_PoModule1 Remove="@(_PoModule1)" />
</ItemGroup>
<!--<Message Text='Added "%(PoResource.PoModulePath)" to "$(PoModuleReferencesPath)"' />-->
<!--<LogItems Items="@(PoModule)" Title="PoModule"/>-->
</Target>
<Target Name="CreatePoModule"
DependsOnTargets="InitPoModules"
Inputs ="%(PoModule.PoItems)"
Outputs="%(PoModule.Identity)">
<MakeDir Directories="$(PoModuleRootDir)" />
<ItemGroup>
<_PoDependencies Include="%(PoModule.PoItems)" />
<_PoDependencies Include="%(PoModule.FullPath)" Condition="Exists(%(FullPath))" />
</ItemGroup>
<PropertyGroup>
<_Options>--no-wrap -D"$(BundleDir)." --lang=%(PoModule.Culture) -o"%(PoModule.FullPath)"</_Options>
<_Options Condition="'$(PoNoLocation)' == 'true'">$(_Options) --no-location</_Options>
<_PoDependencies>@(_PoDependencies->'"%(FullPath)"')</_PoDependencies>
<_PoDependencies>$(_PoDependencies.Replace(';', ' '))</_PoDependencies>
</PropertyGroup>
<Exec Command='"$(MsgCat)" $(_Options) $(_PoDependencies)' />
<Prompt Text="$ msgcat => %(PoModule.FullPath) -- $(ContinueMessage)" Condition="'$(Interactive)' == 'True'" />
<!-- Clean -->
<ItemGroup>
<_PoFile Include="%(PoModule.FullPath)">
<Bundle>$(BundleId)</Bundle>
<Module>$(ModuleName)</Module>
<NoPotCreationDate>$(NoPotCreationDate)</NoPotCreationDate>
<NoPoRevisionDate>$(NoPoRevisionDate)</NoPoRevisionDate>
</_PoFile>
</ItemGroup>
<CleanPoFile SourceFiles="@(_PoFile)" Condition="'$(PoNoClean)' != 'true'"/>
<ItemGroup>
<_PoFile Remove="@(_PoFile)" />
<_PoDependencies Remove="@(_PoDependencies)" />
</ItemGroup>
</Target>
<!--=========================================================================-->
<!-- CREATE PO BUNDLE -->
<!--=========================================================================-->
<Target Name="InitPoBundles" DependsOnTargets="InitPoDomains;InitPoModules">
<ItemGroup>
<DomainCulture Include="%(PoDomain.Culture)" />
<DomainCulture>
<Culture>%(Identity)</Culture>
</DomainCulture>
<_PoBundle1 Include="@(DomainCulture->'$(PoBundleRootDir)$(BundleId).%(Identity).po')" />
<DomainCulture Remove="@(DomainCulture)" />
<_ExistingPoModule Include="@(PoModule)" Condition="Exists(%(Identity))" />
</ItemGroup>
<!--<LogItems Items="@(_ExistingPoItem)" Title="_ExistingPoItem" />-->
<GroupJoin Outer="@(_PoBundle1)" Inner="@(_ExistingPoModule);@(PoDomain)" Keys="Culture" Modifiers="PoItems=FullPath">
<Output TaskParameter="Result" ItemName="_PoBundle2" />
</GroupJoin>
<ItemGroup>
<_PoBundle1 Remove="@(_PoBundle1)" />
</ItemGroup>
<GroupJoin Outer="@(_PoBundle2)" Inner="@(_ExistingPoDomain)" Keys="Culture" Modifiers="PoDomains=FullPath">
<Output TaskParameter="Result" ItemName="PoBundle" />
</GroupJoin>
<ItemGroup>
<_PoBundle2 Remove="@(_PoBundle2)" />
<_ExistingPoModule Remove="@(_ExistingPoModule)" />
</ItemGroup>
<!--<Message Text="%(PoBundle.Identity)" Importance="high" />-->
<!--<LogItems Items="@(PoBundle)" Title="PoBundle" />-->
</Target>
<Target Name="CreatePoBundle"
DependsOnTargets="InitPoBundles"
Inputs ="%(PoBundle.PoItems)"
Outputs="%(PoBundle.Identity)">
<ItemGroup>
<_PoDependencies Include="%(PoBundle.PoItems)" />
<_PoDependencies Include="%(PoBundle.FullPath)" Condition="Exists(%(FullPath))" />
</ItemGroup>
<PropertyGroup>
<_Options>--no-wrap -D"$(BundleDir)." --lang=%(PoBundle.Culture) -o"%(PoBundle.FullPath)"</_Options>
<_Options Condition="'$(PoNoLocation)' == 'true'">$(_Options) --no-location</_Options>
<_PoDependencies>@(_PoDependencies->'"%(FullPath)"')</_PoDependencies>
<_PoDependencies>$(_PoDependencies.Replace(';', ' '))</_PoDependencies>
</PropertyGroup>
<Exec Command='"$(MsgCat)" $(_Options) $(_PoDependencies)' />
<Prompt Text="$ msgcat => %(PoBundle.FullPath) -- $(ContinueMessage)" Condition="'$(Interactive)' == 'True'" />
<!-- Clean -->
<ItemGroup>
<_PoFile Include="%(PoBundle.FullPath)">
<Bundle>$(BundleId)</Bundle>
<NoPotCreationDate>$(NoPotCreationDate)</NoPotCreationDate>
<NoPoRevisionDate>$(NoPoRevisionDate)</NoPoRevisionDate>
</_PoFile>
</ItemGroup>
<CleanPoFile SourceFiles="@(_PoFile)" Condition="'$(PoNoClean)' != 'true'"/>
<ItemGroup>
<_PoFile Remove="@(_PoFile)" />
<_PoDependencies Remove="@(_PoDependencies)" />
</ItemGroup>
</Target>
<!--=========================================================================-->
<!-- UPDATE PO TREE -->
<!--=========================================================================-->
<Target Name="UpdatePoTree"
DependsOnTargets="CreatePoDomain;CreatePoBundle"
Inputs="%(PoDomain.BundlePath);%(PotPath)"
Outputs="%(FullPath)">
<!-- PoDomain = msmerge(culture, -C PoBundle, PoDomain.PotPath) -->
<PropertyGroup>
<_Options>-q --no-wrap -D"$(BundleDir)." --lang=%(PoDomain.Culture)</_Options>
<_Options Condition="'$(PoNoLocation)' == 'true'">$(_Options) --no-location</_Options>
<_Options>$(_Options) -C"%(PoDomain.BundlePath)"</_Options>
<_Options>$(_Options) -o"%(PoDomain.FullPath)"</_Options>
</PropertyGroup>
<Exec Command='"$(MsgMerge)" $(_Options) $(Nul) "%(PoDomain.PotPath)"' />
<Prompt Text="$ msgmerge => %(PoDomain.FullPath) -- $(ContinueMessage)" Condition="'$(Interactive)' == 'True'" />
<!-- Clean -->
<ItemGroup>
<_PoFile Include="%(PoDomain.FullPath)">
<Bundle>$(BundleId)</Bundle>
<Module>%(PoDomain.ModuleName)</Module>
<Domain>%(PoDomain.DomainName)</Domain>
<NoPotCreationDate>$(NoPotCreationDate)</NoPotCreationDate>
<NoPoRevisionDate>$(NoPoRevisionDate)</NoPoRevisionDate>
</_PoFile>
</ItemGroup>
<CleanPoFile SourceFiles="@(_PoFile)" Condition="'$(PoNoClean)' != 'true'"/>
</Target>
<!--=========================================================================-->
<!-- TOUCH PO TREE -->
<!--=========================================================================-->
<Target Name="InitPoTouches">
<ItemGroup>
<PoTouch Include="%(PoBundle.FullPath)" />
<PoTouch Include="%(PoBundle.PoItems)" />
</ItemGroup>
<!-- PoTreeModifiedTime -->
<ItemGroup>
<PoTreeModifiedTime Include="%(PoTouch.ModifiedTime)" />
</ItemGroup>
<!-- PoTreeChanged -->
<PropertyGroup>
<PoTreeChanged Condition="'@(PoTreeModifiedTime->Count())' > '1'">true</PoTreeChanged>
</PropertyGroup>
<!--<LogItems Items="@(PoTouch)" Title="PoTouch" />
<LogItems Items="@(PoTreeModifiedTime)" Title="PoTreeModifiedTime" />
<Message Importance="high" Text="[$(ProjectName)] PoTreeChanged = $(PoTreeChanged)" />-->
<ItemGroup>
<PoTreeModifiedTime Remove="@(PoTreeModifiedTime)" />
</ItemGroup>
</Target>
<Target Name="TouchPoTree" DependsOnTargets="InitPoTouches">
<Touch Files="@(PoTouch)" Condition="'$(PoTreeChanged)' == 'true'"/>
</Target>
<!--=========================================================================-->
<!-- COMPILE PO DOMAINS (CREATE MO DOMAINS) -->
<!--=========================================================================-->
<Target Name="InitMoDomains"
DependsOnTargets="InitPoDomains"
Outputs="$(MoDomainReferencesPath)">
<ItemGroup>
<_MoDomain1 Include="%(PoResource.MoDomainPath)">
<Culture>%(PoResource.Culture)</Culture>
<ModuleId>$(ModuleId)</ModuleId>
<DomainId>%(PoResource.DomainId)</DomainId>
</_MoDomain1>
</ItemGroup>
<SaveItems File="$(MoDomainReferencesPath)" Items="@(_MoDomain1)" RelativeTo="$(BundleDir)" Metadata="Culture;ModuleId;DomainId">
<Output TaskParameter="NewItems" ItemName="_MoDomain2" />
</SaveItems>
<ItemGroup>
<_MoDomain1 Remove="@(_MoDomain1)" />
</ItemGroup>
<!-- Update dependencies -->
<GroupJoin Outer="@(_MoDomain2)" Inner="@(PoDomain)" Keys="Culture;DomainId" Modifiers="PoPath=FullPath">
<Output TaskParameter="Result" ItemName="MoDomain" />
</GroupJoin>
<ItemGroup>
<_MoDomain2 Remove="@(_MoDomain2)" />
</ItemGroup>
<!--<Message Text='Added "%(PoResource.MoDomainPath)" to "$(MoDomainReferencesPath)"' />-->
<!--<LogItems Items="@(MoDomain)" Title="MoDomain"/>-->
</Target>
<Target Name="CreateMoDomain"
DependsOnTargets="InitMoDomains;UpdatePoTree"
Inputs="%(MoDomain.PoPath)"
Outputs="%(FullPath)">
<!-- MoDomain = msgfmt(PoDomain) -->
<MakeDir Directories="%(PoResource.MoDomainDir)" />
<Exec Command='"$(MsgFmt)" -o"%(MoDomain.FullPath)" "%(PoPath)"' />
</Target>
<!-- Propagate compiled POs to referencing projects -->
<Target Name="CreateMoDomainContent">
<ItemGroup>
<PoContent Include="%(PoResource.MoDomainPath)">
<Link>%(PoResource.MoDomainLinkDir)%(MoDomainFileName)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
</PoContent>
<Content Include="@(PoContent)" />
</ItemGroup>
<Message Text="Content <= %(PoContent.Identity)" />
</Target>
<!--=========================================================================-->
<!-- Lock / Unlock -->
<!--=========================================================================-->
<Target Name="PoLock">
<Lock Name="$(PoBundleRootDir)" Timeout="10000"/>
</Target>
<Target Name="PoUnlock">
<Unlock Name="$(PoBundleRootDir)" />
</Target>
<!--=========================================================================-->
<!-- Last solution path -->
<!--=========================================================================-->
<Target Name ="InitSolutionChanged" DependsOnTargets="PoCreateBundleIntDir" Condition="'$(SolutionPath)' != '*Undefined*'">
<SaveItems File="$(LastSolutionSavePath)" Items="$(SolutionPath)" RelativeTo="$(BundleDir)" Overwrite="true">
<Output TaskParameter="OldItems" PropertyName="_LastSolutionPath"/>
</SaveItems>
<PropertyGroup >
<SolutionChanged Condition="'$(_LastSolutionPath)' != '$(SolutionPath)'">true</SolutionChanged>
<_LastSolutionPath />
</PropertyGroup>
<!--<Message Importance="high" Text="[R] SolutionChanged = $(SolutionChanged)" />-->
</Target>
<Target Name="PoCleanIfSolutionChange" DependsOnTargets="InitPoResources;InitSolutionChanged">
<Delete Files="@(PoResource->'%(PotSourcePath)')" Condition="'$(SolutionChanged)' == 'true'" />
</Target>
<Target Name="PoCleanIfProjectChange"
DependsOnTargets="InitPoResources"
Inputs="$(ProjectPath)"
Outputs="@(PoResource->'%(PotSourcePath)')">
<Delete Files="@(PoResource->'%(PotSourcePath)')" />
</Target>
<!--=========================================================================-->
<!-- Clean -->
<!--=========================================================================-->
<Target Name ="PoReset" Condition="$(PoReset) == 'true'" DependsOnTargets="InitPoResources">
<ItemGroup>
<_Temporary Include="$(PoBundleRootDir)**\*" />
<_Temporary Include="$(PoModuleRootDir)**\*" />
<_Temporary Include="@(PoResource)" />
</ItemGroup>
<Delete Files="@(_Temporary)" />
<ItemGroup>
<_Temporary Remove="@(_Temporary)" />
<_Temporary Include="$(PoBundleRootDir)**;$(PoBundleRootDir)" />
<_Temporary Include="$(PoModuleRootDir)**;$(PoModuleRootDir)" />
</ItemGroup>
<RemoveDir Directories="@(_Temporary)" />
<ItemGroup>
<_Temporary Remove="@(_Temporary)" />
</ItemGroup>
</Target>
<Target Name ="PoPurge" Condition="$(PoPurge) == 'true'">
<ItemGroup>
<_Temporary Include="$(PoBundleRootDir)*.po" />
<_Temporary Include="$(PoModuleRootDir)*.po" />
</ItemGroup>
<Delete Files="@(_Temporary)" />
<ItemGroup>
<_Temporary Remove="@(_Temporary)" />
</ItemGroup>
</Target>
<Target Name="PoDelete">
<ItemGroup>
<_Temporary Include="$(SolutionDir)*.zou" />
<_Temporary Include="$(PoBundleRootDir)**/*.zou" />
<_Temporary Include="$(PoBundleRootDir)**/*.mo" />
<_Temporary Include="$(PoModuleRootDir)**/*.zou"/>
<_Temporary Include="$(PoModuleRootDir)**/*.mo"/>
<_Temporary Include="$(PoIntDir)**/*.zou" />
<_Temporary Include="$(PoIntDir)**/*.pot" />
<_Temporary Include="$(ProjectDir)**/*.mo" />
</ItemGroup>
<Delete Files="@(_Temporary)" />
<ItemGroup>
<_Temporary Remove="@(_Temporary)" />
</ItemGroup>
</Target>
<Target Name="PoClean" AfterTargets="Clean">
<CallTarget Targets="PoLock;PoTraceConstants;PoDelete;PoPurge;PoReset;PoUnlock" RunEachTargetSeparately="true" />
</Target>
<!--=========================================================================-->
<!-- Build -->
<!--=========================================================================-->
<PropertyGroup>
<PoBuildDependsOn>
PoTraceConstants;
PoCleanIfSolutionChange;
PoCleanIfProjectChange;
CreatePoDomain;
CreatePoModule;
CreatePoBundle;
UpdatePoTree;
TouchPoTree;
CreateMoDomain;
CreateMoDomainContent;
</PoBuildDependsOn>
</PropertyGroup>
<Target Name="PoBuildCore" DependsOnTargets="$(PoBuildDependsOn)" />
<Target Name="PoBuild" BeforeTargets="ResolveReferences" Condition="'@(PoResource)' != '' And '$(DesignTimeBuild)' != 'true' And '$(BuildingProject)' == 'true'" >
<CallTarget Targets="PoLock;PoBuildCore;PoUnlock" RunEachTargetSeparately="true" />
</Target>
</Project>