TLocaleString struct

Back Up Next

TLocaleString struct

Header File
    <owl/lclstrng.h>

Description
    Designed to provide support for localized registration parameters, the TLocaleString Struct defines a localizable substitute for char* strings. These strings, which describe both OLE and non-OLE enabled objects to the user, are available in whatever language the user needs. This Struct supports ObjectWindows' Doc/View as well as ObjectComponents' OLE-enabled applications. The public member functions, which supply information about the user's language, the native language, and a description of the string marked for localization, simplify the process of translating and comparing strings in a given language.

    To localize the string resource, TLocaleString uses several user-entered prefixes to determine what kind of string to translate. Each prefix must be followed by a valid resource identifier (a standard C identifier).The following table lists the prefixes TLocaleString uses to localize strings. Each prefix is followed by a sample entry.

Prefix   Description
@ TXY   The string is a series of characters interpreted as a resource ID and is accessed only from a resource file. It is never used directly.
# 1045   The string is a series of digits interpreted as a resource ID and is accessed from a resource file. It is never used directly.
! MyWindow   The string is translated if it is not in the native language; otherwise, this string is used directly.

See the section on localizing symbol names in the ObjectWindows Programmer's Guide for more information about localizing strings.

Public Member Functions

Compare
    Syntax
        int Compare(const char far* str, TLangId lang);
    Description
        Using the specified language (lang), Compare compares TLocaleString with another string. It uses the standard string compare and the language-specific collation scheme. It returns one of the following values.

   Return value Meaning
   0   There is no match between the two strings.
   1   This string is greater than the other string.
   -1   This string is less than the other string.

CompareLang
    Syntax
        static int CompareLang(const char far* s1, const char far* s2, TLangId);
    Description
        This function may be re-implemented with enhanced NLS support in another module. Note: That module must be linked in before the library, to override this default implementation.
GetSystemLangId
    Syntax
        static TLangId GetSystemLangId();
    Description
        Returns the system language ID, which can be the same as the UserLangId.
GetUserLangId
    Syntax
        static TLangId GetUserLangId();
    Description
        Returns the user language ID. For single user systems, this is the same as LangSysDefault. The language ID is a predefined number that represents a base language and dialect.
IsNativeLangId
    Syntax
        static int IsNativelangId(TLangId lang);
    Description
        Returns true if lang equals the native system language.
operator =
    Syntax
        void operator = (const char* str);
    Description
        Assigns the string (str) to this locale string.
operator const char*()
    Syntax
        operator const char* ();
    Description
        Returns the current character string in the translation.
Translate
    Syntax
        const char* Translate(TLangId lang);
    Description
        Translates the string to the given language. Translate follows this order of preference in order to choose a language for translation:
            1.     Base language and dialect.
            2.     Base language and no dialect.
            3.     Base language and another dialect.
            4.     The native language of the resource itself.
            5.     Returns 0 if unable to translate the string. (This can happen only if an @ or # prefix is used; otherwise, the ! prefix indicates that the string following is the native language itself.)

Public Data Members

Module
    Syntax
        static HINSTANCE Module;
    Description
        The handle of the file containing the resource.
NativeLangId
    Syntax
        static TLangId NativeLangId;
    Description
        The base language ID of non-localized strings.
Null
    Syntax
        static TLocaleString Null;
    Description
        A null string.
Private
    Syntax
        const char* Private;
    Description
        A string pointer used internally.
SystemDefaultLangId
    Syntax
        static TLangId SystemDefaultLangId;
    Description
        The default language identifier.
UserDefaultLangId
    Syntax
        static TLangId UserDefaultLangId;
    Description
        The user-defined default language identifier.

 

Revised: February 09, 2000.


Copyright © 1998-2001 Yura Bidus. All rights reserved.