4D v16.3Appendix C: XLIFF architecture |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v16.3
Appendix C: XLIFF architecture
Appendix C: XLIFF architecture
4D supports the XLIFF standard for the localization of interface text and titles. This technology is used internally for 4D applications, and 4D developers as well as plug-ins developers will be able to benefit from this new implementation in their own customized applications and plug-ins. The principle for setting up a 4D application interface that is translated dynamically is as follows: all the elements that depend on the language (text, labels and pictures) are stored outside the application, as files, in a folder named Resources. In forms, menus, and so on, the labels and pictures are specified as references. When the application is executed, these elements are displayed dynamically from external files depending on the linguistic context. The XLIFF standard uniformizes the mode of referencing and displaying labels. Note: You can also read strings stored in XLIFF files directly using the Get localized string command. In the Form editor, you can see the "real" contents of static areas by clicking in the Form editor area or by choosing Show Format or Show Name in the Object menu: Compatibility note: In addition to XLIFF, 4D still supports the previous system, based on the concept of “resources” (of the STR# type). This system is nevertheless now obsolete. Both systems can be used at the same time, in particular in converted applications (this point is detailed in the following pages). XLIFF (XML Localization Interchange File Format) is a dedicated standard for the localization process. It is used to describe the correspondence between a source language and a target language within an XML file. Actually, the XLIFF standard is a new alternative to resources-based localization systems. Various tools, including several freeware, can also be found to manage such files. For more information about the XLIFF standard, please refer to the official XLIFF 1.1 Specification that can be found at the following address: Warning: The XLIFF standard is case sensitive. There are two ways to call XLIFFstrings from 4D:
You can call the Get localized string command to access the translation of a string directly in the current language of the application from anywhere in the database. You can use the Get database localization command to find out the current language. Compatibility note: The Get indexed string and STRING LIST TO ARRAY commands in the "Resources" theme can also take advantage of XLIFF documents. However, their use is no longer recommended and they are only maintained for compatibility reasons. In 4D, automatic XLIFF references can be used at the following locations:
Notes:
In 4D, you can use automatic XLIFF references via one of the following syntaxes:
If you use different syntaxes in your database, the order of priority applied when searching a valid translation in the XLIFF files will be as follows: You can see the XLIFF reference or the title translated according to the current language in the form editor using, respectively, the Show Name and Show Resource commands of the Object menu. For more information, refer to Using references in static text. To implement an XLIFF architecture for your localized application, you just need to build one or more valid XLIFF file(s) and copy them into the Resources folder of the database. For more information about the Resources folder of the database, refer to Managing the Resources folder. Here is the full pathname to use:
where:
4D will automatically load the XLIFF files in the folder corresponding to the current language of the database. To set the current language of the database, 4D carries out successive searches in the Resources folder of the database to find a language corresponding to (in the following order of priority):
The Get database localization command finds out what current language is specified for the database. If a language variation is used and is not available in the XLIFF files, the next closest language will be used. XLIFF files can be named freely; they just need to have the extension “.xlf.”. You can place several XLIFF files in the same language folder; they will be loaded in the alphabetical order of the file names. The name of the “.lproj” folder must respect one of the standards described below. 4D will look for a valid folder name based on each of these standards, in the following specific order:
A summary table of the language codes supported by 4D is provided in . If several language definitions are found, 4D will always look for the most precise translations. For example, if the current OS language setting is “French Canadian,” 4D will first look for “fr-ca” translations and then, if not found, “fr” translations. Note: The same principle applies within XLIFF files for the “target-language” tag. You must be sure to carefully set this attribute within the XLIFF files since a file located in the “fr-ca.lproj” folder that has a “target-language=fr” tag will be considered as a translation into “fr” and not “fr-ca.” The XLIFF files are reloaded “dynamically” while you localize your application, so that you can see if the localized words or sentences fit into the object frames (buttons, group boxes, etc.). This reload occurs as 4D comes back to the front whenever the modification date or time has been changed since the last load.The current form will be reloaded simultaneously. The following table lists the language codes supported by 4D for managing XLIFF files.
|
PROPERTIES
Product: 4D
HISTORY
ARTICLE USAGE
4D Design Reference ( 4D v16) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||