Skip to main content

XML Message Files

An XML message file is an export of a message dictionary, which is used in string localization. This is also the required format for any messages that you wish to import. (For export and import instructions, see Managing a Message Dictionary.)

Whenever possible, XML message files should use UTF-8 encoding. However, in certain cases a developer or translator might use local platform encodings, such as shift-jis, for ease of editing the XML message file. Whatever encoding is used for the XML file, it must be supported by the locale for the application, and it must be able to express the messages for the language.

An XML message file may contain messages for one language and multiple domains.

<MsgFile> Element

The <MsgFile> element is the top-level container for the XML message file, and there is only one <MsgFile> element per file.

The <MsgFile> element has one required attribute, Language. The value of the <MsgFile> Language attribute is an all-lowercase RFC1766Opens in a new tab code that identifies the language for the file. It consists of one or more parts: a primary language tag (such as en or ja) optionally followed by a hyphen (-) and a secondary language tag (en-gb or ja-jp).

In the following example, this language is "en" (English).

<?xml version="1.0" encoding="utf-8" ?>
<MsgFile Language="en">
    <MsgDomain Domain="sample">
        <Message Id="source">Source</Message>
        <Message Id="menu">Samples Menu</Message>
    </MsgDomain>
</MsgFile>

<MsgFile> must contain at least one <MsgDomain> element. It may contain more than one <MsgDomain>.

<MsgDomain> Element

The <MsgDomain> element has one required attribute, Domain. The value of the <MsgDomain> Domain attribute is one of the domain names that you are using to organize the messages in your application.

Any <MsgDomain> element may contain zero or more <Message> elements.

<Message> Element

The <Message> element has one required attribute, Id. The value of the <Message> Id attribute is one of the message ID strings that you are using to organize the messages in your application.

Any <Message> element may contain a text string. The string may consist of any of the following items, separately or in combination:

  • Simple text, as permitted by the file format

  • Substitution arguments %1, %2, %3, or %4

  • HTML formatting

  • A string expression in ObjectScript format

The following example uses %1, %2, the HTML tag for bold formatting, and the ObjectScript string convention that two successive double quote characters indicate a single double quote:

<Message>
  The session $Username="&lt;b&gt;%1&lt;/b&gt;" $Roles="&lt;b>%2&lt;/b&gt;"
</Message>

See Also

FeedbackOpens in a new tab