diff options
-rw-r--r-- | build.proj | 1 | ||||
-rw-r--r-- | tools/Translation.targets | 39 |
2 files changed, 40 insertions, 0 deletions
@@ -12,6 +12,7 @@ <Import Project="$(ProjectRoot)tools\$(ProductName).Versioning.targets"/> <Import Project="$(ProjectRoot)tools\Documentation.targets"/> <Import Project="$(ProjectRoot)tools\Publish.targets"/> + <Import Project="$(ProjectRoot)tools\Translation.targets"/> <UsingTask AssemblyFile="$(ProjectRoot)lib\MSBuild.Community.Tasks.dll" TaskName="Zip"/> <UsingTask AssemblyFile="$(ProjectRoot)lib\MSBuild.Community.Tasks.dll" TaskName="ILMerge"/> diff --git a/tools/Translation.targets b/tools/Translation.targets new file mode 100644 index 0000000..21b27be --- /dev/null +++ b/tools/Translation.targets @@ -0,0 +1,39 @@ +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <ExportedTxtResourcesIntermediateDir>$(IntermediatePath)ExportedTxtResources</ExportedTxtResourcesIntermediateDir> + <ExportedTxtResourcesIntermediateDir Condition=" '$(Culture)' != '' ">$(ExportedTxtResourcesIntermediateDir).$(Culture)</ExportedTxtResourcesIntermediateDir> + <ExportedTxtResourcesIntermediateDir>$(ExportedTxtResourcesIntermediateDir)\</ExportedTxtResourcesIntermediateDir> + + <ExportedTxtResourcesZip>$(IntermediatePath)$(ProductName) resources</ExportedTxtResourcesZip> + <ExportedTxtResourcesZip Condition=" '$(Culture)' != '' ">$(ExportedTxtResourcesZip).$(Culture)</ExportedTxtResourcesZip> + <ExportedTxtResourcesZip>$(ExportedTxtResourcesZip).zip</ExportedTxtResourcesZip> + </PropertyGroup> + <Target Name="ExportResX"> + <ItemGroup Condition=" '$(Culture)' != '' " > + <ResXFilesToExport Include="$(ProjectRoot)src\$(ProductName)\**\*.$(Culture).resx" /> + </ItemGroup> + <PropertyGroup> + <ResXNewCulture Condition=" '@(ResXFilesToExport)' == '' ">.$(Culture)</ResXNewCulture> + </PropertyGroup> + <ItemGroup Condition=" '$(Culture)' == '' or '$(ResXNewCulture)' != '' "> + <ResXFilesToExport Include="$(ProjectRoot)src\$(ProductName)\**\*.resx" /> + <ResXFilesToExport Remove="$(ProjectRoot)src\$(ProductName)\**\*.*.resx" /> + </ItemGroup> + <ItemGroup> + <ResXFilesToExport> + <ExportedFullPath>$(ExportedTxtResourcesIntermediateDir)%(RecursiveDir)%(FileName)$(ResXNewCulture).txt</ExportedFullPath> + <ExportedDirectory>$(ExportedTxtResourcesIntermediateDir)%(RecursiveDir)</ExportedDirectory> + </ResXFilesToExport> + <ExportedTxtDirectories Include="@(ResXFilesToExport->'%(ExportedDirectory)')" /> + <ExportedTxtFiles Include="@(ResXFilesToExport->'%(ExportedFullPath)')" /> + </ItemGroup> + <Warning Condition=" '$(ResXNewCulture)' != '' " Text="No culture '$(Culture)' exists in the source project. Synthesizing new one from default culture." /> + <MakeDir Directories="%(ResXFilesToExport.ExportedDirectory)" Condition="!Exists('%(ResXFilesToExport.ExportedDirectory)')" /> + <Exec Command="resgen.exe %(ResXFilesToExport.Identity) %(ResXFilesToExport.ExportedFullPath)" /> + <Purge Directories="@(ExportedTxtDirectories)" IntendedFiles="@(ExportedTxtFiles)" /> + <Delete Files="$(ExportedTxtResourcesZip)" /> + <Zip ZipFileName="$(ExportedTxtResourcesZip)" + WorkingDirectory="$(ExportedTxtResourcesIntermediateDir)" + Files="@(ExportedTxtFiles)" /> + </Target> +</Project>
\ No newline at end of file |