23#include <osl/process.h>
24#include <rtl/locale.h>
25#include <rtl/ustring.hxx>
29#include <rtl/string.hxx>
32#include <osl/mutex.hxx>
33#include <osl/doublecheckedlocking.h>
44 static const char*
const pFallback =
"C";
45 const char *pLang =
nullptr;
48 pLang = getenv (
"LC_ALL" );
49 if (! pLang || pLang[0] == 0)
50 pLang = getenv (
"LC_CTYPE" );
51 if (! pLang || pLang[0] == 0)
52 pLang = getenv(
"LANG" );
53 if (! pLang || pLang[0] == 0)
63 static const char*
const pFallback =
"C";
64 const char *pLang =
nullptr;
67 pLang = getenv (
"LANGUAGE" );
68 if (! pLang || pLang[0] == 0)
71 pLang = getenv (
"LC_ALL" );
73 if (! pLang || pLang[0] == 0)
74 pLang = getenv (
"LC_MESSAGES" );
75 if (! pLang || pLang[0] == 0)
76 pLang = getenv(
"LANG" );
77 if (! pLang || pLang[0] == 0)
84typedef const char * (*getLangFromEnv)(
bool& rbColonList );
94 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex());
95 nLang = rSystemLanguage;
99 rtl_Locale *procLocale;
100 (void) pGetLangFromEnv;
102 if ( osl_getProcessLocale(&procLocale) == osl_Process_E_None )
105 OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
106 rSystemLanguage = nLang;
109 fprintf( stderr,
"intnunx.cxx: failed to convert osl_getProcessLocale() language to system language.\n" );
113 bool bColonList =
false;
114 OString aUnxLang( pGetLangFromEnv( bColonList));
118 sal_Int32
n = aUnxLang.indexOf(
':');
122 if (
n == 0 && aUnxLang.getLength() > 1)
124 n = aUnxLang.indexOf(
':', 1);
126 n = aUnxLang.getLength();
135 aUnxLang = aUnxLang.copy(s,
n);
139 OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
140 rSystemLanguage = nLang;
144 OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
Wrapper for liblangtag BCP 47 language tags, MS-LangIDs, locales and conversions in between.
LanguageType getLanguageType(bool bResolveSystem=true) const
Obtain mapping to MS-LangID.
LanguageTag & makeFallback()
Fall back to a known locale.
static LanguageType getPlatformSystemLanguage()
static LanguageType getPlatformSystemUILanguage()
static LanguageType convertUnxByteStringToLanguage(std::string_view rString)
const char *(* getLangFromEnv)(bool &rbColonList)
static LanguageType nImplSystemUILanguage
static void getPlatformSystemLanguageImpl(LanguageType &rSystemLanguage, getLangFromEnv pGetLangFromEnv)
static LanguageType nImplSystemLanguage
static const char * getLangFromEnvironment(bool &rbColonList)
static const char * getUILangFromEnvironment(bool &rbColonList)
#define LANGUAGE_DONTKNOW