PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
New WINDEV 26 feature!
  • In this lesson you will learn the following concepts
  • What is a multilingual application?
  • Choosing the project languages
  • Localizing the analysis
  • Localizing the project elements
  • Localizing an image
  • Localizing controls
  • Localizing a programming message
  • Localizing menus
  • The translation tools
  • Direct input of translations
  • Translation with WDMSG and WDTRAD
  • Other elements to translate: the framework messages
  • Programming the change of language
  • Adding a menu option
  • Programming
  • Project test
Lesson 4.15. Managing multiple languages
In this lesson you will learn the following concepts
  • What is a multilingual application?
  • Creating a multilingual application, step by step.
Lesson duration

Estimated time: 20 mn
Previous LessonTable of contentsNext Lesson
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).
Therefore, the same application can be used in several languages. But how is it possible? That's what we will see in this lesson.
We are going to handle a project that can be run in English or in French, according to the user's choice.
The main steps of a multilingual application are:
  • Choosing the project languages.
  • Localizing the analysis.
  • Localizing the project elements (windows, reports, controls, help system, etc.).
  • Localizing the messages found in the code.
  • Programming the change of language in the application.
These different steps will be applied to the "WD Full Application" project. This project, available in English, will be translated in French.

  • Open the project you worked on in the previous lesson.
    1. Go to the WINDEV home page (Ctrl + <).
    2. On the home page, click "Tutorial", then in "Part 4 - Full application with data", double-click "Full application (Exercise)".
    3. A dialogue box prompts you to open the project you worked on in the previous lesson. You can open the local copy or the original project. Select "Open the local copy".

Answers

A corrected project is available. This project allows you to perform the different operations in this lesson (if you have not followed the previous lessons). To open the corrected project, go to the home page and click "Tutorial", then in "Part 4 - Full application with data", double-click "Full application (Answers)".
Choosing the project languages
  • The first operation consists in choosing the project languages.
    1. Open the project description: on the "Project" pane, in the "Project" group, click "Description".
    2. Click the "Languages" tab. Our application will support English and French.
    3. Click the "Add" button. The window for selecting languages is displayed.
      Selecting project languages
    4. Click "French". A checkmark is displayed on the right of language.
    5. Validate. The "French" language appears in the list of project languages.
  • The "Languages" tab also allows you to set the language options related to numbers, currencies or dates for the selected language. Let's see an example:
    1. Click the "French" language.
    2. Select the "Date" tab.
    3. The linguistic options of Windows 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 option "Use the settings defined in the linguistic options of the operating system".

Note

In the linguistic options, you have the ability to choose the text direction for the language ("Various" tab, "Text direction" option). This allows you to create interfaces with a language written from right to left.
  • Validate. A message proposes to synchronize the different project elements. Answer "Yes". All project elements opened in the editor (windows, reports, etc.) are closed and the additional languages are added to these elements.
    Remark: The captions that exist in the base project language are automatically copied to the added languages.
Localizing the analysis
By default, an analysis is created in a specific language and cannot be translated.
However, some information can be entered 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. This translation can be done in the "Reports and Queries" tab (this tab is both in the data file and the item description window).
By default, the controls created from the analysis items have the item caption specified in the analysis. If a caption was specified in the shared information of item, this caption will be used when creating the control.
When changing the language of project linked to the analysis, this change is not automatically applied to the analysis. Indeed, an analysis can be shared between several projects.
  • To support several languages in an analysis:
    1. Display the data model editor: click Opening the data model editor in the quick access buttons of the WINDEV menu.
    2. In the analysis description ("Analysis description" from the popup menu), select the "International" tab.
    3. The list of languages supported by the analysis is displayed. The French language not being supported:
      • Click the "Add" button.
      • Select "French".
      • Validate the window for adding languages.
    4. Validate the analysis description window.

      Note

      To take into account all languages of the project linked to the current analysis, you also have the ability to click the "Synchronize with the project" button.
  • To type shared information in several languages, let's take a simple case: entering the caption of the control linked to the "Address" item of "Customer" data file:
    1. Select the Customer data file.
    2. Open the description of items of a data file ("Description of items" in the data file popup menu).
    3. Select the "Address" item and display the parameters of control linked 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 "Caption", enter the text in French: "Adresse".
    5. Validate the shared information window.
    6. Validate the description window of the items.

      Note

      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.
  • To take into account the modifications performed in the analysis, you must generate the analysis: on the "Analysis" pane, in the "Analysis" group, click "Generation".
  • Close the analysis editor (click the "X" icon of the analysis in the open document tabs).
Localizing the project elements
All project elements can be multilingual: windows, reports, help, etc.
We are going to modify some elements of WIN_Menu window to present the different methods that can be used.
We are going to modify:
  • the image of the bar used in the WIN_Menu window.
  • the captions of controls found in the WIN_Menu window.
  • the menu options.
  • the message displayed by the WLanguage code when closing the application.
  • Open the "WIN_Menu" window in the editor (double-click its name in the "Project explorer" pane for example).
  • First of all, check whether the WIN_Menu window is associated with the different languages defined in the project:
    1. Open the window description ("Description" from the popup menu).
    2. Select the "Language" tab: the two languages selected in the project are displayed.
    3. Validate the window.

Localizing an image

  • To change the image of the bar used in the WIN_Menu window according to the runtime language:
    1. Open the "WIN_Menu.WDW" window.
    2. The bar image is found in the template associated with the window. Therefore, the associated window template must be opened:
      • Click the "WD FullApplication" control and display the popup menu.
      • Select "Open template".
      • The window template appears, enclosed in an orange border.
    3. Open the bar description window:
      • Select the "WD FullApplication" control and display the popup menu.
      • Select "Description".
    4. In the "Image" section, click .
    5. Select "Multilingual" in the context menu that appears.
    6. The window for managing multilingual images is displayed. 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>" caption 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.

Localizing controls

A control can display various information to the user:
  • a caption,
  • a help message,
  • an image, ...
This information must be translated. This information can be accessed in the various tabs of the control description window.
  • For our example, we are going to translate the first pane of Tab control.
    1. Double-click the Tab control to display its description window.
    2. In the "General" tab of the description window, select "List of products".
    3. In the "Static pane 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.

Localizing a programming message

All messages found in your program can be translated into several languages. In our example, selecting the "Exit" menu displays the message "Exit from the application". We are going to translate this message.

  • To translate the message of menu option:
    1. Display the code of menu option:
      • Expand the menu in the editor.
      • Select the "Exit" option.
      • Right-click to open the context menu and select "Code".
    2. To translate this type of message, position the cursor in the "Exit from application?" string and press Ctrl + T. You can also go to the "Code" pane, "Languages" group, expand "Translate strings" and select "Translate messages".
    3. The following window is displayed:
    4. This window allows you to translate all messages of your program into all project languages.
    5. In the "French" area, type "Quitter l'application?" and validate.
    6. The icon appears in the code editor.
      This icon indicates that the message is in multiple languages. You can quickly view the different translations by hovering over the icon.
    7. Close the code editor.

Localizing menus

The menu options can be translated like the other controls via the description window of the option, or from the window editor directly.
  • To translate the menu of "WIN_Menu" window:
    1. On the "Display" pane, in the "Options" group, expand "Language displayed" and select the language to display in the editor (French in our case).
    2. The menu options are displayed in the selected language. If no translation corresponds to the selected language, the menu options are displayed in English.
    3. Expand the "Menu" option.
    4. Select "Send an email".
    5. Press the Space key: the text can be edited.
    6. Type the caption in French: "Envoyer un email" and validate.
    7. Switch the displayed language back to English: on the "Display" pane, in the "Options" group, expand "Language displayed" and select "English".
The translation tools
Some application elements have been translated manually.
Several methods can be used to translate this information:
  • translating the messages directly in the editors. This translation can be performed via a translation tool, Google Translate (providing that you own a license), ...
  • a translation performed via an external tool (WDMSG and WDTRAD).

Direct input of translations

The translations are typed in the product interface directly. 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" pane, 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, this character set will be automatically selected.
    • The software or the site that will be used for translation. You have the ability to use WDDixio, translation dictionary supplied with WDMSG (see next paragraph), a specific translation software or site, or Google Translate.
      For more details, see Translation with Google Translate.
    • The languages supported (e.g., "English" as the source language and "Spanish" 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 software defined for translation.

Translation with WDMSG and WDTRAD

A tool named WDMSG (not supplied with WINDEV) can be used 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 is used to easily type all translations for the multilingual information of 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 names of 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 supplied with WINDEV).
This program is used to get a WDM file. To use this file in your application:
  • you have the ability to use LoadError.
  • you can include the file in the project description in the "Languages" tab. Simply select the desired language and select the "Various" tab.
Contact PC SOFT Sales Department for more details about WDINT.
Programming the change of language
By default, the project is run in the runtime language defined for the project, in the "Languages" tab of the project description ("Description" in the "Project" pane).
In an application, the language can be chosen via a menu option. You can change the language of the application being run using Nation in the event associated with the menu option.

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 of window. The menu is expanded.
    3. Select "Send an email".
    4. Right-click to open the context menu. Select "Add after". Type the caption ("Languages") and validate.
    5. Select the "Languages" option you have just created.
    6. Open the context menu (right click) and select "Transform to expand a submenu".
    7. Enter the label of the first sub-option: "English".
    8. Press the "Enter" key twice and enter the label of the second option ("French").
We are now going to enter the WLanguage code required to change the language.

Programming

To enter the language management code:
  1. Select "Menu .. Languages .. French" in the editor.
  2. Right-click to open the context menu. Select "Code".
  3. Write the following code:
    Nation(nationFrench)
  4. Save your changes and close the code editor.
  5. Select "Menu .. Languages .. English" in the editor.
  6. Right-click to open the context menu. Select "Code".
  7. Write the following code:
    Nation(nationEnglish)
    Nation is used to change the execution language of the application. The constants passed as parameters allow you to specify the language to be used.
    The change of language performed by Nation is immediately effective.
  8. Save your changes and close the code editor.

Project test

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.
Previous LessonTable of contentsNext Lesson
Minimum version required
  • Version 26
Comments
Click [Add] to post a comment