GLG Toolkit, JavaScript Library  Version 4.6
Internationalization and Localization

This group contains methods for setting locate as well as localizing GLG drawings by translating text strings to different languages. More...

Detailed Description

This group contains methods for setting locate as well as localizing GLG drawings by translating text strings to different languages.

Functions

Object ExportStrings (String separator1, String separator2)
 Writes all text strings defined in the viewport's drawing into an object representing an image of a string translation file. More...
 
int ImportStrings (String data, boolean verbose)
 Replaces text strings in the viewport's drawing with the strings loaded from a string translation file. More...
 
static void SetLocale (String locale)
 Sets locale used to display dates and numbers. More...
 

Function Documentation

◆ ExportStrings()

Object ExportStrings ( String  separator1,
String  separator2 
)

Writes all text strings defined in the viewport's drawing into an object representing an image of a string translation file.

If the method is invoked on an arbitrary non-viewport object, it writes all text strings defined in the object.

Parameters
separator1A character value that specifies the first separator character to be used in the generated output (for example, '#').
separator2A character value that specifies the second separator character to be used in the generated output (for example, '#').
Returns
A JavaScript object containing a count and data properties on success, or null on error. An integer count property contains the number of exported strings, and a string data property contains an image of the string translation file with a list of exported strings.
The number of exported strings or -1 in case of an error.

This method exports all strings defined in the drawing to an ASCII string translation file that can be edited using a text editor.

The method exports strings of the S (string) resource objects, such as the String attribute of a text object. It does not export strings that are not values of S resource objects, such as object names, tag names and tag sources, which ensures that the program logic is not affected when the translated file is used by ImportStrings to modify text strings in the drawing.

The string translation file contains a line for each exported string. Each string entry contains the name of a string resource which helps identify how the string is used, and two copies of the string: the current value and the new value. Each item in the string entry is separated by two separator characters. The name of the string resource and the first copy of the string are used to identify the string and should not be changed.

When the file is translated, the second copy of the string (the new value) may be replaced with a new string representing the text in the local language and local character set. Multiple copies of the file can be created, one for each supported language.

The ImportStrings method can be used at run time to display a localized drawing. An application can load different versions of the translated file to display localized drawings for different language environments.

This method provides a programming interface for exporting strings from a drawing. The File, Export Strings option of the GLG editors can be used to export strings from the loaded drawing, in which case two double quotation characters are used as the default separators. This can be changed by defining the GLG_STRING_SEPARATOR environment variable to supply a two character string to be used as a separator.

Refer to the Localization Support section of the GLG User's Guide and Builder Reference Manual for more information about the string translation file format.

◆ ImportStrings()

int ImportStrings ( String  data,
boolean  verbose 
)

Replaces text strings in the viewport's drawing with the strings loaded from a string translation file.

If the method is invoked on an arbitrary non-viewport object, it replaces text strings defined in the object.

Parameters
dataA string containing an image of the loaded string translation file with a list of strings to be converted.
verboseIf true, generates an error for each string that was not changed to a new value because it was missing a matching entry in the string translation file.
Returns
The number of imported strings or -1 in case of an error.

This method can be used at run time to display a localized drawing. An application can load different versions of the translated file to display localized drawings for different language environments. See ExportStrings for more information.

This method provides a run time interface for importing translated strings into a drawing to display it in a different language environment. The File, Import Strings option of the GLG editors can be used to import strings into the currently loaded drawing for testing.

◆ SetLocale()

static void SetLocale ( String  locale)
static

Sets locale used to display dates and numbers.

Parameters
localeLocale name.