]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/intl.cpp
Eliminate a warning
[wxWidgets.git] / src / common / intl.cpp
index d1bff69bf727415e374e16121de46762528aad5b..1fd767a47ffdd7101a7602d391ad0ec346d45460 100644 (file)
 #include "wx/hashset.h"
 #include "wx/filesys.h"
 
-#if defined(__WXMAC__)
-    #include "wx/mac/private.h"  // includes mac headers
-#endif
-
 #if defined(__DARWIN__)
-    #include "wx/mac/corefoundation/cfref.h"
+    #include "wx/osx/core/cfref.h"
     #include <CoreFoundation/CFLocale.h>
-    #include "wx/mac/corefoundation/cfstring.h"
+    #include "wx/osx/core/cfstring.h"
 #endif
 
 // ----------------------------------------------------------------------------
@@ -240,7 +236,7 @@ wxPluralFormsScanner::wxPluralFormsScanner(const char* s) : m_s(s)
 bool wxPluralFormsScanner::nextToken()
 {
     wxPluralFormsToken::Type type = wxPluralFormsToken::T_ERROR;
-    while (isspace(*m_s))
+    while (isspace((unsigned char) *m_s))
     {
         ++m_s;
     }
@@ -248,20 +244,20 @@ bool wxPluralFormsScanner::nextToken()
     {
         type = wxPluralFormsToken::T_EOF;
     }
-    else if (isdigit(*m_s))
+    else if (isdigit((unsigned char) *m_s))
     {
         wxPluralFormsToken::Number number = *m_s++ - '0';
-        while (isdigit(*m_s))
+        while (isdigit((unsigned char) *m_s))
         {
             number = number * 10 + (*m_s++ - '0');
         }
         m_token.setNumber(number);
         type = wxPluralFormsToken::T_NUMBER;
     }
-    else if (isalpha(*m_s))
+    else if (isalpha((unsigned char) *m_s))
     {
         const char* begin = m_s++;
-        while (isalnum(*m_s))
+        while (isalnum((unsigned char) *m_s))
         {
             ++m_s;
         }
@@ -1016,6 +1012,8 @@ static wxArrayString gs_searchPrefixes;
 // wxLanguageInfo
 // ----------------------------------------------------------------------------
 
+#ifdef __WXMSW__
+
 // helper used by wxLanguageInfo::GetLocaleName() and elsewhere to determine
 // whether the locale is Unicode-only (it is if this function returns empty
 // string)
@@ -1035,8 +1033,6 @@ static wxString wxGetANSICodePageForLocale(LCID lcid)
     return cp;
 }
 
-#ifdef __WXMSW__
-
 wxUint32 wxLanguageInfo::GetLCID() const
 {
     return MAKELCID(MAKELANGID(WinLang, WinSublang), SORT_DEFAULT);
@@ -1267,6 +1263,8 @@ bool wxMsgCatalogFile::Load(const wxString& szDirPrefix, const wxString& szName,
   // read the whole file in memory
   if ( fileMsg.Read(m_data.GetWriteBuf(nSize), nSize) != lenFile )
     return false;
+
+  m_data.UngetWriteBuf(nSize);
 #endif // wxUSE_FILESYSTEM/!wxUSE_FILESYSTEM
 
 
@@ -1842,11 +1840,11 @@ bool wxLocale::Init(int language, int flags)
         }
         else // language supported by Windows
         {
-            const wxUint32 lcid = info->GetLCID();
-
             // Windows CE doesn't have SetThreadLocale() and there doesn't seem
             // to be any equivalent
 #ifndef __WXWINCE__
+            const wxUint32 lcid = info->GetLCID();
+
             // change locale used by Windows functions
             ::SetThreadLocale(lcid);
 #endif
@@ -1996,8 +1994,13 @@ void wxLocale::AddCatalogLookupPathPrefix(const wxString& prefix)
     // for now we don't use the encoding, although we probably should (doing
     // translations of the msg catalogs on the fly as required) (TODO)
     //
-    // we don't use the modifiers neither but we probably should translate
-    // "euro" into iso885915
+    // we need the modified for languages like Valencian: ca_ES@valencia
+    // though, remember it
+    wxString modifier;
+    size_t posModifier = langFull.find_first_of(wxS("@"));
+    if ( posModifier != wxString::npos )
+        modifier = langFull.Mid(posModifier);
+
     size_t posEndLang = langFull.find_first_of(wxS("@."));
     if ( posEndLang != wxString::npos )
     {
@@ -2043,11 +2046,24 @@ void wxLocale::AddCatalogLookupPathPrefix(const wxString& prefix)
         }
 
         // 1. Try to find the language either as is:
-        for ( i = 0; i < count; i++ )
+        // a) With modifier if set
+        if ( !modifier.empty() )
         {
-            if ( ms_languagesDB->Item(i).CanonicalName == langFull )
+            wxString langFullWithModifier = langFull + modifier;
+            for ( i = 0; i < count; i++ )
             {
-                break;
+                if ( ms_languagesDB->Item(i).CanonicalName == langFullWithModifier )
+                    break;
+            }
+        }
+
+        // b) Without modifier
+        if ( modifier.empty() || i == count )
+        {
+            for ( i = 0; i < count; i++ )
+            {
+                if ( ms_languagesDB->Item(i).CanonicalName == langFull )
+                    break;
             }
         }
 
@@ -2219,7 +2235,7 @@ wxFontEncoding wxLocale::GetSystemEncoding()
         return wxFONTENCODING_CP950;
     }
 #elif defined(__WXMAC__)
-    TextEncoding encoding = 0 ;
+    CFStringEncoding encoding = 0 ;
     encoding = CFStringGetSystemEncoding() ;
     return wxMacGetFontEncFromSystemEnc( encoding ) ;
 #elif defined(__UNIX_LIKE__) && wxUSE_FONTMAP
@@ -2659,23 +2675,24 @@ wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory WXUNUSED(cat))
 
     wxCFRef<CFLocaleRef> userLocaleRef(userLocaleRefRaw);
 
-    CFTypeRef cfstr;
+    CFStringRef cfstr = 0;
     switch ( index )
     {
         case wxLOCALE_THOUSANDS_SEP:
-            cfstr = CFLocaleGetValue(userLocaleRef, kCFLocaleGroupingSeparator);
+            cfstr = (CFStringRef) CFLocaleGetValue(userLocaleRef, kCFLocaleGroupingSeparator);
             break;
 
         case wxLOCALE_DECIMAL_POINT:
-            cfstr = CFLocaleGetValue(userLocaleRef, kCFLocaleDecimalSeparator);
+            cfstr = (CFStringRef) CFLocaleGetValue(userLocaleRef, kCFLocaleDecimalSeparator);
             break;
 
         default:
             wxFAIL_MSG( "Unknown locale info" );
+            cfstr = CFSTR("");
+            break;
     }
 
-    wxCFStringRef
-        str(CFStringCreateCopy(NULL, static_cast<CFStringRef>(cfstr)));
+    wxCFStringRef str(wxCFRetain(cfstr));
     return str.AsString();
 }
 
@@ -2938,6 +2955,9 @@ IMPLEMENT_DYNAMIC_CLASS(wxLocaleModule, wxModule)
 #ifndef LANG_RUSSIAN
 #define LANG_RUSSIAN (0)
 #endif
+#ifndef LANG_SAMI
+#define LANG_SAMI (0)
+#endif
 #ifndef LANG_SANSKRIT
 #define LANG_SANSKRIT (0)
 #endif
@@ -3357,7 +3377,7 @@ void wxLocale::InitLanguagesDB()
    LNG(wxLANGUAGE_FRENCH_SWISS,               "fr_CH", LANG_FRENCH    , SUBLANG_FRENCH_SWISS              , wxLayout_LeftToRight, "French (Swiss)")
    LNG(wxLANGUAGE_FRISIAN,                    "fy"   , 0              , 0                                 , wxLayout_LeftToRight, "Frisian")
    LNG(wxLANGUAGE_GALICIAN,                   "gl_ES", 0              , 0                                 , wxLayout_LeftToRight, "Galician")
-   LNG(wxLANGUAGE_GEORGIAN,                   "ka"   , LANG_GEORGIAN  , SUBLANG_DEFAULT                   , wxLayout_LeftToRight, "Georgian")
+   LNG(wxLANGUAGE_GEORGIAN,                   "ka_GE", LANG_GEORGIAN  , SUBLANG_DEFAULT                   , wxLayout_LeftToRight, "Georgian")
    LNG(wxLANGUAGE_GERMAN,                     "de_DE", LANG_GERMAN    , SUBLANG_GERMAN                    , wxLayout_LeftToRight, "German")
    LNG(wxLANGUAGE_GERMAN_AUSTRIAN,            "de_AT", LANG_GERMAN    , SUBLANG_GERMAN_AUSTRIAN           , wxLayout_LeftToRight, "German (Austrian)")
    LNG(wxLANGUAGE_GERMAN_BELGIUM,             "de_BE", 0              , 0                                 , wxLayout_LeftToRight, "German (Belgium)")
@@ -3393,7 +3413,7 @@ void wxLocale::InitLanguagesDB()
    LNG(wxLANGUAGE_KIRUNDI,                    "rn"   , 0              , 0                                 , wxLayout_LeftToRight, "Kirundi")
    LNG(wxLANGUAGE_KONKANI,                    ""     , LANG_KONKANI   , SUBLANG_DEFAULT                   , wxLayout_LeftToRight, "Konkani")
    LNG(wxLANGUAGE_KOREAN,                     "ko_KR", LANG_KOREAN    , SUBLANG_KOREAN                    , wxLayout_LeftToRight, "Korean")
-   LNG(wxLANGUAGE_KURDISH,                    "ku"   , 0              , 0                                 , wxLayout_LeftToRight, "Kurdish")
+   LNG(wxLANGUAGE_KURDISH,                    "ku_TR", 0              , 0                                 , wxLayout_LeftToRight, "Kurdish")
    LNG(wxLANGUAGE_LAOTHIAN,                   "lo"   , 0              , 0                                 , wxLayout_LeftToRight, "Laothian")
    LNG(wxLANGUAGE_LATIN,                      "la"   , 0              , 0                                 , wxLayout_LeftToRight, "Latin")
    LNG(wxLANGUAGE_LATVIAN,                    "lv_LV", LANG_LATVIAN   , SUBLANG_DEFAULT                   , wxLayout_LeftToRight, "Latvian")
@@ -3412,7 +3432,7 @@ void wxLocale::InitLanguagesDB()
    LNG(wxLANGUAGE_MOLDAVIAN,                  "mo"   , 0              , 0                                 , wxLayout_LeftToRight, "Moldavian")
    LNG(wxLANGUAGE_MONGOLIAN,                  "mn"   , 0              , 0                                 , wxLayout_LeftToRight, "Mongolian")
    LNG(wxLANGUAGE_NAURU,                      "na"   , 0              , 0                                 , wxLayout_LeftToRight, "Nauru")
-   LNG(wxLANGUAGE_NEPALI,                     "ne"   , LANG_NEPALI    , SUBLANG_DEFAULT                   , wxLayout_LeftToRight, "Nepali")
+   LNG(wxLANGUAGE_NEPALI,                     "ne_NP", LANG_NEPALI    , SUBLANG_DEFAULT                   , wxLayout_LeftToRight, "Nepali")
    LNG(wxLANGUAGE_NEPALI_INDIA,               "ne_IN", LANG_NEPALI    , SUBLANG_NEPALI_INDIA              , wxLayout_LeftToRight, "Nepali (India)")
    LNG(wxLANGUAGE_NORWEGIAN_BOKMAL,           "nb_NO", LANG_NORWEGIAN , SUBLANG_NORWEGIAN_BOKMAL          , wxLayout_LeftToRight, "Norwegian (Bokmal)")
    LNG(wxLANGUAGE_NORWEGIAN_NYNORSK,          "nn_NO", LANG_NORWEGIAN , SUBLANG_NORWEGIAN_NYNORSK         , wxLayout_LeftToRight, "Norwegian (Nynorsk)")
@@ -3429,12 +3449,16 @@ void wxLocale::InitLanguagesDB()
    LNG(wxLANGUAGE_ROMANIAN,                   "ro_RO", LANG_ROMANIAN  , SUBLANG_DEFAULT                   , wxLayout_LeftToRight, "Romanian")
    LNG(wxLANGUAGE_RUSSIAN,                    "ru_RU", LANG_RUSSIAN   , SUBLANG_DEFAULT                   , wxLayout_LeftToRight, "Russian")
    LNG(wxLANGUAGE_RUSSIAN_UKRAINE,            "ru_UA", 0              , 0                                 , wxLayout_LeftToRight, "Russian (Ukraine)")
+   LNG(wxLANGUAGE_SAMI,                       "se_NO", LANG_SAMI      , SUBLANG_DEFAULT                   , wxLayout_LeftToRight, "Northern Sami")
    LNG(wxLANGUAGE_SAMOAN,                     "sm"   , 0              , 0                                 , wxLayout_LeftToRight, "Samoan")
    LNG(wxLANGUAGE_SANGHO,                     "sg"   , 0              , 0                                 , wxLayout_LeftToRight, "Sangho")
    LNG(wxLANGUAGE_SANSKRIT,                   "sa"   , LANG_SANSKRIT  , SUBLANG_DEFAULT                   , wxLayout_LeftToRight, "Sanskrit")
    LNG(wxLANGUAGE_SCOTS_GAELIC,               "gd"   , 0              , 0                                 , wxLayout_LeftToRight, "Scots Gaelic")
+   LNG(wxLANGUAGE_SERBIAN,                    "sr_SR", LANG_SERBIAN   , SUBLANG_DEFAULT                   , wxLayout_LeftToRight, "Serbian")
+   LNG(wxLANGUAGE_SERBIAN_CYRILLIC,           "sr_SR", LANG_SERBIAN   , SUBLANG_SERBIAN_CYRILLIC          , wxLayout_LeftToRight, "Serbian (Cyrillic)")
+   LNG(wxLANGUAGE_SERBIAN_LATIN,              "sr_SR@latin", LANG_SERBIAN   , SUBLANG_SERBIAN_LATIN             , wxLayout_LeftToRight, "Serbian (Latin)")
    LNG(wxLANGUAGE_SERBIAN_CYRILLIC,           "sr_YU", LANG_SERBIAN   , SUBLANG_SERBIAN_CYRILLIC          , wxLayout_LeftToRight, "Serbian (Cyrillic)")
-   LNG(wxLANGUAGE_SERBIAN_LATIN,              "sr_YU", LANG_SERBIAN   , SUBLANG_SERBIAN_LATIN             , wxLayout_LeftToRight, "Serbian (Latin)")
+   LNG(wxLANGUAGE_SERBIAN_LATIN,              "sr_YU@latin", LANG_SERBIAN   , SUBLANG_SERBIAN_LATIN             , wxLayout_LeftToRight, "Serbian (Latin)")
    LNG(wxLANGUAGE_SERBO_CROATIAN,             "sh"   , 0              , 0                                 , wxLayout_LeftToRight, "Serbo-Croatian")
    LNG(wxLANGUAGE_SESOTHO,                    "st"   , 0              , 0                                 , wxLayout_LeftToRight, "Sesotho")
    LNG(wxLANGUAGE_SETSWANA,                   "tn"   , 0              , 0                                 , wxLayout_LeftToRight, "Setswana")
@@ -3491,6 +3515,7 @@ void wxLocale::InitLanguagesDB()
    LNG(wxLANGUAGE_UZBEK,                      "uz"   , LANG_UZBEK     , SUBLANG_DEFAULT                   , wxLayout_LeftToRight, "Uzbek")
    LNG(wxLANGUAGE_UZBEK_CYRILLIC,             "uz"   , LANG_UZBEK     , SUBLANG_UZBEK_CYRILLIC            , wxLayout_LeftToRight, "Uzbek (Cyrillic)")
    LNG(wxLANGUAGE_UZBEK_LATIN,                "uz"   , LANG_UZBEK     , SUBLANG_UZBEK_LATIN               , wxLayout_LeftToRight, "Uzbek (Latin)")
+   LNG(wxLANGUAGE_VALENCIAN,                  "ca_ES@valencia", 0     , 0                                 , wxLayout_LeftToRight, "Valencian")
    LNG(wxLANGUAGE_VIETNAMESE,                 "vi_VN", LANG_VIETNAMESE, SUBLANG_DEFAULT                   , wxLayout_LeftToRight, "Vietnamese")
    LNG(wxLANGUAGE_VOLAPUK,                    "vo"   , 0              , 0                                 , wxLayout_LeftToRight, "Volapuk")
    LNG(wxLANGUAGE_WELSH,                      "cy"   , 0              , 0                                 , wxLayout_LeftToRight, "Welsh")