summaryrefslogtreecommitdiffstats
path: root/chrome/installer/util
diff options
context:
space:
mode:
authorgrt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-01 16:15:52 +0000
committergrt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-01 16:15:52 +0000
commit45132c563e520bd734f2e4bb4f627017de2d2775 (patch)
tree36a9905e60231d6ce9cf0f582ea33cdf842d6f24 /chrome/installer/util
parent6cef305bfaada60cecd6aea1d1a676ec60c01d4a (diff)
downloadchromium_src-45132c563e520bd734f2e4bb4f627017de2d2775.zip
chromium_src-45132c563e520bd734f2e4bb4f627017de2d2775.tar.gz
chromium_src-45132c563e520bd734f2e4bb4f627017de2d2775.tar.bz2
Add some language aliases to track changes to base/ui/l10n_util.cc.
Alias Australian, Canadian, New Zealand and South African English to British English, and explicitly alias "es-es" to "es" so it doesn't become "es-419" by way of the wildcard match. BUG=none TEST=covered by installer_util_unittests.exe --gtest_filter=*LanguageSelectorAliasTest* Review URL: http://codereview.chromium.org/8488006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112471 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer/util')
-rw-r--r--chrome/installer/util/language_selector.cc13
-rw-r--r--chrome/installer/util/language_selector_unittest.cc65
2 files changed, 72 insertions, 6 deletions
diff --git a/chrome/installer/util/language_selector.cc b/chrome/installer/util/language_selector.cc
index d47998f..9d98674 100644
--- a/chrome/installer/util/language_selector.cc
+++ b/chrome/installer/util/language_selector.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
//
@@ -48,6 +48,13 @@ const LangToOffset kLanguageOffsetPairs[] = {
// for which translations are available.
const LangToOffset kLanguageToOffsetExceptions[] = {
#if defined(GOOGLE_CHROME_BUILD)
+ // Alias some English variants to British English (all others wildcard to US).
+ { L"en-au", IDS_L10N_OFFSET_EN_GB },
+ { L"en-ca", IDS_L10N_OFFSET_EN_GB },
+ { L"en-nz", IDS_L10N_OFFSET_EN_GB },
+ { L"en-za", IDS_L10N_OFFSET_EN_GB },
+ // Alias es-es to es (all others wildcard to es-419).
+ { L"es-es", IDS_L10N_OFFSET_ES },
// Google web properties use iw for he. Handle both just to be safe.
{ L"he", IDS_L10N_OFFSET_IW },
// Google web properties use no for nb. Handle both just to be safe.
@@ -61,10 +68,8 @@ const LangToOffset kLanguageToOffsetExceptions[] = {
// Vista+ aliases for Chinese w/ script subtag.
{ L"zh-hans", IDS_L10N_OFFSET_ZH_CN },
{ L"zh-hant", IDS_L10N_OFFSET_ZH_TW },
- // Alias Macau and Hong Kong to Taiwan.
+ // Alias Hong Kong and Macau to Taiwan.
{ L"zh-hk", IDS_L10N_OFFSET_ZH_TW },
- { L"zh-mk", IDS_L10N_OFFSET_ZH_TW },
- // Windows uses "mo" for Macau.
{ L"zh-mo", IDS_L10N_OFFSET_ZH_TW },
// Although the wildcard entry for zh would result in this, alias zh-sg so
// that it will win if it precedes another valid tag in a list of candidates.
diff --git a/chrome/installer/util/language_selector_unittest.cc b/chrome/installer/util/language_selector_unittest.cc
index 1e5bc00..63be55a 100644
--- a/chrome/installer/util/language_selector_unittest.cc
+++ b/chrome/installer/util/language_selector_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -26,7 +26,7 @@ const wchar_t* const kExactMatchCandidates[] = {
const wchar_t* const kAliasMatchCandidates[] = {
#if defined(GOOGLE_CHROME_BUILD)
L"he", L"nb", L"tl", L"zh-chs", L"zh-cht", L"zh-hans", L"zh-hant", L"zh-hk",
- L"zh-mk", L"zh-mo"
+ L"zh-mo"
#else
// There is only en-us.
L"en-us"
@@ -126,3 +126,64 @@ INSTANTIATE_TEST_CASE_P(
::testing::ValuesIn(
&kWildcardMatchCandidates[0],
&kWildcardMatchCandidates[arraysize(kWildcardMatchCandidates)]));
+
+#if defined(GOOGLE_CHROME_BUILD)
+
+// A fixture for testing aliases that match to an expected translation. The
+// first member of the tuple is the expected translation, the second is a
+// candidate that should be aliased to the expectation.
+class LanguageSelectorAliasTest
+ : public ::testing::TestWithParam< std::tr1::tuple<const wchar_t*,
+ const wchar_t*> > {
+};
+
+// Test that the candidate language maps to the aliased translation.
+TEST_P(LanguageSelectorAliasTest, AliasesMatch) {
+ installer::LanguageSelector instance(
+ std::vector<std::wstring>(1, std::tr1::get<1>(GetParam())));
+ EXPECT_EQ(std::tr1::get<0>(GetParam()), instance.selected_translation());
+}
+
+INSTANTIATE_TEST_CASE_P(
+ EnGbAliases,
+ LanguageSelectorAliasTest,
+ ::testing::Combine(
+ ::testing::Values(L"en-gb"),
+ ::testing::Values(L"en-au", L"en-ca", L"en-nz", L"en-za")));
+
+INSTANTIATE_TEST_CASE_P(
+ IwAliases,
+ LanguageSelectorAliasTest,
+ ::testing::Combine(
+ ::testing::Values(L"iw"),
+ ::testing::Values(L"he")));
+
+INSTANTIATE_TEST_CASE_P(
+ NoAliases,
+ LanguageSelectorAliasTest,
+ ::testing::Combine(
+ ::testing::Values(L"no"),
+ ::testing::Values(L"nb")));
+
+INSTANTIATE_TEST_CASE_P(
+ FilAliases,
+ LanguageSelectorAliasTest,
+ ::testing::Combine(
+ ::testing::Values(L"fil"),
+ ::testing::Values(L"tl")));
+
+INSTANTIATE_TEST_CASE_P(
+ ZhCnAliases,
+ LanguageSelectorAliasTest,
+ ::testing::Combine(
+ ::testing::Values(L"zh-cn"),
+ ::testing::Values(L"zh-chs", L"zh-hans", L"zh-sg")));
+
+INSTANTIATE_TEST_CASE_P(
+ ZhTwAliases,
+ LanguageSelectorAliasTest,
+ ::testing::Combine(
+ ::testing::Values(L"zh-tw"),
+ ::testing::Values(L"zh-cht", L"zh-hant", L"zh-hk", L"zh-mo")));
+
+#endif // GOOGLE_CHROME_BUILD