Wix 安装部署教程(十四) -- 多语言安装包之用户许可协议
原文:Wix 安装部署教程(十四) -- 多语言安装包之用户许可协议

在上一篇中,留下了许可协议的问题,目前已经解决。感谢网友武全的指点!

问题

一般我们是用WixVariable 来设定许可协议。如下所示:

  <WixVariable Id="WixUILicenseRtf" Value="license.rtf" />

但在多语言中我们写成下面这样是不识别的。它会被直接当成文件路径,而报错,找不到文件。

   <WixVariable Id="WixUILicenseRtf" Value="!(loc.LicenseRtf)" />

string:

 <String Id="LicenseRtf">Languages\license.rtf</String>

自定义CustomLicenseDlg

这样我们需要自定义一个许可证书对话框。不过我们可以在源码的基础上稍作修改。在源码中找到LicenseAgreementDlg.wxs。

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"><Fragment><UI><Dialog Id="LicenseAgreementDlg" 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="LicenseAccepted" 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[LicenseAccepted <> "1"]]></Condition><Condition Action="enable">LicenseAccepted = "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="!(wix.WixUILicenseRtf=$(var.licenseRtf))" /></Control></Dialog></UI></Fragment>
</Wix>

View Code

我们在工程中添加一个wxs文件,命名为CustomLicenseDlg.wxs。

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"><Fragment><UI><Dialog Id="CustomLicenseDlg" 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="LicenseAccepted" 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[LicenseAccepted <> "1"]]></Condition><Condition Action="enable">LicenseAccepted = "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="TextArea" Type="ScrollableText" X="5" Y="50" Width="360"
Height="140" Sunken="yes" TabSkip="no"><Text SourceFile="!(loc.LicenseRtf)" />
</Control> </Dialog></UI></Fragment>
</Wix>

注意修改Id和 Text部分。注意到源码中的Text是这样写的:

 <Text SourceFile="!(wix.WixUILicenseRtf=$(var.licenseRtf))" />

var,wix,loc 这些前缀都表示不同的作用域。替换之后,我们就可以设置不同的LicenseRtf

zh-cn:

 <String Id="LicenseRtf">Languages\license-cn.rtf</String>

zh-tw:

   <String Id="LicenseRtf">Languages\license-tw.rtf</String>

设置UI顺序

另外,我们还需要设置UI顺序,也就是将默认的许可证书对话框换成自定义的。这些在Product元素中修改。

   <!--自定义界面--><UI Id="WixUI_InstallDir"><TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" /><TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" /><TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" /><Property Id="DefaultUIFont" Value="WixUI_Font_Normal" /><Property Id="WixUI_Mode" Value="InstallDir" /><DialogRef Id="BrowseDlg" /><DialogRef Id="CustomLicenseDlg" /><DialogRef Id="DiskCostDlg" /><DialogRef Id="ErrorDlg" /><DialogRef Id="FatalError" /><DialogRef Id="FilesInUse" /><DialogRef Id="MsiRMFilesInUse" /><DialogRef Id="PrepareDlg" /><DialogRef Id="ProgressDlg" /><DialogRef Id="ResumeDlg" /><DialogRef Id="UserExit" /><Publish Dialog="BrowseDlg" Control="OK" Event="DoAction" Value="WixUIValidatePath" Order="3">1</Publish><Publish Dialog="BrowseDlg" Control="OK" Event="SpawnDialog" Value="InvalidDirDlg" Order="4"><![CDATA[WIXUI_INSTALLDIR_VALID<>"1"]]></Publish><Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish><Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="CustomLicenseDlg">NOT Installed</Publish><Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">Installed AND PATCH</Publish><Publish Dialog="CustomLicenseDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish><Publish Dialog="CustomLicenseDlg" Control="Next" Event="NewDialog" Value="InstallDirDlg">LicenseAccepted = "1"</Publish><Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" Value="CustomLicenseDlg">1</Publish><Publish Dialog="InstallDirDlg" Control="Next" Event="SetTargetPath" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish><Publish Dialog="InstallDirDlg" Control="Next" Event="DoAction" Value="WixUIValidatePath" Order="2">NOT WIXUI_DONTVALIDATEPATH</Publish><Publish Dialog="InstallDirDlg" Control="Next" Event="SpawnDialog" Value="InvalidDirDlg" Order="3"><![CDATA[NOT WIXUI_DONTVALIDATEPATH AND WIXUI_INSTALLDIR_VALID<>"1"]]></Publish><Publish Dialog="InstallDirDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Order="4">WIXUI_DONTVALIDATEPATH OR WIXUI_INSTALLDIR_VALID="1"</Publish><Publish Dialog="InstallDirDlg" Control="ChangeFolder" Property="_BrowseProperty" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish><Publish Dialog="InstallDirDlg" Control="ChangeFolder" Event="SpawnDialog" Value="BrowseDlg" Order="2">1</Publish><Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="InstallDirDlg" Order="1">NOT Installed</Publish><Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="2">Installed AND NOT PATCH</Publish><Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="2">Installed AND PATCH</Publish><Publish Dialog="MaintenanceWelcomeDlg" Control="Next" Event="NewDialog" Value="MaintenanceTypeDlg">1</Publish><Publish Dialog="MaintenanceTypeDlg" Control="RepairButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish><Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish><Publish Dialog="MaintenanceTypeDlg" Control="Back" Event="NewDialog" Value="MaintenanceWelcomeDlg">1</Publish><Property Id="ARPNOMODIFY" Value="1" /></UI><UIRef Id="WixUI_Common" />

这样就完成了。编译后,打开安装包发现英文安装包就是英文的许可协议,中文就是中文。

之前论坛还有这样的一种方式,是将内容直接写在wxl文件中。ScrollableText 的Text对应的内容如下。(抱歉,我也不懂那些乱七八糟的字符是什么,看着像是定义格式和字体的)

<Text>{\rtf1\ansi\ansicpg1252\deff0\deftab720 {\fonttbl{\f0\froman\fprq2 Times New Roman;}} {\colortbl\red0\green0\blue0;} \deflang1033\horzdoc{\*\fchars }{\*\lchars } \pard\plain\f0\fs20 !(loc.License_Agreement)\par }</Text>

然后设置不同的License_Agreement String:

  <String Id="License_Agreement">XXX用户许可协议重要须知━请认真阅读:</String>

但是内容完全没有格式,空格和换行好像都被处理了,很难看。即使使用<br>或者/r/n 也没有作用。

小结:Setup工程的多语言主要内容已经讲完。如果要做的更精细,你可能还需要根据语言长度来调整控件的长度。另外还需要和应用程序的多语言配合。这些都还要下工夫。Bundle的多语言和Setup的做法不同。它也需要wxl文件,但是不能同时编译支持多种语言。这个后面有机会再分享。另外繁体 的codepage 设置成936  才行,950老是报错。

posted on 2018-05-18 09:21 NET未来之路 阅读(...) 评论(...) 编辑 收藏

转载于:https://www.cnblogs.com/lonelyxmas/p/9054569.html

Wix 安装部署教程(十四) -- 多语言安装包之用户许可协议相关推荐

  1. Wix 安装部署教程(十六) -- 自动生成多语言文件

    Wix 安装部署教程(十六) -- 自动生成多语言文件 原文:Wix 安装部署教程(十六) -- 自动生成多语言文件 因为持续集成需要,所有项目编译完之后生成一个多语言的安装包.之前生成mst文件都是 ...

  2. Wix 安装部署教程(十二) -- 自动更新WXS文件

    原文:Wix 安装部署教程(十二) -- 自动更新WXS文件 上一篇分享了一个QuickWIX,用来对比两个工程前后的差异,但是这样还是很繁琐,而且昨天发现有Bug,目录对比有问题.这次改变做法,完全 ...

  3. Wix 安装部署教程(十三) -- 多语言安装包

    原文:Wix 安装部署教程(十三) -- 多语言安装包 这几天摸索WIX的多语言安装包(这里是Wix的setup 工程,不是Bundle),终于走通了,感谢网友uni的指点.WIX的多语言安装包能够根 ...

  4. Python学习:安装pycharm教程(Python、pycharm安装包,永久免费使用)

    如果电脑内存小于8G的推荐使用Visual Studio Code,微软出品,软件小巧且免费,它爸爸是全宇宙最强IDE.电脑内存大于8G,可以使用Pycharm,应该是专业Python程序员使用最多的 ...

  5. Wix 安装部署(二)自定义安装界面和行为

    Wix 安装部署(二)自定义安装界面和行为 原文:Wix 安装部署(二)自定义安装界面和行为 上一篇介绍了如何联合MSBuild来自动生成打包文件和对WIX的一些初步认识,http://www.cnb ...

  6. Wix 安装部署(五) Bootstrapper 捆绑安装

    Wix 安装部署(五) Bootstrapper 捆绑安装 原文:Wix 安装部署(五) Bootstrapper 捆绑安装 Wix的xml配置确实很费劲,忍不住有点像吐槽一下,前四篇完成的功能在Wi ...

  7. Openstack的安装部署教程

    Openstack的安装部署教程 一.环境规划 二.全部节点环境配置工作 1.配置hosts 2.关闭所有防火墙和selinux 3.关闭NetworkManager服务 三.配置openstack的 ...

  8. CentOS-7 下 GitLab 安装部署教程

    CentOS-7 下 GitLab 安装部署教程 前言 主要内容 GitLab 介绍 本篇环境信息 准备工作 配置清华大学镜像仓库 安装基础依赖 安装 Postfix 开放 ssh 以及 http 服 ...

  9. kafka不使用自带zk_kafka 安装部署教程

    kafka 安装部署教程 1. 下载 官网链接 http://kafka.apache.org/downloads 浙大源 http://mirrors.tuna.tsinghua.edu.cn/ap ...

最新文章

  1. 数据结构与算法:异或运算
  2. Docker Review - 图形化工具 Portainer
  3. [From 10.1~10.5] 对象和集合初始化器(C#语法糖系列)
  4. 举例介绍活动目录的优势
  5. 如何操控输入框中的placeholder属性
  6. 交换机和路由器的区别是什么?
  7. 乘基取整法是什么_数字逻辑电路-学习指南
  8. 为什么tomcat在eclipse中启动了,访问不了
  9. python吧_python初始与安装 - Python东
  10. 职业经理人必读知识:36页SWOT全面解读,有效提升分析能力
  11. ESXi主机下的常用日志
  12. Hdu - 1210 - Eddy's 洗牌问题
  13. iOS开发手记-仿QQ音乐播放器动态歌词的实现
  14. js 正则表达式总结
  15. Node.js与Golang使用感受与小结【二】
  16. PS2019橡皮擦工具、背景橡皮擦工具、魔术橡皮擦工具
  17. 一线工程师如何看待《没了美国的EDA软件,我们就不能做芯片了》
  18. 基于VirtualBox虚拟机安装Ubuntu图文教程
  19. mysql查看表内容_在mysql中怎样显示表里的内容 ?
  20. 【 vue 】局部样式与全局样式

热门文章

  1. iBatis报java.lang.RuntimeException: Error setting property错误
  2. 201671010103 2016-2017-2 《Java程序设计》第十二周学习心得
  3. Hive存储过程实现-hpsql
  4. 安卓data./data没数据的时候
  5. Github page + octopress介绍
  6. 查拉斯图拉的“没落”
  7. MATLAB的fft2和OpeCV的cvDFT的结果应该是一样的,但为什么有时候会相差255倍呢?
  8. python xmxl 无法启动_/usr/bin/python: can't decompress data; zlib not available 的异常处理
  9. samli文件_5.3 smali文件格式
  10. html表单验证元素必填,AngularJS表单验证:向用户指示必填字段