-
Notifications
You must be signed in to change notification settings - Fork 243
/
TestFx.Loc.targets
88 lines (78 loc) · 5.78 KB
/
TestFx.Loc.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
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Languages supported. -->
<ItemGroup>
<ResxLang Include="cs;de;es;fr;it;ja;ko;pl;pt-BR;ru;tr;zh-Hans;zh-Hant" />
</ItemGroup>
<!-- Default Localization folder. -->
<PropertyGroup>
<ResourceDirectory>$(ProjectDir)Resources</ResourceDirectory>
<SharedResourceDirectory>$(ProjectDir)..\PlatformServices.Shared\netstandard1.3\Resources</SharedResourceDirectory>
</PropertyGroup>
<Target Name="GatherResxResources">
<ItemGroup>
<ResxResources Include="@(EmbeddedResource)" Condition="%(Extension) == '.resx'" />
</ItemGroup>
<PropertyGroup>
<HasResxResources Condition="@(ResxResources) != ''">true</HasResxResources>
</PropertyGroup>
</Target>
<!-- Localization for Libraries.
'UseSharedResources' flag is true for desktop and netcore as their resources are common and present at a shared location -->
<Target Name="TestFxLocalization" Condition="$(IsVsixProj) =='' and $(IsVsixProj) !='true'" BeforeTargets="BeforeBuild" DependsOnTargets="GatherResxResources">
<CallTarget Targets="CreateLocalizeXLF;CreateLocalizeResx" Condition="'$(HasResxResources)' == 'true' and '$(UseSharedResources)' == ''"/>
<CallTarget Targets="CreateLocalizeXLFShared;CreateLocalizeResxShared" Condition="'$(HasResxResources)' == 'true' and '$(UseSharedResources)' == 'true'"/>
</Target>
<!-- Generate xlf files from Resources.resx by using command Build.cmd -uxlf -->
<Target Name="CreateLocalizeXLF" Condition="'$(UpdateXlf)' == 'true'">
<CreateItem Include="@(ResxResources)" AdditionalMetadata="Language=%(ResxLang.Identity)">
<Output ItemName="LocResourceFile" TaskParameter="Include"/>
</CreateItem>
<Exec Command="$(TestFxPackagesRoot)fmdev.xlftool.0.1.3\tools\xlftool.exe update -Resx %(LocResourceFile.Identity) -Xlf $(ResourceDirectory)\xlf\%(LocResourceFile.Filename).%(LocResourceFile.Language).xlf" />
<Exec Command="$(TestFxPackagesRoot)fmdev.xlftool.0.1.3\tools\xlftool.exe update -Resx %(ResxResources.Identity) -Xlf $(ResourceDirectory)\xlf\%(ResxResources.Filename).xlf" />
</Target>
<!-- Generate xlf files from Resources.resx for shared resources by using command Build.cmd -uxlf -->
<Target Name="CreateLocalizeXLFShared" Condition="'$(UpdateXlf)' == 'true'">
<CreateItem Include="@(ResxResources)" AdditionalMetadata="Language=%(ResxLang.Identity)">
<Output ItemName="LocResourceFile" TaskParameter="Include"/>
</CreateItem>
<Exec Command="$(TestFxPackagesRoot)fmdev.xlftool\0.1.3\tools\xlftool.exe update -Resx %(LocResourceFile.Identity) -Xlf $(SharedResourceDirectory)\xlf\%(LocResourceFile.Filename).%(LocResourceFile.Language).xlf" />
<Exec Command="$(TestFxPackagesRoot)fmdev.xlftool\0.1.3\tools\xlftool.exe update -Resx %(ResxResources.Identity) -Xlf $(SharedResourceDirectory)\xlf\%(ResxResources.Filename).xlf" />
</Target>
<!-- Generate language specific resx files from the xlf files -->
<Target Name="CreateLocalizeResx" Condition="'$(IsLocalizedBuild)' == 'true'">
<CreateItem Include="@(ResxResources)" AdditionalMetadata="Language=%(ResxLang.Identity)">
<Output ItemName="LocResourceFile" TaskParameter="Include"/>
</CreateItem>
<Exec Command="$(TestFxPackagesRoot)fmdev.xlftool\0.1.3\tools\xlftool.exe writeTarget -Xlf $(ResourceDirectory)\xlf\%(LocResourceFile.Filename).%(LocResourceFile.Language).xlf -Resx $(ResourceDirectory)\%(LocResourceFile.Filename).%(LocResourceFile.Language).resx -verbose" />
<ItemGroup>
<EmbeddedResource Include="$(ResourceDirectory)\%(LocResourceFile.Filename).%(LocResourceFile.Language).resx" />
</ItemGroup>
</Target>
<!-- Generate language specific resx files from the xlf files for shared resources -->
<Target Name="CreateLocalizeResxShared" Condition="'$(IsLocalizedBuild)' == 'true'">
<CreateItem Include="@(ResxResources)" AdditionalMetadata="Language=%(ResxLang.Identity)">
<Output ItemName="LocResourceFile" TaskParameter="Include"/>
</CreateItem>
<Exec Command="$(TestFxPackagesRoot)fmdev.xlftool\0.1.3\tools\xlftool.exe writeTarget -Xlf $(SharedResourceDirectory)\xlf\%(LocResourceFile.Filename).%(LocResourceFile.Language).xlf -Resx $(ResourceDirectory)\%(LocResourceFile.Filename).%(LocResourceFile.Language).resx -verbose" />
<ItemGroup>
<EmbeddedResource Include="$(ResourceDirectory)\%(LocResourceFile.Filename).%(LocResourceFile.Language).resx" />
</ItemGroup>
</Target>
<!-- Localization for documentation files. -->
<Target Name="CopyLocalizedXmls" BeforeTargets="BeforeBuild" Condition="$(LocDocumentationSubPath) != ''">
<PropertyGroup>
<_SourcePath>$(TestFxPackagesRoot)MSTest.Internal.TestFx.Localized.Documentation\1.0.0-build-20170420-1\contentFiles\any\any\$(LocDocumentationSubPath)</_SourcePath>
</PropertyGroup>
<ItemGroup>
<_LocalizedFiles Include="$(_SourcePath)\**\*.*" />
</ItemGroup>
<Warning Text="Localized documentation doesn't exist: $(LocDocumentationSubPath), $(_SourcePath)" Condition="!Exists('$(_SourcePath)')" />
<Copy SourceFiles="@(_LocalizedFiles)" DestinationFiles="@(_LocalizedFiles->'$(OutDir)\%(RecursiveDir)%(Filename)%(Extension)')" Condition="Exists('$(_SourcePath)')" />
</Target>
<Target Name ="CopyStaticResourcesToOutput">
<!-- Until we have a process of converting to/from loc friendly file formats like resx files, the already localized vsixlangpacks are checked in and packaged in the vsix.-->
<!-- If we have new vsix projects before we have a process setup, they would not contain localized descriptive infromation until the above process is setup.-->
<Exec Command="xcopy /Y /I /S /E $(ProjectDir)Resources $(OutDir)localize" Condition="Exists('$(ProjectDir)Resources')" />
</Target>
</Project>