OWLNext    7.0
Borland's Object Windows Library for the modern age
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
lclstrng.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1994, 1996 by Borland International, All Rights Reserved
4//
5/// \file
6/// TLocaleString - localized name support
7//----------------------------------------------------------------------------
8
9#if !defined(OWL_LCLSTRNG_H)
10#define OWL_LCLSTRNG_H
11
12#include <owl/defs.h>
13#include <owl/private/defs.h>
14#include <owl/private/number.h>
15#if defined(BI_HAS_PRAGMA_ONCE)
16# pragma once
17#endif
18
19namespace owl {
20
21#define DEFAULT_SYSTEM_LANGID 0x409 // in case 16-bit with no NLS support
22
23/// Holds a language ID, a predefined number that represents a base language and
24/// dialect. For example, the number 409 represents American English. TLocaleString
25/// uses the language ID to find the correct translation for strings.
26typedef owl::uint16 TLangId; // language ID - same as NT LANGID
27
28typedef int (*TstricmpLang)(const tchar *, const char *, TLangId);
29
30const TLangId LangSysDefault = 0x0800;
31const TLangId LangUserDefault = 0x0400;
32const TLangId LangNeutral = 0x0000;
33
34#include <owl/preclass.h>
35
36
37
38//----------------------------------------------------------------------------
39/// \struct TLocaleString
40/// localizable substitute for char*
41//
42/// Designed to provide support for localized registration parameters, the
43/// TLocaleString Struct defines a localizable substitute for char* strings. These
44/// strings, which describe both OLE and non-OLE enabled objects to the user, are
45/// available in whatever language the user needs. This Struct supports
46/// ObjectWindows' Doc/View as well as ObjectComponents' OLE-enabled applications.
47/// The public member functions, which supply information about the user's language,
48/// the native language, and a description of the string marked for localization,
49/// simplify the process of translating and comparing strings in a given language.
50///
51/// To localize the string resource, TLocaleString uses several user-entered
52/// prefixes to determine what kind of string to translate. Each prefix must be
53/// followed by a valid resource identifier (a standard C identifier).The following
54/// table lists the prefixes TLocaleString uses to localize strings. Each prefix is
55/// followed by a sample entry.
56///
57/// - \c \b @ TXY The string is a series of characters interpreted as a resource ID and is
58/// accessed only from a resource file. It is never used directly.
59/// - \c \b # 1045 The string is a series of digits interpreted as a resource ID and is
60/// accessed from a resource file. It is never used directly.
61/// - \c \b ! MyWindow The string is translated if it is not in the native language;
62/// otherwise, this string is used directly.
63///
64///
65/// See the section on localizing symbol names in the ObjectWindows Programmer's
66/// Guide for more information about localizing strings.
67//
69 //TLocaleString():Private(0){}
70 //TLocaleString(const TLocaleString& lstr):Private(lstr.Private){}
71 //TLocaleString(const tchar* str):Private(str){}
72 const tchar * Translate(TLangId lang); ///< translate string
73 operator const tchar *() const; ///< return current string
74 void operator =(const tchar * str) { Private = str; }
75 int Compare(const tchar* str, TLangId lang); ///< insensitive compare
76
77 const tchar* Private; ///< string pointer used for initialization
78
79 static TLangId GetSystemLangId(); ///< platform-dependent implementation
80 static TLangId GetUserLangId(); ///< platform-dependent implementation
81 static int IsNativeLangId(TLangId lang); ///< returns bool true if native
82
83/// The default language identifier.
84 static TLangId SystemDefaultLangId;///< must define and set to system language
85
86/// The user-defined default language identifier.
87 static TLangId UserDefaultLangId; ///< same as system language if single user
88
89/// The base language ID of non-localized strings.
90 static TLangId NativeLangId; ///< must define and set to lang. of literals
91
92/// The handle of the file containing the resource.
93 static HINSTANCE Module; ///< must define and set to resource module
94 static TLocaleString Null; ///< reference a null string
95 static int CompareLang(const tchar * s1, const tchar * s2, TLangId);
96 // CompareLang() may be implemented in another module for NLS support
97};
98
99#include <owl/posclass.h>
100
101} // OWL namespace
102
103//
104// Prefix characters for locale strings
105//
106#define AUTOLANG_RCID '#' ///< indicates name specified by numeric ID
107#define AUTOLANG_XLAT '!' ///< indicates name to be localized (binary)
108#define AUTOLANG_LOAD '@' ///< indicates resource name to load (binary)
109
110//
111// Custom resource for translations
112//
113#define RT_LOCALIZATION MAKEINTRESOURCE(201)
114
115
116
117
118#endif // OWL_LCLSTRNG_H
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
int(* TstricmpLang)(const tchar *, const char *, TLangId)
Definition lclstrng.h:28
owl::uint16 TLangId
Holds a language ID, a predefined number that represents a base language and dialect.
Definition lclstrng.h:26
char tchar
Definition defs.h:77
const TLangId LangNeutral
Definition lclstrng.h:32
const TLangId LangUserDefault
Definition lclstrng.h:31
unsigned short uint16
Definition number.h:33
const TLangId LangSysDefault
Definition lclstrng.h:30
General definitions used by all ObjectWindows programs.
#define _OWLCLASS
Definition defs.h:338
Designed to provide support for localized registration parameters, the TLocaleString Struct defines a...
Definition lclstrng.h:68
static TLangId NativeLangId
The base language ID of non-localized strings.
Definition lclstrng.h:90
static TLangId SystemDefaultLangId
The default language identifier.
Definition lclstrng.h:84
const tchar * Private
string pointer used for initialization
Definition lclstrng.h:77
static TLangId UserDefaultLangId
The user-defined default language identifier.
Definition lclstrng.h:87
static HINSTANCE Module
The handle of the file containing the resource.
Definition lclstrng.h:93
static TLocaleString Null
reference a null string
Definition lclstrng.h:94