4D v16

インターフェースの国際化 (XLIFF)

ホーム

 
4D v16
インターフェースの国際化 (XLIFF)

インターフェースの国際化 (XLIFF)    


 

 

ビデオ中で説明されている操作の他、以下の点にも留意してください。

XLIFFファイルを使用するためには、ファイルを以下の場所に配置しなければなりません:

  • Windows: [DatabaseFolder]\Resources\[Lang].lproj\[MyJALoc].xlf
  • Mac OS: [DatabaseFolder]:Resources:[Lang].lproj:[MyJALoc].xlf

*[Lang]は言語コードです。例えば日本語の場合ja.lprojフォルダーです。

デフォルトで4Dは使用するランゲージを以下の順番で決定します:

  1. システムランゲージ
  2. 4Dアプリケーションランゲージ
  3. English
  4. 上記が見つからなかった場合、Resourcesフォルダー内で最初に見つけた言語

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.

 
 

 
プロパティ 

プロダクト: 4D
テーマ: インターフェースの国際化 (XLIFF)

 
履歴 

 
ARTICLE USAGE

セルフトレーニング ( 4D v16)