Home > Class Reference > ENSLIB namespace > %Library.MessageDictionary

%Library.MessageDictionary

class %Library.MessageDictionary extends %Library.RegisteredObject

The %MessageDictionary is introduced to allow easy localization of program messages and CSP page content. A %MessageDictionary is a dictionary of messages. Each message in the dictionary is any Cache string and is indexed by any Cache value. A %MessageDictionary is then defined for each language and domain needed by your application. Each message is indexed by language, domain and id.

In order for a %MessageDictionary object to be created (New'ed), a language and domain must be specified for the message dictionary. The format of the specification string is "<language>:<domain>". <language> is an optional RFC 1766 language tag. If not specified the default system language is used. <domain> is a required domain specification, for example "en-us:titles" or ":names".

Property Inventory

Method Inventory

Properties

property Domain as %String;
The Domain attribute defines the logical grouping of messages in the Message Dictionary. If the domain name begins with %, then the Message Dictionary is considered a system Message Dictionary that is visible in all namespaces. Application Message Dictionaries are visible in only the namespace in which they are defined.
Property methods: DomainDisplayToLogical(), DomainGet(), DomainIsValid(), DomainLogicalToDisplay(), DomainLogicalToOdbc(), DomainNormalize(), DomainSet()
property Language as %String;
The Language attribute defines the language of the messages in the Message Dictionary. Language is any RFC 1766 defined language tag. In summary, a language tag is composed of 1 or more parts: A primary language tag optionally followed by a hyphen (-) separated secondary subtag. The Language string will be normalized to all lower case characters.
Property methods: LanguageDisplayToLogical(), LanguageGet(), LanguageIsValid(), LanguageLogicalToDisplay(), LanguageLogicalToOdbc(), LanguageNormalize(), LanguageSet()

Methods

method %OnNew(initvalue) as %Status
Inherited description: This callback method is invoked by the %New() method to provide notification that a new instance of an object is being created.

If this method returns an error then the object will not be created.

It is passed the arguments provided in the %New call. When customizing this method, override the arguments with whatever variables and types you expect to receive from %New(). For example, if you're going to call %New, passing 2 arguments, %OnNew's signature could be:

Method %OnNew(dob as %Date = "", name as %Name = "") as %Status If instead of returning a %Status code this returns an oref and this oref is a subclass of the current class then this oref will be the one returned to the caller of %New method.

classmethod Delete(languages As %String = "", flag As %String = "") as %Status
Delete all Message Dictionary(s) for the specified languages. Languages is an optional comma separated list of languages whose Message Dictionaries are to be deleted. If languages is not specified, Message Dictionaries for all languages are deleted. The "s", system flag, is an optional flag indicating whether system "s" or application Message Dictionaries are to be dleeted. The default value is to delete application Message Dictionaries.

The messages names associated with include files are always deleted, but not any previously geenrated include files. The "d", display, flag is supported.

classmethod Export(file As %String, languages As %String = "", flag As %String = "") as %Status
Export Message Dictionaries to XML file(s). languages is an optional comma separated list of languages. If languages is not specified, all languages are exported. Each language in the list is exported to a separate file. The template for the filename is given by the file argument that is of the format "<filepath>.<ext>". The file will be named by concatenating the language to the <filepath> with an extension of <ext>. The "s", system flag, is an optional flag indicating whether system "s" or application Message Dictionaries are to be exported.
classmethod ExportDomainList(file As %String, domainList As %String, language As %String) as %Status
Export Message Dictionaries for the specified languages and domains. fil is the path of the file to be written. domainList is a comma separated list of domains to be exported. language is an optional language that default to the current session language, $$$SessionLanguage.
method FormatMessage(id As %String, default As %String, args...) as %String
Get and format message text from this Message Dictionary. The default argument is used for the message if no message is found for id. If the default argument is not specified, then string for the default language or English is used as the default. Arguments of the form %1, %2, etc will be replaced by arguments that follow the id argument.
classmethod FormatText(text As %String, args...) as %String
Format the specified message text. Arguments of the form %1, %2, etc will be replaced by arguments that follow the text argument.
classmethod GenerateInclude(includeName As %String, flag As %String = "", DomainList="", UseDomainName As %Boolean = 0) as %Status
Generate an include file mapping the Name attributes of each message in any Message Dictionary to the message id.

The name of the include file to be generated is includeName. The DomainList argument is a comma separated list of names of the domains for which the include file is to generated. If Domain is not specified or "", then all domains are included in the include file. If UseDomainName is true (1), then the domain name as "" is prepended to the message code in the include file. The "s", system flag, is an optional flag indicating whether system, "s", or application Message Dictionaries are to be exported. The "d", display, flag is supported.

classmethod GetDomains(language As %String = "", flag As %String = "") as %ListOfDataTypes
GetDomains returns a list of all domains that have messages loaded for the specified language. If language="" is specifed, the default language is used. The "s", system flag, is an optional flag indicating whether languages supported by system ("s") or application Message Dictionaries are to be returned. The default value is to return the domains for application Message Dictionaries.
classmethod GetLanguages(domain As %String = "", flag As %String = "") as %ListOfDataTypes
GetLanguages returns a list of all languages that have messages loaded for the specified domain or all languages if domain="" Each language is in the standard RFC1766 format and all in lower case. The "s", system flag, is an optional flag indicating whether languages supported by system ("s") or application Message Dictionaries are to be returned. The default value is to return the languages for application Message Dictionaries.
method GetMessage(id As %String, default As %String = "") as %String
Get message text from this Message Dictionary. The default argument is used for the message if no message is found for id. No message formatting is supported by this method.
method GetNextMessage(ByRef id As %String) as %String
Return the text and id of the next message. The text and id of the message with the next id are returned. If the input id = "", then the text and id of the first message are returned. Return an empty string for the message text and id, if the input id was for the last message. Language is optional and the current language is used if language is "" or not specified. Language will be converted to lower case before being used. Domain can be a system domain beginning with % or a application domain.
classmethod GetSessionLanguage() as %String
GetSessionLanguage retrieves the default session language for the messages in the Message Dictionary. The language returned is a RFC 1766 defined language tag.
In summary, a language tag is composed of 1 or more parts: A primary language tag optionally followed by a hyphen (-) separated secondary subtag. The Language string will be normalized to all lower case characters.
classmethod Import(filepath As %String, flag As %String = "") as %Status