Locale Info
Availability LightWave 6.0 | Component Layout, Modeler | Header lwhost.h
The locale info global returns a code indicating the (human) language setting of the system.
Global Call
unsigned long locinfo; locinfo = ( unsigned long ) global( LWLOCALEINFO_GLOBAL, GFUSE_TRANSIENT );
The global function ordinarily returns a void *
, so this should be cast to an
integer type to get the return value.
The language ID is in the low 16 bits of the return value. The high 16 bits are
reserved for future use. The language ID can be extracted using a macro defined in lwhost.h
.
langid = locinfo & LWLOC_LANGID;
The language IDs are identical to those defined in the Microsoft Win32 API and exposed
in the Microsoft Visual C++ winnt.h
header file. Bits 7 - 0 define the language
group and bits 15 - 8 define the sublanguage. The plug-in SDK header file lwserver.h
contains symbols for some of the more common language IDs.
LANGID_GERMAN 0x0407 LANGID_USENGLISH 0x0409 LANGID_UKENGLISH 0x0809 LANGID_SPANISH 0x040a LANGID_FRENCH 0x040c LANGID_ITALIAN 0x0410 LANGID_JAPANESE 0x0411 LANGID_KOREAN 0x0412 LANGID_RUSSIAN 0x0419 LANGID_SWEDISH 0x041D
Note that the low order bits for USENGLISH
and UKENGLISH
are the
same. Win32 defines 9 flavors of English (as well as 16 flavors of both Arabic and
Spanish, for example) that are distinguished by sublanguage code.
Your plug-in isn't required to implement localization, but even if you don't provide error messages or panel text in multiple languages, you may still want to localize things like date formats or currency symbols.
Example
The following code fragment selects a greeting string based on the locale.
#include <lwserver.h> #include <lwhost.h> unsigned long locinfo; locinfo = ( unsigned long ) global( LWLOCALEINFO_GLOBAL, GFUSE_TRANSIENT ); switch ( locinfo & LWLOC_LANGID ) { case LANGID_GERMAN: msg = "Guten Tag"; break; case LANGID_USENGLISH: case LANGID_UKENGLISH: msg = "Good day"; break; case LANGID_SPANISH: msg = "Buenos dias"; break; case LANGID_FRENCH msg = "Bonjour"; break; case LANGID_ITALIAN msg = "Buon giorno"; break; case LANGID_JAPANESE msg = "Konnichi wa"; break; case LANGID_KOREAN msg = "Annyoung hase yo"; break; case LANGID_RUSSIAN msg = "Zdravstvuite"; break; case LANGID_SWEDISH msg = "God dag"; break; ...