Localizing applications

Localization involves creation and use of different resources, such as text, textures, and styles, for locales that you want to support in your application. Kanzi uses localized resources indirectly using resource IDs that hold a separate value for each locale. To keep track of localized resources and locales Kanzi uses localization tables. You can see all localized resources and locales used by your application in the localization tables in the Library > Localization.

To localize your Kanzi application:

  1. Add the resources from your project which you want to localize to a localization table. See Adding resources to a localization table.
  2. Localize resources. See Localizing text resources and Localizing other resources.
  3. Edit localized resources. See Editing localized resources.

You can also localize themes. See Localizing themes.

Learn how to localize your Kanzi applications by completing a tutorial. See Tutorial: Localize your application.

Adding resources to a localization table

If you have a complete Kanzi application you want to localize, or if you added content to a Kanzi application that you already localized, you have to create the resource IDs for the items you want to localize and add them to a localization table. After you create the resource IDs for the resources you want to localize and add them to a localization table you can start localizing your Kanzi application. See Localizing text resources and Localizing other resources.

To create resource IDs and add them to a localization table:

  1. In the Project right-click the Screen node and in the context menu select Add Resources to a Localization Table.
    When you use the Add Resources to a Localization Table command on the Screen node, Kanzi Studio enables you to add all resources in your project to a localization table and localize them. To add to a localization table resources only for a selected node and its tree, right-click that node and select Add Resources to a Localization Table.
  2. In the Add Resources to a Localization Table window set:
    1. Localization Table to the localization table to which you want to add the resources. If you do not have a localization table yet, select <Create New>.
      A localization table contains the information about which locale uses which resources.
    2. Select the resource type you want to show in the Add Resources to a Localization Table window.
      For example, to show only text and image resources select and .
    3. In the table that lists all resources of the type you selected, click the checkbox next to the resource you want to add to the localization table you selected. To change the resource ID, double-click the resource ID and enter a new name.
      Kanzi Studio creates a single resource ID for Text Block nodes which use the same value for the Text property. These nodes share the same entry in a localization table.
    4. Click Add.
    5. Kanzi Studio creates resources and resource IDs from all resource types you selected and adds them to the localization table you selected. You can find the localization tables in the Library > Localization. You can now localize resources and in the localization table set which resource you want to use for which locale.

  3. You can start localizing your Kanzi application. See Localizing text resources, Localizing other resources, and Editing localized resources.

Localizing text resources

Kanzi uses gettext's .po file format for handling localized text resources. See The Format of PO Files. To use a different format for importing and exporting localized text resources, you can use the Kanzi Localization Plugin API to create a Kanzi Studio plugin that supports the format based on your specifications. You can find an example of such plugin in the <KanziWorkspace>/Examples/CsvPlugin directory. See Csv plugin example.

To localize text resources:

  1. Create text content in your Kanzi Studio project using Text Block nodes and add text resources to a localization table. See Adding resources to a localization table.
  2. In Library > Localization right-click the localization table that contains the resources you want to localize, and select Export Localization Table. Kanzi Studio exports to <ProjectName>/Localization/<LocalizationTableName> the localization table template to a .pot file, and as many .po files as you have locales in that localization table.
  3. This step depends on whether you are translating your Kanzi application for the first time or whether you are doing an incremental translation:
  4. After you receive the .po files from the translators, save them to <ProjectName>/Localization/<LocalizationTableName>.
  5. In Kanzi Studio in the Library > Localization right-click the localization table the content of which your translators localized, and select Import Localization Table. Kanzi Studio imports all .po files in the <ProjectName>/Localization/<LocalizationTableName> directory to the selected localization table.

Localizing other resources

Besides translating the text content into multiple languages, Kanzi enables you to use different resources for each locale, including animations, brushes, composers, fonts, materials, meshes, textures, and styles. You can use this procedure to localize resources of all types.

To localize other resources:

  1. Create or import content to your Kanzi Studio project and add the resources used by this content to a localization table. See Adding resources to a localization table.
    For example, if you have five locales and want to use a different set of textures for each locale, import to your Kanzi Studio project the images for the textures for each locale. See Importing.
  2. In the Library > Localization double-click the localization table that contains the resources you want to localize.
    Kanzi Studio opens the localization table in the Localization Editor.
  3. In the Localization Editor find the resource you want to localize, double-click the resource cell in the locale into which you want to localize, and enter the text or select the resource ID for the resource you want to use for that locale.
  4. Repeat the previous step until you select resources for all resources and locales.

Localizing themes

Kanzi enables you to localize themed applications.

To localize themes:

  1. For each theme the content of which you want to localize, create a prefab from the content that includes the text nodes you want to localize. See Creating and using a prefab.
  2. Localize the text resources:
    1. In the Prefabs select the prefabs you created in the previous step and add their resources to a localization table. See Adding resources to a localization table.
    2. In the Library > Localization double-click the localization table you created in the previous step to open it in the Localization Editor, add the locales to which you want to localize themes, and localize the text resources. See Localizing text resources.
      To add a locale click + Create Locale, enter the name for the locale, and click OK.
  3. Use Prefab View nodes to show the localized content:
    1. In the Prefabs under the node where you want to show the localized content create a Prefab View node and in the Properties add and set the Prefab Template property to one of the prefabs you created in step 1.
      You must use a Prefab View node so that you can dynamically change the prefab that the Prefab View instantiates. See Prefab Placeholder and Prefab View nodes.
    2. In the Prefabs right-click the Prefab View node you created in the previous step and select Add Resources to a Theme Group.
    3. In the Add Resources to a Theme Group window:
      • Set the Theme Group to the theme group to which you want to add the resources.
        A theme group contains the information about which theme uses which resources.
      • Rename the Resource ID to something that is meaningful in the context of your project.
      Click Add.
      Kanzi Studio adds to the theme group the resource ID which points to the prefab shown in the Value column. In the Prefab View node from which you add the resources to a Theme Group, Kanzi Studio sets the value of the Prefab Template property to the resource ID.
    4. (Optional) In the Prefabs copy the Prefab View node you created in step 1 to the places where you want to show the same content.

    5. In the Library > Themes double-click the theme group to which you added the resources, and in the Theme Editor for the resource ID you created in step 3 select the correct prefab for each theme.
  4. In the Dictionaries window to view the resource dictionaries of localization tables and theme groups in the project, click Locales and Themes, and select different locales and themes to see the localized themes in the Preview.

Editing localized resources

In the Localization Editor you can set and edit the resources that locales use.

To edit the localized resources:

  1. In the Library > Localization double-click the localization table that contains the resources you want to edit.
    Kanzi Studio opens the localization table in the Localization Editor.
  2. In the Localization Editor:

Using a kzb file URL for a resource in a locale

After you add resources used in your project to a localization table, you can use a kzb URL to point to the resources in another Kanzi Studio project.

To use a kzb file URL for a resource in a locale:

  1. In the Library > Localization double-click the localization table that contains the resources for which you want to use a kzb file URL.
    Kanzi Studio opens the localization table in the Localization Editor.
  2. In the Localization Editor double-click the cell for the resource and in the dropdown menu select < URL >.
  3. In the cell enter the kzb file URL of the resource you want to use.
    For example, to use a font from another Kanzi Studio project, enter the kzb file URL pointing to that font.

Creating locale packs

A locale pack is a kzb file that contains only the resources for a specific locale. Using Kanzi Engine API you can load the application resources used by a certain locale when you set that locale. That way you reduce the size of kzb files in your application.

When you want to export a resource that is used by a locale pack to the main project kzb file, in the Library select the resource and in the Properties add and enable the Is Used By Code property. All resources that have Is Used By Code property enabled are exported only to the main project kzb file and not to any locale packs that use them.

To create a locale pack:

  1. In the Library > Localization add to the localization tables the resources used by the locale you want to add to your Kanzi application in a locale pack.
  2. In the Library > Localization double-click any localization table and in the Localization Editor click next to the locale name the resources of which you want to export to a locale pack.
  3. In Kanzi Studio select File > Export > Export KZB. This command:

  4. Use the Kanzi Engine API to load the locale pack in your Kanzi application. See Tutorial: Localize your application.

Showing resource use

In the Localization Editor you can see in the currently selected context in the Project whether resources are used and where they are used.

To show resource use:

  1. In the Library > Localization double-click the localization table where you want to inspect the use of resources.
    Kanzi Studio opens the localization table in the Localization Editor.
  2. Use the Localization Editor:

Creating localization tables

Kanzi uses localized resources indirectly using resource IDs that hold a separate value for each locale. To keep track of localized resources and locales Kanzi uses localization tables. You can see all localized resources and locales used by your application in the localization tables in the Library > Localization.

You can create several localization tables to:

To create a localization table, in the Library press Alt and right-click Localization, select Localization Table, and name the localization table.

Using localization in multiple Kanzi Studio projects combined into a Kanzi application

To use localization when you combine multiple Kanzi Studio projects into a Kanzi application, you must make the localization tables accessible to the Screen node of the main project of your application in one of these ways:

See also

Using locales

Tutorial: Localize your application

Localization

Using prefabs

Combining Kanzi Studio projects into a Kanzi application