是否可以使用 .wxl 文件在 WiX 中本地化 EULA? [英] Is it possible to localize EULA in WiX using .wxl file?

查看:19
本文介绍了是否可以使用 .wxl 文件在 WiX 中本地化 EULA?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

My installer, created wth WiX is localized via .wxl files. It is possible in WiX to specify multiple cultures and light.exe will be called multiple times, creating an installer for each language (this is available while building installer from Visual Studio).

除 EULA 之外的所有作品文件.它通过

All works file except for EULA. It is defined in .wxs file via

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

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

And i don't know a good way to change this value from .wxl localization file. Using

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

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

Is not working, sice .wxl files are used at link-time and .wxs is compiled before them, so compiler can't find !(loc.EulaFile). Searching forums i have found two workarounds. First is to create a custom license dialog for each language - it seems to work, but it's a very hard way and bloat source code a lot. Second way is to drop Visual Studio / Votive build and to call light.exe multiple times, specifying different license file each time via -d command-line key.

有什么方法可以解决这个问题并使用本地化的 EULA 文件,以便可以在 VisualStudio + Voltive 中构建项目而无需复制粘贴大量对话框?本地化安装程序是一个非常普遍的问题,所以也许存在一些我不知道的解决方案?

Is it any way to solve this problem and use localized EULA files so project can be built in VisualStudio + Voltive without a need to copy-paste lots of dialogs? Localizing installers is a very common problem, so maybe some solution exist that i don't know about?

推荐答案

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

There is another way to do this, and although it is a bit messy it is less messy than the two workarounds the OP has mentioned. And credit where credit is due, this answer is almost 100% based on this post http://weblogs.sqlteam.com/mladenp/archive/2010/04/15/WiX-3-Tutorial-Custom-EULA-License-and-MSI-localization.aspx by Mladen Prajdić.

以下内容基于 WiX 3.5.

The following is based on WiX 3.5.

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

You create a slightly modified copy of the LicenseAgreementDlg dialog and include it in your project.

<?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 源文件中,您添加以下代码以将您的新对话框修补"到对话框序列中,而不是原始对话框:

In your main WiX source file you add the following code to "patch" your new dialog into the dialog sequencing instead of the original one:

  <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,您可能需要通过查看源代码来修改上述内容.

Note that this is based on using the WixUI_InstallDir dialog collection - for other collections, such as WixUI_Mondo, you will probably have to modify the above by looking at the source.

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

Finally, in each of your localization files you place one line like this:

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

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

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

And, of course, you place the localized license file as indicated. I'm placing the license files (and localization files) in subfolders, but this is not necessary.

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

Like I said, it's a bit messy, but it does work.

这篇关于是否可以使用 .wxl 文件在 WiX 中本地化 EULA?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆