VSProps: Support compiling Qt translation files

This commit is contained in:
Connor McLaughlin 2020-07-28 03:08:41 +10:00
parent a4e9adad25
commit bb56b169fc
3 changed files with 29 additions and 1 deletions

View file

@ -13,6 +13,7 @@
<QtPluginsDir>$(QTDIR)plugins\</QtPluginsDir>
<QtToolOutDir>$(SolutionDir)build\$(ProjectName)-$(Platform)-$(Configuration)\</QtToolOutDir>
<QtMocOutPrefix>$(QtToolOutDir)moc_</QtMocOutPrefix>
<QtTsOutDir>$(BinaryOutputDir)translations\</QtTsOutDir>
<QtDebugSuffix>d</QtDebugSuffix>
<QtLibSuffix Condition="'$(Configuration)'=='Debug' Or '$(Configuration)'=='DebugFast'">$(QtDebugSuffix)</QtLibSuffix>
<QtPluginFolder>QtPlugins</QtPluginFolder>
@ -113,6 +114,9 @@
<AvailableItemName Include="QtMoc">
<Targets>QtMoc</Targets>
</AvailableItemName>
<AvailableItemName Include="QtTs">
<Targets>QtTs</Targets>
</AvailableItemName>
</ItemGroup>
<!--Copy the needed dlls-->
@ -157,4 +161,25 @@
Overwrite="true"
/>
</Target>
<!--Compiles all translation files-->
<ItemGroup>
<TsFiles Include="$(MSBuildProjectDirectory)\**\*.ts" />
</ItemGroup>
<Target Name="QtTs"
BeforeTargets="ClCompile"
Inputs="@(TsFiles)"
Condition="'@(QtTs)'!=''"
Outputs="@(TsFiles->'$(QtTsOutDir)%(Filename).qm')">
<Message Text="lrelease %(TsFiles.Filename)" Importance="High" />
<Error Condition="!$(QtDirValid)" Text="QTDIR not set or non-existent (pull the submodule?)" />
<MakeDir Directories="$(QtTsOutDir)" />
<Exec Command="&quot;$(QtBinDir)lrelease.exe&quot; &quot;%(TsFiles.FullPath)&quot; -qm &quot;$(QtTsOutDir)%(TsFiles.Filename).qm&quot;" />
</Target>
<ItemGroup>
<TsOutputs Include="$(QtTsOutDir)*.qm" />
</ItemGroup>
<Target Name="QtTsClean">
<Delete Files="@(TsOutputs)" />
</Target>
</Project>

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<CleanDependsOn>QtResourceClean;QtUiClean;QtMocClean;$(CleanDependsOn)</CleanDependsOn>
<CleanDependsOn>QtResourceClean;QtUiClean;QtMocClean;QtTsClean;$(CleanDependsOn)</CleanDependsOn>
<!--
<ComputeLinkInputsTargets>$(ComputeLinkInputsTargets);QtComputeMocOutput;</ComputeLinkInputsTargets>
<ComputeLibInputsTargets>$(ComputeLibInputsTargets);QtComputeMocOutput;</ComputeLibInputsTargets>

View file

@ -3,9 +3,12 @@
<ItemType Name="QtResource" DisplayName="Qt Resource File" />
<ItemType Name="QtUi" DisplayName="Qt User Interface File" />
<ItemType Name="QtMoc" DisplayName="Qt Meta Object File" />
<ItemType Name="QtTs" DisplayName="Qt Translation File" />
<ContentType Name="QtUi" DisplayName="Qt User Interface Compiler" />
<ContentType Name="QtResource" DisplayName="Qt Resource Compiler" />
<ContentType Name="QtMoc" DisplayName="Qt Meta Object Compiler" />
<ContentType Name="QtTs" DisplayName="Qt Translation Compiler" />
<FileExtension Name="*.qrc" ContentType="QtResource" />
<FileExtension Name="*.ui" ContentType="QtUi" />
<FileExtension Name="*.ts" ContentType="QtTs" />
</ProjectSchemaDefinitions>