是否可以使用.wxl文件在WiX中本地化EULA?

时间:2010-09-02 13:38:37

标签: wix votive

我的安装程序,通过.wxl文件本地创建了WiX。在WiX中可以指定多个文化,light.exe将被多次调用,为每种语言创建一个安装程序(这在从Visual Studio构建安装程序时可用)。

除EULA外的所有工作文件。它在.wxs文件中通过

定义
<WixVariable Id='WixUILicenseRtf' Value='en.rtf' />

我不知道从.wxl本地化文件更改此值的好方法。使用

<WixVariable Id='WixUILicenseRtf' Value='!(loc.EulaFile)' />
<String Id='EulaFile'>en.rtf</String>

不工作,sice .wxl文件在链接时使用,.wxs在它们之前编译,因此编译器找不到!(loc.EulaFile)。搜索论坛我找到了两个解决方法。首先是为每种语言创建一个自定义许可证对话框 - 它似乎工作,但它是一个非常困难的方式和膨胀源代码很多。第二种方法是删除Visual Studio / Votive构建并多次调用light.exe,每次通过-d命令行键指定不同的许可证文件。

是否有任何方法可以解决此问题并使用本地化的EULA文件,因此可以在VisualStudio + Voltive中构建项目而无需复制粘贴大量对话框?本地化安装程序是一个非常常见的问题,因此可能存在一些我不知道的解决方案?

3 个答案:

答案 0 :(得分:7)

最简单的解决方案是最简单的,只需在指定WixUILicenseRtf文件时在命令行上使用.wxl变量。

light -loc setup_fr-FR.wxl -dWixUILicenseRtf=EULA_fr-FR.rtf ...

请参阅WiX Wiki上的User Interface Basics以获取更多信息。

答案 1 :(得分:6)

还有另外一种方法可以做到这一点,虽然它有点乱,但它比OP提到的两个解决方法更不凌乱。在信用到期的情况下,根据MladenPrajdić的这篇文章http://weblogs.sqlteam.com/mladenp/archive/2010/04/15/WiX-3-Tutorial-Custom-EULA-License-and-MSI-localization.aspx,这个答案几乎是100%。

以下内容基于WiX 3.5。

您创建了一个稍微修改过的LicenseAgreementDlg对话框副本,并将其包含在您的项目中。

<?xml version="1.0" encoding="UTF-8"?>
<!--
    Copyright (c) Microsoft Corporation.  All rights reserved.

    The use and distribution terms for this software are covered by the
    Common Public License 1.0 (http://opensource.org/licenses/cpl1.0.php)
    which can be found in the file CPL.TXT at the root of this distribution.
    By using this software in any fashion, you are agreeing to be bound by
    the terms of this license.

    You must not remove this notice, or any other, from this software.
-->

<!-- This is a modified version of LicenseAgreementDlg to support selection of localized versions of 
     the license file. It is very much based on this article: 
     http://sqlserverpedia.com/blog/sql-server-bloggers/wix-3-tutorial-custom-eula-license-and-msi-localization/  -->

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
        <UI>
            <Dialog Id="LicenseAgreementKludge" Width="370" Height="270" Title="!(loc.LicenseAgreementDlg_Title)">
                <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.LicenseAgreementDlgBannerBitmap)" />
                <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
                <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
                <Control Id="Description" Type="Text" X="25" Y="23" Width="340" Height="15" Transparent="yes" NoPrefix="yes" Text="!(loc.LicenseAgreementDlgDescription)" />
                <Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes" Text="!(loc.LicenseAgreementDlgTitle)" />
                <Control Id="LicenseAcceptedCheckBox" Type="CheckBox" X="20" Y="207" Width="330" Height="18" CheckBoxValue="1" Property="LicenseAcceptedKludge" Text="!(loc.LicenseAgreementDlgLicenseAcceptedCheckBox)" />
                <Control Id="Print" Type="PushButton" X="112" Y="243" Width="56" Height="17" Text="!(loc.WixUIPrint)">
                    <Publish Event="DoAction" Value="WixUIPrintEula">1</Publish>
                </Control>
                <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)" />
                <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)">
                    <Publish Event="SpawnWaitDialog" Value="WaitForCostingDlg">!(wix.WixUICostingPopupOptOut) OR CostingComplete = 1</Publish>
                    <Condition Action="disable"><![CDATA[LicenseAcceptedKludge <> "1"]]></Condition>
                    <Condition Action="enable">LicenseAcceptedKludge = "1"</Condition>
                </Control>
                <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
                    <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
                </Control>
                <Control Id="LicenseText" Type="ScrollableText" X="20" Y="60" Width="330" Height="140" Sunken="yes" TabSkip="no">
                    <Text SourceFile="$(var.ProjectDir)\!(loc.LicenseRtf)" />  <!-- this value has been modified -->
                </Control>
            </Dialog>
        </UI>
    </Fragment>
</Wix>

在您的主WiX源文件中,添加以下代码以将新对话框“修补”到对话框排序中而不是原始对话框中:

  <Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="LicenseAgreementKludge">1</Publish>
  <Publish Dialog="LicenseAgreementKludge" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish>
  <Publish Dialog="LicenseAgreementKludge" Control="Next" Event="NewDialog" Value="InstallDirDlg">LicenseAcceptedKludge = "1"</Publish>
  <Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" Value="LicenseAgreementKludge">1</Publish>

请注意,这是基于使用WixUI_InstallDir对话框集合 - 对于其他集合,例如WixUI_Mondo,您可能需要通过查看源代码来修改上述内容。

最后,在每个本地化文件中,您放置一行如下:

<String Id="LicenseRtf">en-us\MerliniaSMSGatewayLicense.en-us.rtf</String>

<String Id="LicenseRtf">da-dk\MerliniaSMSGatewayLicense.da-dk.rtf</String>

当然,您按照指示放置了本地化的许可证文件。我将许可文件(和本地化文件)放在子文件夹中,但这不是必需的。

就像我说的那样,它有点乱,但确实有用。

答案 2 :(得分:1)

本地化 EULA 非常简单。将 ScrollableText 控件添加到您的某个对话框中。在ScrollableText控件的文本元素中引用本地化String。

<Control Id="LicenseText" Type="ScrollableText" X="20" Y="60" Width="330" Height="140" Sunken="yes" TabSkip="no">
  <Text>!(loc.License)</Text>
</Control>

接下来创建一个本地化文件,比如美国英语。将文件命名为en-US.wxl。在本地化文件中创建本地化String元素,该元素使用 ScrollableText 控件的Text元素中引用的标识符,在本例中它称为许可证。将 EULA 的原始rtf字符串添加为本地化字符串的 CDATA 元素。

要获取原始数据,请使用wordpad创建rtf文件。用记事本打开该rtf文件并复制其内容。将该内容粘贴到本地化String元素的 CDATA 元素中。务必在字符串和 CDATA 标记之间 省略所有空格

示例本地化的String元素如下:

<String Id="License"><![CDATA[{\rtf1\ansi\ansicpg1252\deff0\deflang1031{\fonttbl{\f0\fnil\fcharset0 Calibri;}}
{\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\sa200\sl276\slmult1\lang7\f0\fs22 American EULA.}]]></String>

因此,包含多个 EULA 的关键是在相应的本地化文件中使用原始rtf数据。