// wxLanguageInfo
// ----------------------------------------------------------------------------
-#ifdef __WXMSW__
+#ifdef __WINDOWS__
// helper used by wxLanguageInfo::GetLocaleName() and elsewhere to determine
// whether the locale is Unicode-only (it is if this function returns empty
return locale;
}
-#endif // __WXMSW__
+#endif // __WINDOWS__
// ----------------------------------------------------------------------------
// wxLocale
bool wxLocale::IsAvailable(int lang)
{
const wxLanguageInfo *info = wxLocale::GetLanguageInfo(lang);
- wxCHECK_MSG( info, false, wxS("invalid language") );
+ if ( !info )
+ {
+ // The language is unknown (this normally only happens when we're
+ // passed wxLANGUAGE_DEFAULT), so we can't support it.
+ wxASSERT_MSG( lang == wxLANGUAGE_DEFAULT,
+ wxS("No info for a valid language?") );
+ return false;
+ }
#if defined(__WIN32__)
if ( !info->WinLang )
// accessors for locale-dependent data
// ----------------------------------------------------------------------------
-#if defined(__WXMSW__) || defined(__WXOSX__)
+#if defined(__WINDOWS__) || defined(__WXOSX__)
namespace
{
const char* formatchars =
"dghHmMsSy"
-#ifdef __WXMSW__
+#ifdef __WINDOWS__
"t"
#else
"EawD"
// between 1 and 2 digits for days
fmtWX += "%d";
break;
-#ifdef __WXMSW__
+#ifdef __WINDOWS__
case 3: // ddd
fmtWX += "%a";
break;
wxFAIL_MSG( "too many 'd's" );
}
break;
-#ifndef __WXMSW__
+#ifndef __WINDOWS__
case 'D':
switch ( lastCount )
{
wxASSERT_MSG( lastCount <= 2, "too many 'g's" );
break;
-#ifndef __WXMSW__
+#ifndef __WINDOWS__
case 'a':
fmtWX += "%p";
break;
#endif
-#ifdef __WXMSW__
+#ifdef __WINDOWS__
case 't':
switch ( lastCount )
{
} // anonymous namespace
-#endif // __WXMSW__ || __WXOSX__
+#endif // __WINDOWS__ || __WXOSX__
-#if defined(__WXMSW__)
+#if defined(__WINDOWS__)
namespace
{
: LOCALE_SDECIMAL,
buf,
WXSIZEOF(buf)) )
+ {
str = buf;
+
+ // As we get our decimal point separator from Win32 and not the
+ // CRT there is a possibility of mismatch between them and this
+ // can easily happen if the user code called setlocale()
+ // instead of using wxLocale to change the locale. And this can
+ // result in very strange bugs elsewhere in the code as the
+ // assumptions that formatted strings do use the decimal
+ // separator actually fail, so check for it here.
+ wxASSERT_MSG
+ (
+ wxString::Format("%.3f", 1.23).find(str) != wxString::npos,
+ "Decimal separator mismatch -- did you use setlocale()?"
+ "If so, use wxLocale to change the locale instead."
+ );
+ }
break;
case wxLOCALE_SHORT_DATE_FMT:
return str.AsString();
}
-#else // !__WXMSW__ && !__WXOSX__, assume generic POSIX
+#else // !__WINDOWS__ && !__WXOSX__, assume generic POSIX
namespace
{