<?xml version='1.0' encoding='utf-8'?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <?if $(env.Platform) = "x64" ?>
  <?define Win64YesNo="yes" ?>
  <?define PackagePlatforms="x64" ?>
  <?define ReleasePath="Release64" ?>
  <?elseif $(env.Platform) = "arm64" ?>
  <?define Win64YesNo="yes" ?>
  <?define ReleasePath="ReleaseARM64" ?>
  <?define PackagePlatforms="arm64" ?>
  <?else?>
  <?define Win64YesNo="no" ?>
  <?define PackagePlatforms="x86" ?>
  <?define ReleasePath="Release" ?>
  <?endif?>

  <Product
  UpgradeCode="9ECED698-D4D9-42fd-946D-51CC049D1F6F"
  Name='"TortoiseSVN $LANGUI$"'
  Id='*'
  Language='1033'
  Codepage='65001'
  Version='$MajorVersion$.$MinorVersion$.$WCREV$'
  Manufacturer='TortoiseSVN'>

    <Package Id='*' Keywords='Installer'
      Description="$LANGUI$ language pack for TortoiseSVN"
      Comments='https://tortoisesvn.net'
      Manufacturer="Stefan Kueng"
      Platform="$(var.PackagePlatforms)"
      InstallerVersion='200'
      Languages='1033'
      Compressed='yes'
      SummaryCodepage='1252' />

    <MajorUpgrade AllowDowngrades="yes" Schedule="afterInstallValidate" />

    <Media Id='1' Cabinet='langpack.cab' EmbedCab='yes' CompressionLevel="high" />
    <Property Id="WIXUI_INSTALLDIR" Secure="yes" Value="INSTALLDIR" />

    <Property Id="ALLUSERS" Secure="yes">1</Property>
    <Property Id="COUNTRYID" Value="$COUNTRYID$" />
    
    <?if $(env.Platform) = "win32" ?>
    <Condition Message="You are attempting to run the 32-bit installer on a 64-bit version of Windows. Please install the 64-bit version of the TortoiseSVN language pack instead.">NOT Msix64</Condition>
    <?endif ?>

    <Property Id="INSTALLDIR" Secure="yes">
      <RegistrySearch Id="TSVNInstallationDir" Root="HKLM" Key="Software\[Manufacturer]" Name="Directory" Type="raw" Win64="$(var.Win64YesNo)"/>
    </Property>
    <Condition Message="TortoiseSVN is not installed. Please install TortoiseSVN before installing the language pack">INSTALLDIR</Condition>

    <CustomAction Id="SetLanguage" BinaryKey="CustomActionsDLL" DllEntry="SetLanguage" />
    <Binary Id="CustomActionsDLL" SourceFile="..\bin\$(var.ReleasePath)\bin\CustomActions.dll" />

    <Directory Id='TARGETDIR' Name='SourceDir'>
      <Directory Id='ProgramFilesFolder' Name='PFiles'>
        <Directory Id='INSTALLDIR' Name='TortoiseSVN'>
          <Directory Id='LanguagesFolder' Name='Languages'>
            <Component Id='Main' Guid='9D004446-94B4-4b9d-8C95-0BD46008A2A5'>
              <?if $(env.TSVNHelpFile) = "$COUNTRYCODE$" ?>
              <File Id='HELPPROC' Name='TortoiseSVN_$COUNTRYCODE$.chm' DiskId='1' Source='..\doc\output\TortoiseSVN_$COUNTRYCODE$.chm' Vital='no'></File>
              <?endif?>
              <?if $(env.TMergeHelpFile) = "$COUNTRYCODE$" ?>
              <File Id='HELPMERG' Name='TortoiseMerge_$COUNTRYCODE$.chm' DiskId='1' Source='..\doc\output\TortoiseMerge_$COUNTRYCODE$.chm' Vital='no'></File>
              <?endif?>

              $SPELLCHECKFILES$

              <File Id='PROCDLL' Name='TortoiseProc$COUNTRYID$.dll' DiskId='1' Source='..\bin\TortoiseProc$COUNTRYID$.dll' Vital='yes'></File>
              <?if $(env.Platform) = "x64" ?>
              <File Id='PROCDLL32' Name='TortoiseProc32$COUNTRYID$.dll' DiskId='1' Source='..\bin\TortoiseProc32$COUNTRYID$.dll' Vital='yes'></File>
              <?endif?>
              <File Id='MERGDLL' Name='TortoiseMerge$COUNTRYID$.dll' DiskId='1' Source='..\bin\TortoiseMerge$COUNTRYID$.dll' Vital='yes'></File>
              <File Id='BLAMDLL' Name='TortoiseBlame$COUNTRYID$.dll' DiskId='1' Source='..\bin\TortoiseBlame$COUNTRYID$.dll' Vital='yes'></File>
              <File Id='IDIFDLL' Name='TortoiseIDiff$COUNTRYID$.dll' DiskId='1' Source='..\bin\TortoiseIDiff$COUNTRYID$.dll' Vital='yes'></File>
              <File Id='UDIFDLL' Name='TortoiseUDiff$COUNTRYID$.dll' DiskId='1' Source='..\bin\TortoiseUDiff$COUNTRYID$.dll' Vital='yes'></File>

            </Component>
            <?if $(env.TSVNMoFile) = "$COUNTRYCODE$" ?>
            <Directory Id='SVNLANG' Name='$COUNTRYCODE$' >
              <Directory Id='LCMESG' Name='LC_MESSAGES'>
                <Component Id='SVNMO' Guid='3CD420FC-32B4-4413-84EE-BAEB77E04B06'>
                  <File Id='MO' Name='Subversion.mo' DiskId='1' Source='Subversion.mo' Vital='no'></File>
                </Component>
              </Directory>
            </Directory>
            <?endif?>
          </Directory>
        </Directory>
      </Directory>

    </Directory>

    <Feature Id='Complete' Title='Binaries' Description='The complete language pack.'
      Display='expand' Level='1' ConfigurableDirectory='INSTALLDIR'>
      <Feature Id='Main' Title='Program' Description='The language pack files.' Level='1'>
        <ComponentRef Id='Main' />
        <?if $(env.TSVNMoFile) = "$COUNTRYCODE$" ?>
        <ComponentRef Id='SVNMO' />
        <?endif?>
      </Feature>
    </Feature>

    <UIRef Id="WixUI_LanguagePack" />
    <UIRef Id="WixUI_ErrorProgressText" />

    <WixVariable Id="WixUIBannerBmp" Value="Banner.jpg" />
    <WixVariable Id="WixUIDialogBmp" Value="Dialog.jpg" />

    <Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Configure TortoiseSVN to use this language" />
    <UI>
      <Publish Dialog="ExitDialog"
                  Control="Finish"
                  Event="DoAction"
                  Value="SetLanguage">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
    </UI>

    <InstallExecuteSequence>
      <!-- These 'Suppress' statements prevent the installer from getting
           registered and from being shown in the software panel. With both
           suppressed, the installer simply copies the files without any
           trace left. -->
      <PublishProduct Suppress='yes' />
      <RegisterProduct Suppress='yes' />
      <RegisterUser Suppress='yes' />
      <PublishFeatures Suppress='yes' />
    </InstallExecuteSequence>

  </Product>
</Wix>
