Commit 74dc7ede authored by jungshik@google.com's avatar jungshik@google.com

Block Oriya locale on Windows XP.

Add IsLocaleSupportedByOS to l10n_util_{win,posix}.cc. Posix version always returns true. Windows blocks Oriya on Windows XP. 

BUG=7325
TEST=1. L10n*.GetAppLocale
     2. On Win XP, Oriya should not be shown in the UI language switch menu while it should be shown elsewhere.

Review URL: http://codereview.chromium.org/45054

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12557 0039d316-1c4b-4281-b951-d872f2087c98
parent 4e55fc89
...@@ -197,6 +197,7 @@ ...@@ -197,6 +197,7 @@
'common/jstemplate_builder.h', 'common/jstemplate_builder.h',
'common/l10n_util.cc', 'common/l10n_util.cc',
'common/l10n_util.h', 'common/l10n_util.h',
'common/l10n_util_posix.cc',
'common/l10n_util_win.cc', 'common/l10n_util_win.cc',
'common/l10n_util_win.h', 'common/l10n_util_win.h',
'common/libxml_utils.cc', 'common/libxml_utils.cc',
......
...@@ -154,6 +154,7 @@ input_files = ChromeFileList([ ...@@ -154,6 +154,7 @@ input_files = ChromeFileList([
'jstemplate_builder.h', 'jstemplate_builder.h',
'l10n_util.cc', 'l10n_util.cc',
'l10n_util.h', 'l10n_util.h',
'l10n_util_posix.cc',
'libxml_utils.cc', 'libxml_utils.cc',
'libxml_utils.h', 'libxml_utils.h',
'logging_chrome.cc', 'logging_chrome.cc',
...@@ -292,6 +293,7 @@ if not env.Bit('mac'): ...@@ -292,6 +293,7 @@ if not env.Bit('mac'):
if not env.Bit('posix'): if not env.Bit('posix'):
input_files.Remove( input_files.Remove(
'ipc_channel_posix.cc', 'ipc_channel_posix.cc',
'l10n_util_posix.cc',
) )
if env.Bit('windows'): if env.Bit('windows'):
......
...@@ -128,6 +128,9 @@ bool IsLocaleAvailable(const std::wstring& locale, ...@@ -128,6 +128,9 @@ bool IsLocaleAvailable(const std::wstring& locale,
if (test_locale != locale) if (test_locale != locale)
return false; return false;
if (!l10n_util::IsLocaleSupportedByOS(locale))
return false;
FilePath test_path = FilePath::FromWStringHack(locale_path) FilePath test_path = FilePath::FromWStringHack(locale_path)
.Append(FilePath::FromWStringHack(locale)) .Append(FilePath::FromWStringHack(locale))
.ReplaceExtension(kLocaleFileExtension); .ReplaceExtension(kLocaleFileExtension);
...@@ -641,6 +644,8 @@ const std::vector<std::string>& GetAvailableLocales() { ...@@ -641,6 +644,8 @@ const std::vector<std::string>& GetAvailableLocales() {
// Filter out the names that have aliases. // Filter out the names that have aliases.
if (IsDuplicateName(locale_name)) if (IsDuplicateName(locale_name))
continue; continue;
if (!IsLocaleSupportedByOS(ASCIIToWide(locale_name)))
continue;
// Normalize underscores to hyphens because that's what our locale files // Normalize underscores to hyphens because that's what our locale files
// use. // use.
std::replace(locale_name.begin(), locale_name.end(), '_', '-'); std::replace(locale_name.begin(), locale_name.end(), '_', '-');
......
...@@ -48,6 +48,11 @@ const char16 kPopDirectionalFormatting = 0x202C; ...@@ -48,6 +48,11 @@ const char16 kPopDirectionalFormatting = 0x202C;
// we fall back to en-us. // we fall back to en-us.
std::wstring GetApplicationLocale(const std::wstring& pref_locale); std::wstring GetApplicationLocale(const std::wstring& pref_locale);
// Given a locale code, return true if the OS is capable of supporting it.
// For instance, Oriya is not well supported on Windows XP and we return
// false for "or".
bool IsLocaleSupportedByOS(const std::wstring& locale);
// This method returns the Local Name of the Locale Code. For example, for // This method returns the Local Name of the Locale Code. For example, for
// |local_code_wstr| = "en-US", it returns "English (United States)". // |local_code_wstr| = "en-US", it returns "English (United States)".
// |app_locale_wstr| can be obtained in the UI thread - for example: // |app_locale_wstr| can be obtained in the UI thread - for example:
......
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/common/l10n_util.h"
namespace l10n_util {
// Return true blindly for now.
bool IsLocaleSupportedByOS(const std::wstring& locale) {
return true;
}
} // namespace l10n_util
...@@ -8,6 +8,9 @@ ...@@ -8,6 +8,9 @@
#include "base/file_util.h" #include "base/file_util.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/string_util.h" #include "base/string_util.h"
#if defined(OS_WIN)
#include "base/win_util.h"
#endif
#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_paths.h"
#include "chrome/common/l10n_util.h" #include "chrome/common/l10n_util.h"
#include "chrome/common/stl_util-inl.h" #include "chrome/common/stl_util-inl.h"
...@@ -114,6 +117,7 @@ TEST_F(L10nUtilTest, GetAppLocale) { ...@@ -114,6 +117,7 @@ TEST_F(L10nUtilTest, GetAppLocale) {
L"he", L"he",
L"fil", L"fil",
L"nb", L"nb",
L"or",
}; };
#if defined(OS_WIN) #if defined(OS_WIN)
...@@ -184,6 +188,21 @@ TEST_F(L10nUtilTest, GetAppLocale) { ...@@ -184,6 +188,21 @@ TEST_F(L10nUtilTest, GetAppLocale) {
SetICUDefaultLocale(L"he"); SetICUDefaultLocale(L"he");
EXPECT_EQ(L"en-US", l10n_util::GetApplicationLocale(L"en")); EXPECT_EQ(L"en-US", l10n_util::GetApplicationLocale(L"en"));
#if defined(OS_WIN)
// Oriya should be blocked unless OS is Vista or newer.
if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) {
SetICUDefaultLocale(L"or");
EXPECT_EQ(L"en-US", l10n_util::GetApplicationLocale(L""));
SetICUDefaultLocale(L"en-GB");
EXPECT_EQ(L"en-GB", l10n_util::GetApplicationLocale(L"or"));
} else {
SetICUDefaultLocale(L"or");
EXPECT_EQ(L"or", l10n_util::GetApplicationLocale(L""));
SetICUDefaultLocale(L"en-GB");
EXPECT_EQ(L"or", l10n_util::GetApplicationLocale(L"or"));
}
#endif
// Clean up. // Clean up.
PathService::Override(chrome::DIR_LOCALES, orig_locale_dir); PathService::Override(chrome::DIR_LOCALES, orig_locale_dir);
file_util::Delete(new_locale_dir, true); file_util::Delete(new_locale_dir, true);
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#include "chrome/common/l10n_util.h" #include "chrome/common/l10n_util.h"
#include "chrome/common/l10n_util_win.h" #include "chrome/common/l10n_util_win.h"
#include "base/win_util.h"
namespace l10n_util { namespace l10n_util {
int GetExtendedStyles() { int GetExtendedStyles() {
...@@ -31,4 +33,10 @@ void HWNDSetRTLLayout(HWND hwnd) { ...@@ -31,4 +33,10 @@ void HWNDSetRTLLayout(HWND hwnd) {
} }
} }
bool IsLocaleSupportedByOS(const std::wstring& locale) {
// Block Oriya on Windows XP.
return !(LowerCaseEqualsASCII(locale, "or") &&
win_util::GetWinVersion() < win_util::WINVERSION_VISTA);
}
} // namespace l10n_util } // namespace l10n_util
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment