[haiku-webkit-commits] r492 - in webkit/trunk/WebCore: . platform/haiku platform/text/haiku

  • From: webkit@xxxxxxxxxxxxxxx
  • To: haiku-webkit-commits@xxxxxxxxxxxxx
  • Date: Tue, 11 May 2010 12:10:37 +0000

Author: stippi
Date: Tue May 11 12:10:36 2010
New Revision: 492
URL: http://mmlr.dyndns.org/changeset/492

Log:
* Moved WebCore::defaultLanguage() into it's own file Language.cpp, as done for
  more recent ports.
* Updated to new BLanguage API.
* Make sure to replace _ with - in the language identifier (as in Qt port).
* Use defaultLanguage() in TextBreakIteratorInternalICUHaiku.cpp.

Added:
   webkit/trunk/WebCore/platform/haiku/Language.cpp
Modified:
   webkit/trunk/WebCore/Jamfile
   webkit/trunk/WebCore/platform/haiku/LocalizedStringsHaiku.cpp
   
webkit/trunk/WebCore/platform/text/haiku/TextBreakIteratorInternalICUHaiku.cpp

Modified: webkit/trunk/WebCore/Jamfile
==============================================================================
--- webkit/trunk/WebCore/Jamfile        Tue May 11 12:07:59 2010        (r491)
+++ webkit/trunk/WebCore/Jamfile        Tue May 11 12:10:36 2010        (r492)
@@ -1230,6 +1230,7 @@
         FileChooserHaiku.cpp
         FileSystemHaiku.cpp
         KURLHaiku.cpp
+        Language.cpp
         LocalizedStringsHaiku.cpp
         LoggingHaiku.cpp
         MIMETypeRegistryHaiku.cpp

Added: webkit/trunk/WebCore/platform/haiku/Language.cpp
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ webkit/trunk/WebCore/platform/haiku/Language.cpp    Tue May 11 12:10:36 
2010        (r492)
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2010 Stephan Aßmus <superstippi@xxxxxx>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "Language.h"
+
+#include "PlatformString.h"
+#include <Locale.h>
+#include <LocaleRoster.h>
+#include <stdio.h>
+
+namespace WebCore {
+
+String defaultLanguage()
+{
+    static BString local;
+    static bool initialized = false;
+    if (!initialized) {
+       initialized = true;
+       BLanguage* language;
+        if (be_locale_roster->GetDefaultLanguage(&language) == B_OK)
+            local = language->ID();
+        else
+            local = "en_US";
+           local.ReplaceAll('_', '-');
+    }
+    return local;
+}
+
+}

Modified: webkit/trunk/WebCore/platform/haiku/LocalizedStringsHaiku.cpp
==============================================================================
--- webkit/trunk/WebCore/platform/haiku/LocalizedStringsHaiku.cpp       Tue May 
11 12:07:59 2010        (r491)
+++ webkit/trunk/WebCore/platform/haiku/LocalizedStringsHaiku.cpp       Tue May 
11 12:10:36 2010        (r492)
@@ -48,11 +48,6 @@
     return "Reset";
 }
 
-String defaultLanguage()
-{
-    return "en";
-}
-
 String searchableIndexIntroduction()
 {
     return "Searchable Index";

Modified: 
webkit/trunk/WebCore/platform/text/haiku/TextBreakIteratorInternalICUHaiku.cpp
==============================================================================
--- 
webkit/trunk/WebCore/platform/text/haiku/TextBreakIteratorInternalICUHaiku.cpp  
    Tue May 11 12:07:59 2010        (r491)
+++ 
webkit/trunk/WebCore/platform/text/haiku/TextBreakIteratorInternalICUHaiku.cpp  
    Tue May 11 12:10:36 2010        (r492)
@@ -21,34 +21,20 @@
 #include "config.h"
 #include "TextBreakIteratorInternalICU.h"
 
-#include <Locale.h>
-#include <LocaleRoster.h>
+#include "Language.h"
+#include "PlatformString.h"
+#include <wtf/text/CString.h>
 
 namespace WebCore {
 
-static const char* currentLocaleID()
-{
-    static BString local;
-    static bool initialized = false;
-    if (!initialized) {
-       initialized = true;
-       BLanguage* language;
-        if (be_locale_roster->GetDefaultLanguage(&language) == B_OK)
-            local = language->Code();
-        else
-            local = "en_US";
-    }
-    return local.String();
-}
-
 const char* currentSearchLocaleID()
 {
-    return currentLocaleID();
+    return defaultLanguage().utf8().data();
 }
 
 const char* currentTextBreakLocaleID()
 {
-    return currentLocaleID();
+    return defaultLanguage().utf8().data();
 }
 
 } // namespace WebCore

Other related posts:

  • » [haiku-webkit-commits] r492 - in webkit/trunk/WebCore: . platform/haiku platform/text/haiku - webkit