是否可以将变量传递给WIX本地化文件?

Ele*_*ena 14 variables user-interface localization wix wix3.5

我需要在WIX本地化文件WIXUI_en-us.wxl中使用变量.我试过这样用:

<String Id="Message_SomeVersionAlreadyInstalled" Overridable="yes">A another version of product $(var.InstallationVersionForGUI) is already installed</String>
Run Code Online (Sandbox Code Playgroud)

但它不起作用.当我宣布财产并以这种方式使用它时:

<String Id="Message_SomeVersionAlreadyInstalled" Overridable="yes">A another version of product [InstallationVersionForGUI] is already installed</String>

也不起作用.

我哪里错了?

感谢您的帮助和时间.

Bob*_*son 17

本地化字符串在链接时处理,因此您不能使用$(var)预处理器变量.只要使用本地化字符串的位置支持运行时格式化(例如,使用"格式化"字段类型),就支持使用[property]引用.


sas*_*ont 14

你的第二种方法应该可以正常工作.这与默认.wxl文件使用的方法相同.

例如,在您的.wxl文件中,您将声明您的字符串:

<String Id="Message_Foo">Foo blah blah [Property1]</String>
Run Code Online (Sandbox Code Playgroud)

在您的.wxs文件中,您声明属性.如果您愿意,可以声明属性以匹配WiX变量(听起来您正在尝试这样做)

<Property Id="Property1">$(var.Property1)</Property>
Run Code Online (Sandbox Code Playgroud)

  • @cel在邮件列表上的具体答案有点模糊,如果你在构建时知道属性你可以只结合wix变量和本地化...例如`<Product Id ="*"UpgradeCode ="$(var.Property_UpgradeCode )"Name ="!(loc.ApplicationName)$(var.versionmajor)"Language ="!(loc.Property_ProductLanguage)"Version ="$(var.version)"Manufacturer ="!(loc.ManufacturerName)">` (2认同)