MTLocaleConfig

The MTLocaleConfig object performs the following functions:

- Holds a collection of LocalizedEntry objects, created from XML files, located in the directory passed to the Initialize() method. A file called LocaleFileList.xml must exist in this directory and it must contain entries for all localization files. The LocaleFileList.xml master file can be n-deep; therefore, it may also contain entries for other master files. When the Load or LoadLanguage method is called, the master file is found, is processed recursively, and the resulting internal collections are created.

- Creates new localized entries and writes them to XML files.

## Program ID

Metratech.MTLocaleConfig.1

## MTLocaleConfig Methods

GetLocalizedString | Returns a localized string for specified FQN (Fully Qualified Name) and language code.
Initialize | Sets configuration directory and host locations of the localization files.
InitializeWithhFileName | Sets master file name and optional host name from which to load localization files.
Load | Creates internal collection for specified locale space and language code.
LoadLanguage | Creates an internal collection for the specified language code.
Localize | Creates a new MTLocalizedEntry object and adds it to the internal MTLocalizedCollection object.
SetLocalizedString | Changes localized string for existing Mtlocalizedtntry. Note: Do not use this method to create localized entries; use the Localize method.
Write | Writes internal MTLocalizedCollection to XML files. File names are constructed automatically from locale space and language code for elements in this collection. Every entry is put into the appropriate file.

## MTLocaleConfig Properties

Count | Returns the number of items in an internal collection.
LocalizedCollection | Returns an internal localized collection.

## Example

Example to be provided in a future release of this online help system.

Method Detail

## GetLocalizedString

Returns a localized string for specified FQN (Fully Qualified Name) and language code.

### Visual Basic Syntax

Function GetLocalizedString(fqn As String, lang_code As String) As String

### C++ Syntax

HRESULT GetLocalizedString( [in] BSTR fqn,[in] BSTR lang_code, [out, retval] BSTR* str);

### Arguments

fqn

The fully qualified name.

lang_code

The language code.

Return Value

The localized string.

## Initialize

Sets configuration directory and host locations of the localization files. The following rules apply:

- If the host_name parameter is set, all reading and writing of localized strings happen remotely from/to this host’s relative dir == root_dir.

- If the root_dir parameter is set but the host_name is not, all reading and writing of localized strings are local from/to root_dir\Localization.

- If neither host_name or root_dir is set, objects are initialized in read-only mode from MTConfigdir.

### Visual Basic Syntax

Sub Initialize([root_dir], [host_name])

### C++ Syntax

HRESULT Initialize([in, optional]VARIANT root_dir, [in, optional]VARIANT host_name);

### Arguments

config_dir [optional]

The configuration directory.

host [optional]

The host name.

## InitializeWithFileName

Sets master file name and optional host name from which to load localization files.

### Visual Basic Syntax

Sub InitializeWithFileName(filename As String, host_name As String)

### C++ Syntax

HRESULT InitializeWithFileName([in] BSTR filename, [in] BSTR host_name);

### Arguments

filename

The master file name.

host [optional]

The host name.

## Load

Creates internal collection for specified locale space and language code.

### Visual Basic Syntax

Sub Load(name_space As String, lang_code As String)

### C++ Syntax

[id(3), helpstring("method Load")] HRESULT Load(BSTR name_space, BSTR lang_code);

### Arguments

name_space

The locale space.

lang_code

The language code.

## LoadLanguage

Creates an internal collection for the specified language code.

### Visual Basic Syntax

Sub LoadLanguage(lang_code As String)

### C++ Syntax

HRESULT LoadLanguage(BSTR lang_code);

### Arguments

lang_code

The language code.

## Localize

The localize method creates a new MTLocalizedEntry object and adds it to the internal MTLocalizedCollection object.

### Visual Basic Syntax

Sub Localize(name_space As String, lang_code As String, fqn As String, value As String)

### C++ Syntax

HRESULT Localize([in] BSTR name_space, [in] BSTR lang_code, [in] BSTR fqn, [in] BSTR value);

### Arguments

name_space

The locale space.

lang_space

The language space.

fqn

The localized string.

## SetLocalizedString

Changes localized string for existing MtlocalizedEntry.

Note: Do not use this method to create localized entries; use the Localize method.

### Visual Basic Syntax

Sub SetLocalizedString(fqn As String, lang_code As String, newval As String)

### C++ Syntax

HRESULT SetLocalizedString(BSTR fqn, BSTR lang_code, BSTR newval);

### Arguments

fqn

The locale space.

lang_code

The language code.

newval

New localized string.

## Write

Writes internal MTLocalizedCollection to XML files. File names are constructed automatically from locale space and language code for elements in this collection. Every entry is put into the appropriate file.

### Visual Basic Syntax

Sub Write()

### C++ Syntax

HRESULT Write();

### Arguments

None.

Property Detail

## Count

Returns the number of items in an internal collection.

This is a read-only property.

### Visual Basic Syntax

Property Count As Long

### C++ Syntax

[propget, id(8), helpstring("property Count")] HRESULT Count([out, retval] long *pVal);

### Return Value

The number of items in an internal collection.

## LocalizedCollection

Returns an internal localized collection.

This is a read-only property.

### Visual Basic Syntax

Property LocalizedCollection As MTLocalizedCollection

### C++ Syntax

[propget, id(13), helpstring("property LocalizedCollection")] HRESULT LocalizedCollection([out, retval] IMTLocalizedCollection* *pVal);

### Return Value

The internal collection.