]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/intl.cpp
Also allow key events for Shift-Tab when wxWANTS_CHARS style is used
[wxWidgets.git] / src / common / intl.cpp
index 36c76c398b09bf25a408065e3780b8b225e50b96..820a7d6bad0f1b85742c3840f73562f765703057 100644 (file)
     #pragma implementation "intl.h"
 #endif
 
+#if defined(__BORLAND__) && !defined(__WXDEBUG__)
+    // There's a bug in Borland's compiler that breaks wxLocale with -O2,
+    // so make sure that flag is not used for this file:
+    #pragma option -O1
+#endif
+
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
@@ -1215,7 +1221,7 @@ void wxMsgCatalogFile::FillHash(wxMessagesHash& hash, bool convertEncoding) cons
     if ( convertEncoding )
     {
         wxFontEncoding targetEnc = wxFONTENCODING_SYSTEM;
-        wxFontEncoding enc = wxFontMapper::Get()->CharsetToEncoding(charset, FALSE);
+        wxFontEncoding enc = wxFontMapper::Get()->CharsetToEncoding(m_charset, FALSE);
         if ( enc == wxFONTENCODING_SYSTEM )
         {
             convertEncoding = FALSE; // unknown encoding
@@ -1369,6 +1375,7 @@ wxLocale::wxLocale()
   m_pszOldLocale = NULL;
   m_pMsgCat = NULL;
   m_language = wxLANGUAGE_UNKNOWN;
+  m_initialized = false;
 }
 
 // NB: this function has (desired) side effect of changing current locale
@@ -1378,6 +1385,10 @@ bool wxLocale::Init(const wxChar *szName,
                     bool        bLoadDefault,
                     bool        bConvertEncoding)
 {
+  wxASSERT_MSG( !m_initialized,
+                _T("you can't call wxLocale::Init more than once") );
+  
+  m_initialized = true;
   m_strLocale = szName;
   m_strShort = szShort;
   m_bConvertEncoding = bConvertEncoding;
@@ -1420,7 +1431,7 @@ bool wxLocale::Init(const wxChar *szName,
   if ( m_strShort.IsEmpty() ) {
     // FIXME I don't know how these 2 letter abbreviations are formed,
     //       this wild guess is surely wrong
-    if ( szLocale[0] )
+    if ( szLocale && szLocale[0] )
     {
         m_strShort += (wxChar)wxTolower(szLocale[0]);
         if ( szLocale[1] )
@@ -1566,7 +1577,11 @@ bool wxLocale::Init(int language, int flags)
         }
         else
         {
-            int codepage = -1;
+            int codepage 
+                         #ifdef SETLOCALE_FAILS_ON_UNICODE_LANGS
+                         = -1
+                         #endif
+                         ;
             wxUint32 lcid = MAKELCID(MAKELANGID(info->WinLang, info->WinSublang),
                                      SORT_DEFAULT);
             // FIXME
@@ -1650,7 +1665,7 @@ bool wxLocale::Init(int language, int flags)
                     (flags & wxLOCALE_CONV_ENCODING) != 0);
     free(szLocale);
 
-    if ( ret )
+    if (IsOk()) // setlocale() succeeded
         m_language = lang;
 
     return ret;
@@ -2229,6 +2244,8 @@ wxFontEncoding wxLocale::GetSystemEncoding()
     {
         return wxFONTENCODING_CP950;
     }
+#elif defined(__WXMAC__)
+    return wxMacGetFontEncFromSystemEnc( CFStringGetSystemEncoding() ) ;
 #elif defined(__UNIX_LIKE__) && wxUSE_FONTMAP
     wxString encname = GetSystemEncodingName();
     if ( !encname.empty() )
@@ -2411,15 +2428,16 @@ const wxChar *wxLocale::GetString(const wxChar *szOrigString,
             if ( szDomain != NULL )
             {
                 wxLogTrace(_T("i18n"),
-                           _T("string '%s'[%d] not found in domain '%s' for locale '%s'."),
-                           szOrigString, n, szDomain, m_strLocale.c_str());
+                           _T("string '%s'[%lu] not found in domain '%s' for locale '%s'."),
+                           szOrigString, (unsigned long)n,
+                           szDomain, m_strLocale.c_str());
 
             }
             else
             {
                 wxLogTrace(_T("i18n"),
-                           _T("string '%s'[%d] not found in locale '%s'."),
-                           szOrigString, n, m_strLocale.c_str());
+                           _T("string '%s'[%lu] not found in locale '%s'."),
+                           szOrigString, (unsigned long)n, m_strLocale.c_str());
             }
         }
 #endif // __WXDEBUG__
@@ -2470,6 +2488,11 @@ bool wxLocale::AddCatalog(const wxChar *szDomain)
     // don't add it because it couldn't be loaded anyway
     delete pMsgCat;
 
+    // it's OK to not load English catalog, the texts are embedded in
+    // the program:
+    if (m_strShort.Mid(0, 2) == wxT("en"))
+        return TRUE;
+
     return FALSE;
   }
 }
@@ -3282,7 +3305,7 @@ void wxLocale::InitLanguagesDB()
    LNG(wxLANGUAGE_SWAHILI,                    "sw_KE", LANG_SWAHILI   , SUBLANG_DEFAULT                   , "Swahili")
    LNG(wxLANGUAGE_SWEDISH,                    "sv_SE", LANG_SWEDISH   , SUBLANG_SWEDISH                   , "Swedish")
    LNG(wxLANGUAGE_SWEDISH_FINLAND,            "sv_FI", LANG_SWEDISH   , SUBLANG_SWEDISH_FINLAND           , "Swedish (Finland)")
-   LNG(wxLANGUAGE_TAGALOG,                    "tl"   , 0              , 0                                 , "Tagalog")
+   LNG(wxLANGUAGE_TAGALOG,                    "tl_PH", 0              , 0                                 , "Tagalog")
    LNG(wxLANGUAGE_TAJIK,                      "tg"   , 0              , 0                                 , "Tajik")
    LNG(wxLANGUAGE_TAMIL,                      "ta"   , LANG_TAMIL     , SUBLANG_DEFAULT                   , "Tamil")
    LNG(wxLANGUAGE_TATAR,                      "tt"   , LANG_TATAR     , SUBLANG_DEFAULT                   , "Tatar")