2010-09-02 227 views
6

我的安裝程序,創建WiX通過.wxl文件本地化。在WiX中可以指定多種文化,light.exe將被多次調用,爲每種語言創建一個安裝程序(這可以在從Visual Studio構建安裝程序時使用)。是否可以使用.wxl文件在WiX中本地化EULA?

除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中構建而無需複製粘貼大量對話框?本地化安裝程序是一個非常普遍的問題,所以也許存在一些我不知道的解決方案?

回答

5

還有另外一種方法可以做到這一點,儘管它有點混亂,但它比OP提到的兩個解決方法更不麻煩。信貸到期的信用,這個答案几乎100%根據這個職位http://weblogs.sqlteam.com/mladenp/archive/2010/04/15/WiX-3-Tutorial-Custom-EULA-License-and-MSI-localization.aspx MladenPrajdić。

以下是基於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> 

在你的主維克斯源文件添加以下代碼,以「打補丁」的新對話框,在對話框中排序代替了原來的一個:

<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> 

,當然,您將本地化的許可證文件所示。我將許可證文件(和本地化文件)放在子文件夾中,但這不是必需的。

就像我說的,這有點亂,但它確實有效。

+0

無法在WiX 3.7中正常工作。自從WiX 3.0以來,本地化支持已從Text元素中移除? – ivan 2013-10-08 12:10:49

+0

@ivan使用WiX 3.7對我來說工作正常。 – RenniePet 2013-10-08 13:41:26

+0

用戶@kadorken在建議的編輯中指出:「確保在你的UIRef ID =」WixUI_InstallDir「指令之後放置修補程序發佈指令以使它們有效。」 – RenniePet 2015-02-12 08:32:40

7

最好的解決方案是最簡單的,只需在命令行中使用WixUILicenseRtf變量來指定.wxl文件。

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

請參考WiX Wiki的User Interface Basics以獲取更多信息。

+0

非常感謝!像你說的;最好的解決方案是最簡單的!你救了我的一天! – Sander 2016-12-21 11:25:11

1

本地化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。在本地化文件中創建一個本地化字符串元素,該元素使用文本元素中引用的標識符控制,在這種情況下稱爲許可證。將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數據。

相關問題