本文介绍了wix internall 字符串无法本地化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Wix I18n Dev.wixtoolset的版本是V3.7.安装程序 UI 是由 UIExtension 创建的.在安装过程中,有一些 UI 字符串无法本地化.如复制新文件"等.我搜索了这些字符串,并在 wix 源代码中放置了 (wix37-sourcessrcextUIExtensionwixlibWixUI_en-us.wxl),并且 wix 已经本地化了这些字符串.令我困惑的是,wix 已将这些字符串本地化,但在安装过程中仍显示为英文.即使我替换了 .wxl 文件中的字符串,它仍然显示为英文字符串.

Wix I18n Dev.The version of wixtoolset is V3.7.And the Installer UI is created by UIExtension.In the installation process, there are some UI strings cannot be localized. Such as "Copying new files" and so on. I searched these strings and there are laid in the wix source code(wix37-sourcessrcextUIExtensionwixlibWixUI_en-us.wxl), and wix has localized these strings.It's confusing to me that wix has localized these strings, but it still displayed as English in the installation process. Even I replaced there strings in .wxl file ,it still displayed as English strings.

我尝试了 BdN3504 的示例.wxs 文件与 BdN3504 相同.wxl 文件是

I tried the example of BdN3504.the wxs file is the same as BdN3504.the wxl file is

您可以看到状态仍然保持英语.

and you can see the status is still keep English.

我的构建环境是VS2010 &wix3.7.不知道有什么问题......

My build environment is VS2010 & wix3.7. I don't know what's wrong with it....

推荐答案

我已经回答了这个问题 这里.

I already answered this question here.

阅读或查看 Nick Ramirez 的书 .

Either read that or check out the paragraph called Progress Bar Messages in Nick Ramirez' book WiX 3.6: A Developer's Guide to Windows.

packtpublishing 的好心人在这里免费提供他书中包含该段落的章节:

The good people of packtpublishing are offering the chapter of his book containing that paragraph for free here:

第 12 章:本地化安装程序.请参见第 329 页.

Chapter 12: Localizing Your Installer. See page 329.

另一页是 MSDN 文章:标准操作参考 书中也提到了这一点.

Another page of interest is this MSDN article: Standard Actions Reference which is also noted in the book.

编辑:由于评论的原因,我将发布一个工作的最小示例和屏幕截图,所以你会看到它有效:

Edit: Because of the comments I will post a working minimal example and a screenshot, so you see that it works:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="*" Name="LocalizingErrors" Language="1034" Version="1.0.0.0" Manufacturer="SomeOne" UpgradeCode="7ddbcad4-98d9-4c2d-9ae6-6fdc47314947">
        <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

        <MediaTemplate EmbedCab="no" />

        <Feature Id="ProductFeature" Title="LocalizingErrors" Level="1">
            <ComponentGroupRef Id="ProductComponents" />
        </Feature>

    <!-- Custom Progress messages

    Custom progress messages are defined by a table in the MSI called ActionText. However, by default
    this table isn't included. Without it, the messages are the stock English versions.

    To add the ActionText table with strings for progress messages, add a ProgressText element inside
    a UI element for each standard action found in the Execute sequence. For example, to add a
    localized message for the InstallFiles action, add the following markup to one of your wxs files:
    -->
    <UI>
      <ProgressText Action="InstallFiles" Template="!(loc.InstallFilesTemplate)">!(loc.InstallFiles)</ProgressText>
      <ProgressText Action="CreateShortcuts" Template="!(loc.CreateShortcutsTemplate)">!(loc.CreateShortcuts)</ProgressText>
      <ProgressText Action="WriteRegistryValues" Template="!(loc.WriteRegistryValuesTemplate)">!(loc.WriteRegistryValues)</ProgressText>
      <ProgressText Action="RegisterUser" Template="!(loc.RegisterUserTemplate)">!(loc.WriteRegistryValues)</ProgressText>
      <ProgressText Action="RegisterProduct" Template="!(loc.RegisterProductTemplate)">!(loc.RegisterProduct)</ProgressText>
      <ProgressText Action="PublishFeatures" Template="!(loc.PublishFeaturesTemplate)">!(loc.PublishFeatures)</ProgressText>
      <ProgressText Action="PublishProduct" Template="!(loc.PublishProductTemplate)">!(loc.PublishFeatures)</ProgressText>
      <ProgressText Action="InstallFinalize" Template="!(loc.InstallFinalizeTemplate)">!(loc.InstallFinalize)</ProgressText>
    </UI>
    <UIRef Id="WixUI_Minimal"/>
    </Product>

    <Fragment>
        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder">
                <Directory Id="INSTALLFOLDER" Name="LocalizingErrors" />
            </Directory>
        </Directory>
    </Fragment>

    <Fragment>
        <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
            <Component Id="ProductComponent" Guid="92A175A0-D15D-48EC-B2E1-FD5848FB6430">
        <File Id="somefile" Source="..File.exe" KeyPath="yes" />
            </Component>
        </ComponentGroup>
    </Fragment>
</Wix>

伴随这个例子,你必须有一个你的文化的本地化文件.您必须在 Build->Cultures to build 下的项目属性中设置文化.就我而言,我将其命名为 es-es.wxl,文件内容如下:

Accompanying this example, you have to have a localisation file for your Culture. You have to set the Culture in the project properties under Build->Cultures to build. In my case I named it es-es.wxl and the file contents follow:

<?xml version="1.0" encoding="utf-8"?>
<WixLocalization Culture="es-es" xmlns="http://schemas.microsoft.com/wix/2006/localization" Codepage="1252" Language="1034">
  <String Id="Error_1311">Archivo no encontrado: [2]. Compruebe que el archivo existe y que puedes acceder a él.</String>
  <String Id="InstallFiles">Installazione del archivos</String>
  <String Id="InstallFilesTemplate">Archivo: [1], Tamaño de archivo: [6], Directorio: [9]</String>
  <String Id="CreateShortcuts">Creacion de los atajos</String>
  <String Id="CreateShortcutsTemplate">Atajo [1] creado</String>
  <String Id="WriteRegistryValues">Escribir en registro</String>
  <String Id="WriteRegistryValuesTemplate">Camino: [1], Nombre: [2], valor: [3]</String>
  <String Id="RegisterUser">Registrar a los usuarios</String>
  <String Id="RegisterUserTemplate">Usario: [1]</String>
  <String Id="RegisterProduct">Registrar producto</String>
  <String Id="RegisterProductTemplate">Producto: [1]</String>
  <String Id="PublishFeatures">Publicar las características</String>
  <String Id="PublishFeaturesTemplate">Caraterística: [1]</String>
  <String Id="PublishProduct">Publicar el producto</String>
  <String Id="PublishProductTemplate">Producto: [1]</String>
  <String Id="InstallFinalize">Finalizar la instalación</String>
  <String Id="InstallFinalizeTemplate">Finalizar [ProductName]</String>
</WixLocalization>

最后一个屏幕截图向您展示它的工作原理:

Lastly a Screenshot to show you that it works:

另一个编辑:要本地化错误字符串,您只需定义带有相应错误编号的 Error 元素:

Another edit: To localize error strings, you simply have to define Error elements with the corresponding error numbers:

<UI>
    <Error Id="1322">Una parte de la ruta de la carpeta no es válido. Se está vacío o supera la longitud permitida por el sistema.</Error>
    <Error Id="1311">!(loc.Error_1311)</Error>
</UI>

第一个错误字符串是硬编码的,所以这不是一个好的解决方案.最好使用本地化文件,因为它在第二个 Error 元素中完成.

The first error string is hard-coded, so that's not such a good solution. It's better to use localization files, as it is done in the second Error element.

这篇关于wix internall 字符串无法本地化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 14:36
查看更多