Technical Background

From Apache OpenOffice Wiki
Jump to: navigation, search

This section provides an overview of how the Dialog Localization feature works internally and how the resources are stored. In case of a localized Dialog Library the localized properties do not contain strings but Resource IDs referring to a String Resource table. Example:

Dialog XML snippet, not localized:

  <dlg:window ... dlg:title="My Dialog">
  <dlg:button ... dlg:value="My Label"/>

Dialog XML snippet, localized:

  <dlg:window ... dlg:title="&amp;1.Dialog1.Title">
  <dlg:button ... dlg:value="&amp;3.Dialog1.CommandButton1.Label"/>

"&" is the XML encoding for the & character. This character is used as escape character marking the string as localized. The pure Resource ID is 1.Dialog1.Title respectively 3.Dialog1.CommandButton1.Label.

The strings referenced by the Resource IDs are stored in files meeting the format of Java properties files, e.g. described in In the Library's folder one of these files is stored for each language following a special naming scheme. For the languages used in the example above the following files are stored in the Dialog Library's folder (both for Application based libraries stored in the file system and for Document based libraries stored in a document's package file):

 Dialog1.xdl                     // Dialog XML description  // English (USA) properties file  // Estonian properties file  // French properties file
 DialogStrings_en_US.default     // Empty file marking English (USA) as default language

Each of these files contain all strings for the corresponding language using the Resource IDs as keys. The French properties file for the dialog shown in the last illustration looks like this:

 # Strings for Dialog Library Standard
 1.Title=French Dialog
 5.Dialog1.CheckBox1.Label=French Box1
 7.Dialog1.CheckBox2.Label=French Box2
 9.ListBox1.StringItemList=French List Entry1
 10.ListBox1.StringItemList=French List Entry2
 11.ListBox1.StringItemList=French List Entry3

The IDs start with a numeric part that is unique for the complete library. The textual part following then contains the Dialog, Control and Property name the Resource ID refers to. The numeric ID alone would be unique but the textual part makes it easier to associate Resource IDs and controls when resource properties files should be edited manually. When the dialog or controls are renamed the Resource IDs are renamed accordingly.

The UNO API used for managing the String Resource is placed in Each Dialog Library supports, giving access to a component. This component supports, allowing to resolve strings using Resource IDs as keys and, allowing to add and remove strings and languages.

In case of an Application Dialog Library the StringResource supports allowing to read/write the properties files from/to the file system. In case of a Document Dialog Library the StringResource supports allowing to read/write the properties files from/to the document's package file.

Further details are described in the IDL documentation.

Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages