]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/intl.cpp
compilation fix for systems with XtIMSignal
[wxWidgets.git] / src / common / intl.cpp
index ad9d29f1610cb81ac5589c460ddebebf78f0b0ce..1f360d9a5a4d7c3c966ea1c6cd52ae6a7bb2d753 100644 (file)
 #endif
 
 #include "wx/file.h"
+#include "wx/filename.h"
 #include "wx/tokenzr.h"
 #include "wx/module.h"
 #include "wx/fontmap.h"
 #include "wx/encconv.h"
 #include "wx/hashmap.h"
 #include "wx/ptr_scpd.h"
+#include "wx/app.h"
+#include "wx/apptrait.h"
 
 #if defined(__WXMAC__)
   #include  "wx/mac/private.h"  // includes mac headers
@@ -99,9 +102,6 @@ typedef wxUint32 size_t32;
 const size_t32 MSGCATALOG_MAGIC    = 0x950412de;
 const size_t32 MSGCATALOG_MAGIC_SW = 0xde120495;
 
-// extension of ".mo" files
-#define MSGCATALOG_EXTENSION  _T(".mo")
-
 // the constants describing the format of lang_LANG locale string
 static const size_t LEN_LANG = 2;
 static const size_t LEN_SUBLANG = 2;
@@ -498,7 +498,6 @@ public:
     ~wxPluralFormsCalculator() {}
 
     void  init(wxPluralFormsToken::Number nplurals, wxPluralFormsNode* plural);
-    wxString getString() const;
 
 private:
     wxPluralFormsToken::Number m_nplurals;
@@ -1074,16 +1073,14 @@ static wxString GetFullSearchPath(const wxChar *lang)
 }
 
 // open disk file and read in it's contents
-bool wxMsgCatalogFile::Load(const wxChar *szDirPrefix, const wxChar *szName0,
+bool wxMsgCatalogFile::Load(const wxChar *szDirPrefix, const wxChar *szName,
                             wxPluralFormsCalculatorPtr& rPluralFormsCalculator)
 {
-   /* We need to handle locales like  de_AT.iso-8859-1
-      For this we first chop off the .CHARSET specifier and ignore it.
-      FIXME: UNICODE SUPPORT: must use CHARSET specifier!
-   */
-   wxString szName = szName0;
-   if(szName.Find(wxT('.')) != wxNOT_FOUND) // contains a dot
-      szName = szName.Left(szName.Find(wxT('.')));
+  /*
+     We need to handle locales like  de_AT.iso-8859-1
+     For this we first chop off the .CHARSET specifier and ignore it.
+     FIXME: UNICODE SUPPORT: must use CHARSET specifier!
+  */
 
   wxString searchPath = GetFullSearchPath(szDirPrefix);
   const wxChar *sublocale = wxStrchr(szDirPrefix, wxT('_'));
@@ -1097,9 +1094,6 @@ bool wxMsgCatalogFile::Load(const wxChar *szDirPrefix, const wxChar *szName0,
                  << wxPATH_SEP;
   }
 
-  wxString strFile = szName;
-  strFile += MSGCATALOG_EXTENSION;
-
   // don't give translation errors here because the wxstd catalog might
   // not yet be loaded (and it's normal)
   //
@@ -1107,17 +1101,18 @@ bool wxMsgCatalogFile::Load(const wxChar *szDirPrefix, const wxChar *szName0,
 
   NoTransErr noTransErr;
   wxLogVerbose(_("looking for catalog '%s' in path '%s'."),
-               szName.c_str(), searchPath.c_str());
+               szName, searchPath.c_str());
 
+  wxFileName fn(szName);
+  fn.SetExt(_T("mo"));
   wxString strFullName;
-  if ( !wxFindFileInPath(&strFullName, searchPath, strFile) ) {
-    wxLogVerbose(_("catalog file for domain '%s' not found."), szName.c_str());
+  if ( !wxFindFileInPath(&strFullName, searchPath, fn.GetFullPath()) ) {
+    wxLogVerbose(_("catalog file for domain '%s' not found."), szName);
     return false;
   }
 
   // open file
-  wxLogVerbose(_("using catalog '%s' from '%s'."),
-             szName.c_str(), strFullName.c_str());
+  wxLogVerbose(_("using catalog '%s' from '%s'."), szName, strFullName.c_str());
 
   wxFile fileMsg(strFullName);
   if ( !fileMsg.IsOpened() )
@@ -1243,7 +1238,7 @@ void wxMsgCatalogFile::FillHash(wxMessagesHash& hash,
     if ( convertEncoding )
     {
         wxFontEncoding targetEnc = wxFONTENCODING_SYSTEM;
-        wxFontEncoding enc = wxFontMapper::Get()->CharsetToEncoding(m_charset, false);
+        wxFontEncoding enc = wxFontMapperBase::Get()->CharsetToEncoding(m_charset, false);
         if ( enc == wxFONTENCODING_SYSTEM )
         {
             convertEncoding = false; // unknown encoding
@@ -1477,8 +1472,19 @@ bool wxLocale::Init(const wxChar *szName,
   m_pMsgCat = NULL;
   bool bOk = true;
   if ( bLoadDefault )
+  {
     bOk = AddCatalog(wxT("wxstd"));
 
+    // there may be a catalog with toolkit specific overrides, it is not
+    // an error if this does not exist
+    if ( bOk && wxTheApp )
+    {
+      wxAppTraits *traits = wxTheApp->GetTraits();
+      if (traits)
+        AddCatalog(traits->GetToolkitInfo().name.BeforeFirst(wxT('/')).MakeLower());
+    }
+  }
+
   return bOk;
 }
 
@@ -1798,7 +1804,7 @@ void wxLocale::AddCatalogLookupPathPrefix(const wxString& prefix)
          (langFull.Len() == LEN_FULL && langFull[LEN_LANG] == wxT('_')) )
     {
         // 0. Make sure the lang is according to latest ISO 639
-        //    (this is neccessary because glibc uses iw and in instead
+        //    (this is necessary because glibc uses iw and in instead
         //    of he and id respectively).
 
         // the language itself (second part is the dialect/sublang)
@@ -2284,12 +2290,17 @@ wxFontEncoding wxLocale::GetSystemEncoding()
 #if defined(__WIN32__) && !defined(__WXMICROWIN__)
     UINT codepage = ::GetACP();
 
-    // wxWidgets only knows about CP1250-1257, 932, 936, 949, 950
+    // wxWidgets only knows about CP1250-1257, 874, 932, 936, 949, 950
     if ( codepage >= 1250 && codepage <= 1257 )
     {
         return (wxFontEncoding)(wxFONTENCODING_CP1250 + codepage - 1250);
     }
 
+    if ( codepage == 874 )
+    {
+        return wxFONTENCODING_CP874;
+    }
+
     if ( codepage == 932 )
     {
         return wxFONTENCODING_CP932;
@@ -2321,7 +2332,7 @@ wxFontEncoding wxLocale::GetSystemEncoding()
     wxString encname = GetSystemEncodingName();
     if ( !encname.empty() )
     {
-        wxFontEncoding enc = wxFontMapper::Get()->
+        wxFontEncoding enc = (wxFontMapperBase::Get())->
             CharsetToEncoding(encname, false /* not interactive */);
 
         // on some modern Linux systems (RedHat 8) the default system locale