ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

New WINDEV 2024 feature!
Help / WINDEV Tutorial / Tutorial - Managing multiple languages
  • Adapting an application to support multiple languages
  • What is a multilingual application?
  • Practical example: integrating multiple languages into an application
  • Step 1: Choosing the languages supported by the project
  • Step 2: Choosing the languages in the analysis
  • Adding languages in the analysis
  • Shared multilingual information
  • Applying changes
  • Step 3: Adapting the different elements of the project to support multiple languages
  • Using a multilingual image
  • Translating controls
  • Translating programming text
  • Translating menus and menu options
  • Step 4: Changing the language programmatically
  • Adding a menu option
  • Programming
  • Test of a multilingual project
  • Further information: The translation tools
  • Entering the translations directly
  • Translation with WDMSG and WDTRAD
  • Other elements to translate: the framework messages

Tutorial - Managing multiple languages

Adapting an application to support multiple languages
We will cover the following topics:
  • What is a multilingual application?
  • Creating a multilingual application, step by step.
Durée de la leçon 20 mn
What is a multilingual application?
A multilingual application is an application that can be run in different languages (English, French, Spanish, German or any other language).
In other words, the same application can be used in multiple languages. Let's see how it's done.
We will use a project that can be run in English or French, according to the user's choice.
Practical example: integrating multiple languages into an application
Let's say we have developed an application with a UI in one language (e.g., English) but we need to make some changes so that is supports another language (e.g., French).
There's a specific order to these changes. The first step is to indicate that the project supports multiple languages. This step is absolutely essential in order to develop a multilingual application.
Let's take a look at the main steps to developing a multilingual WINDEV application. These steps are as follows:
  • Choosing the languages supported by the project.
  • Choosing the languages supported by the analysis.
  • Implementing the languages in the different elements of the project (windows, reports, controls, help, etc.).
  • Implementing the languages in the code.
  • Changing the application language programmatically.
To illustrate these steps, we will use the "WD Full Application" project. This project will be translated from English into French.
Opening the example project
  1. Go to the WINDEV home page (Ctrl + <).
  2. On the home page, click "Tutorial", then in "Tutorial - WINDEV Application: Manage data", double-click "Full application - Answers".
Step 1: Choosing the languages supported by the project
The first step is to define the different languages supported by the project. In this example, the application will be in English and French.
  1. Open the project description: on the "Project" tab, in the "Project" group, click "Description".
  2. Click the "Languages" tab.
  3. Click "Add". The language selection window appears.
    Selecting project languages
  4. Click "French". A checkmark is displayed on the right of the language.
  5. Validate. "French" appears in the list of project languages.
The "Languages" tab also allows you to set the language options for numbers, currencies, dates, etc., in the selected language. Let's see an example:
  1. Click "French".
  2. Select the "Date" tab.
  3. The Windows language options are used by default. Select "Use the following parameters": you now have the ability to define the date format as well as the translation used for the days and months.
  4. Keep the "Use the settings defined in the operating system language options" option.
In the language options, you can set the text direction ("Miscellaneous" tab, "Text direction" option). This allows you to create interfaces with a language written from right to left.
Now, let's simply apply changes:
  1. Validate the project description window.
  2. A message prompts you to synchronize the different project elements. Select "Yes".
All the open elements in the editor (windows, reports, etc.) are closed and the additional languages are added to these elements.
Remark: The captions that exist in the main project language are automatically copied to the added languages.
Step 2: Choosing the languages in the analysis
By default, an analysis is created in a specific language and cannot be translated.
However, some information can be written in several languages (notes in the documentation, shared information, etc.).
If your application uses Reports and Queries, the names of the data files and items can also be translated. These elements can be translated in the "Reports and Queries" tab.
Why translate the data present in the analysis?
By default, the controls created from analysis items use the caption specified in the analysis. If a caption has been specified in the shared information of the item, it will be used when creating the control. In a multilingual project, this information must be translated so that new elements are created with all the necessary languages.
When you change the language of the project linked to the analysis, this change is not automatically applied to the analysis, since analyses can be shared between multiple projects.

To discover how this works, let's first add the languages in the analysis, then enter the shared information in multiple languages.

Adding languages in the analysis

To use multiple languages in the WD Full Application analysis:
  1. Open the data model editor: click Load project analysis in the quick access buttons of the WINDEV menu.
  2. In the analysis description ("Analysis description" option in the context menu), select the "International" tab.
  3. The list of languages supported by the analysis is displayed. Since French is not supported, we need to add it:
    • Click the "Add" button.
    • Select "French".
    • Validate the language selection window.
  4. Validate the analysis description window.
    To take into account all the languages of the project linked to the current analysis, click "Synchronize with the project".

Shared multilingual information

Here is a simple example of how to enter shared information in multiple languages: let's define the text of the control bound to the "Address" item in the "Customer" data file:
  1. Select the Customer data file.
  2. Open the description of the items (select "Description of items" in the context menu of the data file).
  3. Select the "Address" item and open the parameters of the control bound to the selected item (shared information). To do so, click the link at the bottom of the screen. The shared information is displayed in a new window.
  4. In the "General" tab, in the French caption, enter "Adresse".
  5. Validate the shared information window.
  6. Validate the description window of the items.
    The shared information of the analysis can be translated:
    • when creating the analysis.
    • at any time via the editor.
    • at any time via WDMSG and WDTRAD, tools used to extract, translate and reintegrate the different elements of the project. These two tools will be presented later in this tutorial.

Applying changes

To take changes into account, you must generate the analysis: on the "Analysis" tab, in the "Analysis" group, click "Generation".
Close the analysis editor (click the "X" icon of the analysis in the open document tabs).
Step 3: Adapting the different elements of the project to support multiple languages
All project elements can be multilingual: windows, reports, help, etc. Each of these elements can contain different objects to be translated: controls, images, menus, code, etc. Depending on the object to be translated, a specific method can be used.
To use multiple languages in our application, we will modify a few elements in WIN_Menu:
  • the image of the banner used in WIN_Menu.
  • the captions of the controls in WIN_Menu.
  • the menu options.
  • the message displayed by the WLanguage code when closing the application.
First, make sure that WIN_Menu is associated with the different languages defined in the project:
  1. Open the "WIN_Menu" window in the editor (double-click its name in the "Project explorer" pane for example).
  2. Open the window description ("Description" in the context menu).
  3. Select the "Language" tab: the two languages selected in the project are displayed.
  4. Confirm changes and close the description window.

Using a multilingual image

In an application, you may need to use different images depending on the language used.
In our example, the image of the banner in WIN_Menu contains the name of the application. As this name is different in each language, we need to change the image.
This image is used in the window template, so it must be modified in the template. This modification can then be applied to all windows that use the template. For more details, see Window templates.
To change the image of the banner used in WIN_Menu according to the runtime language:
  1. Open "WIN_Menu".
  2. The image of the banner is used in the template associated with the window. Therefore, the associated window template must be opened:
    • Click the "WD FullApplication" control and open the context menu.
    • Select "Open template".
    • The window template appears, enclosed in an orange border.
  3. Open the banner description window:
    • Select the "WD FullApplication" control and open the context menu.
    • Select "Description".
  4. In the "Image" section, click .
  5. In the context menu that appears, select "Multilingual".
  6. The multilingual image management window opens. A different image can be used for each language. This feature is very useful if you use images that contain text.
  7. For our example, in the "French" area, select the "header-fr.png" file:
    • Click .
    • Select "Browse".
    • Select the desired file.
  8. Validate. The "<Multilingual value>" text appears in the "Image" section of the description window.
  9. Validate the control description window.
  10. Save the window template ( or Ctrl + S).
  11. Update the windows that use the window template by clicking the icon in the orange bar. Validate the update window.
  12. Close the window template displayed in the editor.

Translating controls

Controls can display different types of information to the user:
  • a caption,
  • a help message,
  • an image, etc.
Sometimes, this information must be translated. This data is available in the different tabs of the control description window.
For our example, we will translate the first tab of the Tab control in WIN_Menu.
  1. Double-click the Tab control to open its description window.
  2. In the "General" tab of the description window, select "List of products".
  3. In the "Static tab description" section, do the following:
    • enter the translation of the tab label: "Liste des produits".
    • define one specific image per language for the tab (as previously done).
    • define a tooltip for each language.
  4. Close the control description window.

Translating programming text

All the text displayed by the WLanguage code of your application can also be translated into multiple languages. In our example, when you click the "Exit" menu option, the "Exit application?" dialog box is displayed. We are going to translate this message.
To translate the text of the menu option:
  1. Open the code of the menu option:
    • Expand the menu in the editor.
    • Select the "Exit" option.
    • Right-click to open the context menu and select "Code".
      In this section of code, the text to be translated is "Exit application?".
  2. Position the cursor on the "Exit application?" string.
  3. Press Ctrl + T. The following window is displayed:
    This window allows you to translate the text of your application into all the languages of the project.
  4. In "French", type "Quitter l'application?" and validate.
In the code editor, the icon appears next to the string.
This icon indicates that the message is in multiple languages. You can quickly view the different translations by hovering over the icon.
These are all the actions required in the code. You can now close the code editor.

Translating menus and menu options

A menu option can be translated like any other control via its description window, or directly from the window editor. We will use the latter method in our example.
To translate the menu of the "WIN_Menu" window:
  1. On the "Display" tab, in the "Options" group, expand "Language displayed" and select the language to display in the editor (French in our case).
    The menu options are displayed in the selected language. If no translation corresponds to the selected language, the menu options are displayed in English.
  2. Expand the "Menu" option.
  3. Select "Send an email".
  4. Press the Space key: the text becomes editable.
  5. Type the caption in French: "Envoyer un email" and validate.
  6. Switch the displayed language back to English: on the "Display" tab, in the "Options" group, expand "Language displayed" and select "English".
Step 4: Changing the language programmatically
We have translated different elements of WIN_Menu. Now let's see how to change the application language.
By default, the application runs in the language defined for the project. This language can be defined in the "Languages" tab of the project description ("Description" in the "Project" tab).
In an application, there are several methods to select the language to be used. In most cases, a menu option (or "Language" button) is used. You can use Nation to change the language of the running application.
For our example, we will add a menu option to select the desired language.

Adding a menu option

To add a menu option:
  1. Open the "WIN_Menu" window in the editor if necessary (double-click its name in the "Project explorer" pane).
  2. Click the "Menu" option in the window. The menu is expanded.
  3. Select "Send an email".
  4. Right-click to open the context menu. Select "Add an option after". Enter "Languages" and validate.
  5. Select the "Languages" option you have just created.
  6. Right-click to open the context menu and select "Transform to expand a submenu".
  7. Enter the text of the first sub-option: "English".
  8. Press the "Enter" key twice and enter the text of the second option ("French").
We will write the WLanguage code to change the language.

Programming

To enter the language management code:
  1. Select "Menu .. Languages .. English" in the editor.
  2. Right-click to open the context menu. Select "Code".
  3. Write the following code:
    Nation(nationEnglish)
  4. Save your changes and close the code editor.
  5. Select "Menu .. Languages .. French" in the editor.
  6. Right-click to open the context menu. Select "Code".
  7. Write the following code:
    Nation(nationFrench)
    Nation changes the execution language of the application. The constants passed as parameters specify the language to be used.
    The language is changed immediately by Nation.
  8. Save your changes and close the code editor.
Test of a multilingual project
We have translated some elements of the application. Now, we will change the language in test mode.
To test the application:
  1. Test the project (click in the quick access buttons). The window is displayed in test mode in English.
  2. Select "Menu .. Languages .. French".
  3. The elements that we modified in our application are displayed in French:
    • the image of the window template.
    • the first tab label.
  4. End the test by selecting "Menu .. Exit". The message is displayed in French.
  5. Validate and go back to the editor.
Further information: The translation tools
We have translated some elements of the application manually.
However, several translation methods are available in WINDEV:
  • translating text directly in the editors. Messages can be translated via a translation tool (e.g., Google Translate, provided you have a license), etc.
  • a translation performed via an external tool (WDMSG and WDTRAD).

Entering the translations directly

Translations can be typed directly in the interface. For example, the caption of "New" button becomes "Nouveau" in French. Simply open the control description window and enter the corresponding translation in the desired language.
If you want to use a translation software or a translation site, WINDEV can be configured to use this software:
  1. On the "Home" tab, in the "Environment" group, expand "Options" and select "General options of WINDEV".
  2. Go to the "Translation" tab.
  3. Specify:
    • Whether the regional settings must be automatically enabled according to the language used for the input. In this case, if the language requires a specific character set, it will be automatically selected.
    • The translation software or website to be used. You can use WDDIXIO, a translation dictionary included with WDMSG (see next paragraph), a specific translation software or website, or Google Translate.
      For more details, see Using Google Translate.
    • The languages supported (e.g., "English" as the source language and "French" as the destination language).
  4. Validate.
  5. Once the translation settings are defined, you can use the button in the different description windows of the project elements: this button allows you to use the translation software.

Translation with WDMSG and WDTRAD

You can use WDMSG, a tool (not provided with WINDEV) that allows you to:
  • extract all the project messages (control captions, code message, window titles, etc.) to translate them,
  • reintegrate the translated messages.
The messages to translate are extracted:
  • in a text format that can be configured to be used by most translation tools.
  • in HFSQL format.
WDMSG also comes with WDTRAD, a computer-assisted translation tool. WDTRAD makes it easy to enter all the translations of multilingual resources in a project.
Contact PC SOFT Sales Department for more details about WDMSG and WDTRAD.

Other elements to translate: the framework messages

There are multiple messages in the WINDEV framework. For example, the days and months used by the date functions come from the WINDEV framework. To translate one or more libraries of this framework, you must use WDINT (not provided with WINDEV).
This program is used to get a WDM file. To use this file in your application:
  • use the LoadError function.
  • include the file in the "Languages" tab of the project description. Simply select the desired language and go to the "Miscellaneous" tab.
Contact PC SOFT Sales Department for more details about WDINT.
Table of contents
Minimum version required
  • Version 2024
Comments
Click [Add] to post a comment

Last update: 12/15/2023

Send a report | Local help