Changeset 128582 in webkit


Ignore:
Timestamp:
Sep 14, 2012 3:59:57 AM (12 years ago)
Author:
keishi@webkit.org
Message:

LocaleMac should fallback to defaultLanguage for an invalid locale
https://bugs.webkit.org/show_bug.cgi?id=96744

Reviewed by Kent Tamura.

Source/WebCore:

There is no way to tell if a locale identifier is valid or not in Cocoa
so we look if we have a matching language in the list of
ISOLanguageCodes given by NSLocale.

Covered in LocaleMacTest.invalidLocale.

  • platform/text/mac/LocaleMac.mm:

(WebCore):
(WebCore::LocaleMac::LocaleMac):
(WebCore::LocaleMac::create):

Source/WebKit/chromium:

  • tests/LocaleMacTest.cpp:

(TEST_F):

Location:
trunk/Source
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r128580 r128582  
     12012-09-14  Keishi Hattori  <keishi@webkit.org>
     2
     3        LocaleMac should fallback to defaultLanguage for an invalid locale
     4        https://bugs.webkit.org/show_bug.cgi?id=96744
     5
     6        Reviewed by Kent Tamura.
     7
     8        There is no way to tell if a locale identifier is valid or not in Cocoa
     9        so we look if we have a matching language in the list of
     10        ISOLanguageCodes given by NSLocale.
     11
     12        Covered in LocaleMacTest.invalidLocale.
     13
     14        * platform/text/mac/LocaleMac.mm:
     15        (WebCore):
     16        (WebCore::LocaleMac::LocaleMac):
     17        (WebCore::LocaleMac::create):
     18
    1192012-09-14  Vsevolod Vlasov  <vsevik@chromium.org>
    220
  • trunk/Source/WebCore/platform/text/mac/LocaleMac.mm

    r128156 r128582  
    7272    , m_didInitializeNumberData(false)
    7373{
     74    NSArray* availableLanguages = [NSLocale ISOLanguageCodes];
     75    // NSLocale returns a lower case NSLocaleLanguageCode so we don't have care about case.
     76    NSString* language = [m_locale.get() objectForKey:NSLocaleLanguageCode];
     77    if ([availableLanguages indexOfObject:language] == NSNotFound)
     78        m_locale = [[NSLocale alloc] initWithLocaleIdentifier:defaultLanguage()];
    7479}
    7580
  • trunk/Source/WebKit/chromium/ChangeLog

    r128548 r128582  
     12012-09-14  Keishi Hattori  <keishi@webkit.org>
     2
     3        LocaleMac should fallback to defaultLanguage for an invalid locale
     4        https://bugs.webkit.org/show_bug.cgi?id=96744
     5
     6        Reviewed by Kent Tamura.
     7
     8        * tests/LocaleMacTest.cpp:
     9        (TEST_F):
     10
    1112012-09-13  Sheriff Bot  <webkit.review.bot@gmail.com>
    212
  • trunk/Source/WebKit/chromium/tests/LocaleMacTest.cpp

    r128156 r128582  
    222222#endif
    223223
     224TEST_F(LocaleMacTest, invalidLocale)
     225{
     226    EXPECT_STREQ(monthLabel("en_US", January).utf8().data(), monthLabel("foo", January).utf8().data());
     227    EXPECT_STREQ(decimalSeparator("en_US").utf8().data(), decimalSeparator("foo").utf8().data());
     228}
     229
    224230static void testNumberIsReversible(const AtomicString& localeString, const char* original, const char* shouldHave = 0)
    225231{
Note: See TracChangeset for help on using the changeset viewer.