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

问题描述

Wix I18n Dev.wixtoolset的版本为V3.7.并由UIExtension创建安装程序UI.在安装过程中,有些UI字符串无法本地化.如复制新文件"等.我搜索了这些字符串,并将其放置在wix源代码中(wix37-sources \ src \ ext \ UIExtension \ wixlib \ WixUI_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-sources\src\ext\UIExtension\wixlib\WixUI_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)的书 WiX 3.6:Windows开发人员指南.

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内部字符串无法本地化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 14:36