Index: sal/util/sal.map =================================================================== RCS file: /cvs/porting/sal/util/sal.map,v retrieving revision 1.42 diff -u -p -u -r1.42 sal.map --- sal/util/sal.map 4 Apr 2003 10:46:19 -0000 1.42 +++ sal/util/sal.map 14 Oct 2003 16:43:46 -0000 @@ -86,6 +86,7 @@ UDK_3_0_0 { osl_getSocketOption; osl_getSocketType; osl_getSymbol; + osl_getSystemLocale; osl_getSystemPathFromFileURL; osl_getSystemTime; osl_getThreadIdentifier; Index: sal/inc/rtl/locale.h =================================================================== RCS file: /cvs/porting/sal/inc/rtl/locale.h,v retrieving revision 1.3 diff -u -p -u -r1.3 locale.h --- sal/inc/rtl/locale.h 26 Apr 2001 13:34:01 -0000 1.3 +++ sal/inc/rtl/locale.h 14 Oct 2003 16:43:58 -0000 @@ -130,6 +130,15 @@ rtl_Locale * SAL_CALL rtl_locale_registe rtl_Locale * SAL_CALL rtl_locale_getDefault(); /** + As above - but actually useful - and not strangely deprecated, + and with no setter. + */ +typedef enum { + rtl_LocaleSystemMessages, + rtl_LocaleSystemCType +} rtl_LocaleSystemType; + +/** Sets the default. Normally set once at the beginning of applet or application, then never reset. setDefault does not reset the host locale. Index: sal/inc/rtl/locale.hxx =================================================================== RCS file: /cvs/porting/sal/inc/rtl/locale.hxx,v retrieving revision 1.3 diff -u -p -u -r1.3 locale.hxx --- sal/inc/rtl/locale.hxx 26 Apr 2001 13:34:01 -0000 1.3 +++ sal/inc/rtl/locale.hxx 14 Oct 2003 16:43:58 -0000 @@ -263,6 +263,16 @@ public: */ OUString getVariant() const { return pData->Variant; } + /** + Getter for lang-country name + */ + inline OUString getRawName() + { + rtl::OUString aRaw = ( getLanguage() + + rtl::OUString::createFromAscii( "-" ) + + getCountry() ); + return aRaw; + } /** Returns the hash code of the locale This. Index: sal/inc/osl/process.h =================================================================== RCS file: /cvs/porting/sal/inc/osl/process.h,v retrieving revision 1.14 diff -u -p -u -r1.14 process.h --- sal/inc/osl/process.h 26 Mar 2003 16:45:37 -0000 1.14 +++ sal/inc/osl/process.h 14 Oct 2003 16:44:16 -0000 @@ -360,6 +360,8 @@ oslProcessError SAL_CALL osl_getProcessL */ oslProcessError SAL_CALL osl_setProcessLocale( rtl_Locale * pLocale ); + +rtl_Locale * SAL_CALL osl_getSystemLocale( rtl_LocaleSystemType nType ); sal_Bool SAL_CALL osl_sendResourcePipe(oslPipe Pipe, oslSocket Socket); Index: sal/osl/unx/nlsupport.c =================================================================== RCS file: /cvs/porting/sal/osl/unx/nlsupport.c,v retrieving revision 1.21 diff -u -p -u -r1.21 nlsupport.c --- sal/osl/unx/nlsupport.c 16 Jul 2003 17:21:12 -0000 1.21 +++ sal/osl/unx/nlsupport.c 14 Oct 2003 16:44:29 -0000 @@ -1347,3 +1347,46 @@ int _imp_setProcessLocale( rtl_Locale * #endif /* ifdef LINUX || SOLARIS || MACOSX || NETBSD */ + +// Get locale of category LC_CTYPE of environment variables +static sal_Char* GetLangFromEnvironment() +{ + static sal_Char* pFallback = "C"; + sal_Char *pLang = NULL; + + pLang = getenv ( "LC_ALL" ); + if (! pLang) + pLang = getenv ( "LC_CTYPE" ); + if (! pLang) + pLang = getenv( "LANG" ); + if (! pLang) + pLang = pFallback; + + return pLang; +} + +rtl_Locale * SAL_CALL osl_getSystemLocale( rtl_LocaleSystemType nType ) +{ + const char *pMessages[] = { "LANGUAGE", "LC_ALL", "LC_MESSAGES", "LANG", NULL }; + const char *pCType[] = { "LC_ALL", "LC_CTYPE", NULL }; + const char **pScan; + const char *pLang = NULL; + static rtl_Locale *pLocales[2] = { NULL, NULL }; + + if( !pLocales[ nType ] ) + { + pScan = (nType == rtl_LocaleSystemMessages) ? pMessages : pCType; + while (*pScan) + { + if( pLang = getenv( *pScan ) ) + break; + pScan++; + } + if( !pLang ) + pLang = "C"; + + pLocales[ nType ] = _parse_locale( pLang ); + } + + return pLocales[ nType ]; +}