4D v16

XLIFF and translation

Home

 
4D v16
XLIFF and translation

XLIFF and translation    


 

 

In addition to the manipulations explained in the video, you should also note that:

To be taken into account by 4D, your XLIFF files must be placed here:

  • Windows: in MyDatabase\Resources\Lang.lproj\MyEnLoc.xlf
  • Mac OS: in MyPackage:Resources:Lang.lproj:MyEnLoc.xlf (if the .4dbase extension is active)
  • Mac OS: in MyDatabase:Resources:Lang.lproj:MyEnLoc.xlf (if you have removed the .4dbase extension)

By default, 4D looks for the language to use in this order:

  1. the system language
  2. the 4D application language
  3. English
  4. If all of these fail, the first language found in the Resources folder is loaded.

We're going to learn how to implement XLIFF translation files that you use to localize the entire interface.

It's simple: you just replace the texts found in the interface by a reference to an external file containing the desired texts.

This will be in the form ":xliff: and an object name" for example "bOK" which is the reference of the OK button. We see here that the text has changed from "Finish" to "OK".
Why is that?

Because in the resources subfolder of the database folder, there is a folder for each language.
Currently, the system is in English and within this folder we have:

  • an XML file that contains
  • in addition to the standard declarations, in the body
  • a certain number of groups (groups are not mandatory but are useful for structuring the XLIFF file)
  • and in each group, translation units.

It turns out that we have a resource called bOK where the text contained in the Target is "OK".

If we change this to "Finish" and we save the file and go back to 4D, the text "Finish" is replaced.

We can test this here:

  • End
  • Save
  • Go back to 4D and we can see "End"

For all the text of the interface, we need to replace:

  • the English text
  • by the text in the desired language.

Currently, we are in the en.xlf file so all the "target" text names are in English.

Let's create an entry for the text called "Add".

The file was saved. Here, if we replace the text with ":xliff:bAdd", we retrieve the text "Add".

That's for the English version.

Now we're going to retrieve this entry, close the file and open this file in the French folder.

We add the unit in question "Ajouter" and save.

Now imagine we want to work on a French system.

  • In the system preferences, whether on Mac or Windows
  • we can set a priority language
  • Here we see a notice that the changes will take effect the next time the application is launched.

So we're going to quit our test database and start it again.

And can see that the text "Add" has been replaced by the French version (Ajouter).

If we want, we can:

  • Change and indicate "un enregistrement"
  • We can then save
  • Note that the update is not automatic in the displayed form because the resources are loaded when the form is loaded.
  • However, if we exit and go back to the structure, the form is updated with the new text.

Now we just need to create the other entries, "Tout selectionner Tous les enregistrements" for example, and here we indicate that the button is a reference (":xliff:bAll") and that we do in fact have the text "Tout selectionner Tous les enregistrements".

Now we're going to go back to the English system so we need to quit 4D.

When we restart, we find the text from earlier; however, in the English file, we did not indicate the translation of the "bAll" entry, so in this case, the XLIFF reference is shown.

So we need to:

  • go back and retrieve the XLIFF file concerned
  • add the "bAll" entry and indicate "All"
  • When we go back to 4D, the update is performed.

An important complementary element in implementing XLIFF files concerns the character strings in methods.

Let's go back to the Test_Variables form that we created and where we assign values to the pop-up menu that has 3 texts here.
We can:

  • replace those 3 texts using the Get localized string command
  • and indicate a resname that matches, in the XLIFF file in question, a label in the chosen language.

Here we see the "Text1Test" text that is:

  • "Hello" in English and
  • "Bonjour" in French.

We're going to:

  • declare the array
  • trace the assigning of values (the array is actually empty)
  • and when we read the matching strings, the array is filled with the contents of the XLIFF file data.

 
 

 
PROPERTIES 

Product: 4D
Theme: XLIFF and translation

 
HISTORY 

 
ARTICLE USAGE

Self-training ( 4D v16)