wix internall strings cannot be localize

2019-02-15 15:26发布

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. enter image description here

enter image description here


I tried the example of BdN3504. the wxs file is the same as BdN3504. the wxl file is enter image description here

and you can see the status is still keep English. enter image description here

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

1条回答
女痞
2楼-- · 2019-02-15 15:48

I already answered this question here.

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.

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

Chapter 12: Localizing Your Installer. See page 329.

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>

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: Image of a localized wix installation with localized progress bar strings.

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>

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.

查看更多
登录 后发表回答