【问题标题】:Is it possible to localize EULA in WiX using .wxl file?是否可以使用 .wxl 文件在 WiX 中本地化 EULA?
【发布时间】:2010-09-02 13:38:37
【问题描述】:

我使用 WiX 创建的安装程序是通过 .wxl 文件本地化的。在 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 中构建项目,而无需复制粘贴大量对话框?本地化安装程序是一个非常常见的问题,所以也许存在一些我不知道的解决方案?

【问题讨论】:

    标签: wix votive


    【解决方案1】:

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

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

    有关更多信息,请参阅 WiX Wiki 上的 User Interface Basics

    【讨论】:

    • 非常感谢!就像你所说;最好的解决方案是最简单的!你拯救了我的一天!
    【解决方案2】:

    还有另一种方法可以做到这一点,虽然它有点混乱,但它没有 OP 提到的两种解决方法那么混乱。并且信用到期,这个答案几乎 100% 基于 Mladen Prajdić 的这篇帖子http://weblogs.sqlteam.com/mladenp/archive/2010/04/15/WiX-3-Tutorial-Custom-EULA-License-and-MSI-localization.aspx

    以下基于 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>
    

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

    就像我说的,它有点乱,但确实有效。

    【讨论】:

    • 无法在 WiX 3.7 中运行。自 WiX 3.0 以来,是否已从 Text 元素中删除本地化支持?
    • 用户 @kadorken 在建议的编辑中指出以下内容:“确保将补丁发布指令放在 UIRef ID="WixUI_InstallDir" 指令之后,以使它们生效。”
    【解决方案3】:

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

    <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。在本地化文件中创建一个本地化字符串元素,该元素使用 ScrollableText 控件的文本元素中引用的标识符,在本例中称为许可证。将 EULA 的原始 rtf 字符串添加为本地化字符串的 CDATA 元素。

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

    以下是本地化字符串元素示例:

    <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 数据。

    【讨论】:

      【解决方案4】:

      转到解决方案的配置管理器,在安装程序项目行上为您要使用的每个本地化创建一个新配置,例如:

      现在,在安装程序项目属性页面/构建中,对于每个创建的配置,在“要构建的文化”上设置单一文化,并在“定义变量”框上设置不同的值:

      例如,对于 es-ES:

      WixUILicenseRtf=.\Assets\license-es-ES.rtf

      对于美国:

      WixUILicenseRtf=.\Assets\license-en-US.rtf

      ...等

      构建您的安装程序:

      对于每种文化:

      • 转到配置管理器,
      • 选择安装程序的配置文化,接受
      • 构建

      优点:

      • 无需处理自定义操作、自定义对话框或控制台命令
      • 只需要配置一次。让它运行是一项机械任务

      缺点:

      • 每次构建都需要一些额外的点击
      • 超过三种文化的混乱

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2010-10-05
        • 2011-02-04
        • 1970-01-01
        • 1970-01-01
        • 2016-01-09
        • 1970-01-01
        • 2015-09-11
        • 2016-01-26
        相关资源
        最近更新 更多