Skip to main content
13-Aquamarine
April 20, 2020
Solved

How to translate dialogs and menus for a custom application

  • April 20, 2020
  • 1 reply
  • 2240 views

Hello,

I have developped a custom application (with ACL language). But I would like to have a multilingual application (French / English). What is the best way to translate the dialogs and the menus ?

Kind regards

David

Best answer by ClayHelberg

In the base app, they do this using text entities and parameterized catalog entries. For example, the standard Find dialog includes this at the top:

 

<!DOCTYPE window PUBLIC "-//Arbortext//DTD XUI XML 1.1//EN"
 "xui.dtd" [
<!ENTITY % xuidlgStrings PUBLIC "-//Arbortext//ENTITIES XUI XML 1.0//EN" "">
%xuidlgStrings;
]>

 

 

If you look in the main catalog file, the entry for this public ID looks like this:

 

PUBLIC "-//Arbortext//ENTITIES XUI XML 1.0//EN" "../lib/locale/%L/dialogStrings.ent"

 

Note the "%L" parameter there, which will capture the user's configured locale and use it to load the appropriate text entities.

 

So, you should be able to add two folders in your custom/lib/locale folder: custom/lib/locale/en for English, and custom/lib/locale/fr for French. Put the corresponding language files in these folders, add a catalog entry similar to the one above, and a parameter entity reference similar to the one in the Find dialog above into your dialog. Then, replace the literal strings in your XUI dialog file with entity references, and you should get the right strings based on the user's configured locale.

 

If you are lucky, and your controls all have fairly generic labels like "OK", "Cancel", "Save", etc., you may even be able to just use the included localization entities and have it work. Otherwise, you'll have to pull out all your strings as entities and define the two entity files, one for each language.

(Of course, if you have a user who chooses "es" as their locale, they'll come up empty, so you might want to include fallback copies of the English entities file in other locale folders just in case.)

1 reply

18-Opal
May 21, 2020

In the base app, they do this using text entities and parameterized catalog entries. For example, the standard Find dialog includes this at the top:

 

<!DOCTYPE window PUBLIC "-//Arbortext//DTD XUI XML 1.1//EN"
 "xui.dtd" [
<!ENTITY % xuidlgStrings PUBLIC "-//Arbortext//ENTITIES XUI XML 1.0//EN" "">
%xuidlgStrings;
]>

 

 

If you look in the main catalog file, the entry for this public ID looks like this:

 

PUBLIC "-//Arbortext//ENTITIES XUI XML 1.0//EN" "../lib/locale/%L/dialogStrings.ent"

 

Note the "%L" parameter there, which will capture the user's configured locale and use it to load the appropriate text entities.

 

So, you should be able to add two folders in your custom/lib/locale folder: custom/lib/locale/en for English, and custom/lib/locale/fr for French. Put the corresponding language files in these folders, add a catalog entry similar to the one above, and a parameter entity reference similar to the one in the Find dialog above into your dialog. Then, replace the literal strings in your XUI dialog file with entity references, and you should get the right strings based on the user's configured locale.

 

If you are lucky, and your controls all have fairly generic labels like "OK", "Cancel", "Save", etc., you may even be able to just use the included localization entities and have it work. Otherwise, you'll have to pull out all your strings as entities and define the two entity files, one for each language.

(Of course, if you have a user who chooses "es" as their locale, they'll come up empty, so you might want to include fallback copies of the English entities file in other locale folders just in case.)

dgopois13-AquamarineAuthor
13-Aquamarine
May 25, 2020

Hello Clay,

For my application, I chose to use XLIFF files and the "amo" ACL functions (amo_open, amo_text, amo_close) but the solution with the entities is also interesting.

Thank you for your help.

David