OScript API/Built-in Package Index

Class: XLate

An xlate is a localized string. Each xlate consists of a group and a name. All xlates are defined in xlate databases, which are stored as text properties files.

Class Attributes

XLate group was not found

XLate name was not found

Generic xlate error

Class Methods

Create( String groupName, String stringName )

Create a new xlate

Finish custom xlates

IsXLate( String xlate, [Boolean lookup] )

Determine if the given string represents an xlate

ListOpened( [String moduleName] )

Get the list of open xlate databases associated with a module

LoadCustom( String locale, [String path] )

Load custom xlates

Load xlates for newly enabled languages

LookupXLate( String groupName, String stringName )

Find an xlate with the given group and name

Names( String xlate )

Return the group and name associated with the xlate

Open( String moduleName, String path )

Open an xlate database file

OpenXDB( Dynamic moduleOrObject ) Deprecated

Open an xlate database file associated with a module or an object

ResetOpened( [String moduleName] )

Reset the xlates for a given module

Class Attributes

XLate group was not found

XLate name was not found

Generic xlate error

Class Methods

Create

String Create( String groupName,
               String stringName )

Create a new xlate object with a specified name within a specified group

Parameters

groupName

Group to which the xlate belongs

stringName

Name of the xlate

Returns:

A localized string associated with the group and name

FinishCustom

Boolean FinishCustom()

Call this after all ospaces are loaded to add unclaimed xlates. An unclaimed xlate is one which does not appear in another properties file. Takes no parameters, iterates through all installed locales.

Returns:

TRUE if successful

IsXLate

Boolean IsXLate( String xlate,
                 [Boolean lookup] )

XLate.IsXLate() will determine if the given object is indeed an xlate. If the lookup parameter is TRUE, then it will also determine if the xlate is defined.

Parameters

xlate

An xlate

lookup

Whether to lookup to see if the xlate has been defined

Returns:

TRUE if the object is an xlate, and optionally whether it has been defined

Example

if ( XLate.IsXLate( [EXAMPLEMODULE_HTMLLABEL.MessageText], TRUE ) )

    Echo( 'The xlate was found' )

end

ListOpened

Dynamic ListOpened( [String moduleName] )

This function is used to get the list of open xlate databases associated with a module, or all open databases for all modules.

Parameters

moduleName

Module name

Returns:

A list of lists, each entry containing a module name and the path to the database file

LoadCustom

Boolean LoadCustom( String locale,
                    [String path] )

Automatically called when locale is added or may be called with custom path for testing When locale is first added, $OTHOME/config/custom_strings is checked for locale-specific files.

Parameters

locale

locale

path

optional path

Returns:

TRUE if successful

LoadLanguagePacks

Boolean LoadLanguagePacks()

This function will check if all xlates of enabled languages have been loaded and automatically load any missing ones. Note that it is automatically called by the engine at the end of every request. Thus, there is no need to call this function for front end llserver threads. However, agent threads may call this when they see it necessary or beneficial.

Returns:

TRUE if successful

LookupXLate

Dynamic LookupXLate( String groupName,
                     String stringName )

This function is used to find an xlate with the given name, within the specified group.

Parameters

groupName

Group to which the xlate belongs

stringName

Name of the xlate

Returns:

A localized string associated with the group and name, or an error message if the xlate was not found

Names

List Names( String xlate )

Returns a list that contains the xlate group name and name

Parameters

xlate

An xlate

Returns:

A two-element list containing the group name and xlate name

Example

List names = XLate.Names( [EXAMPLEMODULE_HTMLLABEL.MessageText] ) // Will return { 'EXAMPLEMODULE_HTMLLABEL', 'MessageText' }

Open

Dynamic Open( String moduleName,
              String path )

Open an xlate database file

Parameters

moduleName

The name of the module

path

Path to the database file

Returns:

TRUE if the file could be opened

Example

Boolean result = XLate.Open( 'examplemodule', 'C:\\OPENTEXT\\module\\examplemodule\\ospace' )

OpenXDB

Deprecated
Dynamic OpenXDB( Dynamic moduleOrObject )

Open an xlate database file associated with a module or an object

Parameters

moduleOrObject

The name of a module, or an object reference

Returns:

Undefined

ResetOpened

Boolean ResetOpened( [String moduleName] )

Reset the xlates for a given module

Parameters

moduleName

The name of the module

Returns:

TRUE if successful

 Copyright © 2023 OpenText Corporation. All rights reserved.