Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(447)

Side by Side Diff: trunk/src/base/i18n/rtl.cc

Issue 474483002: Revert 289312 "Move StringToUpperASCII and LowerCaseEqualsASCII ..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « trunk/src/base/files/file_path.cc ('k') | trunk/src/base/strings/string_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/i18n/rtl.h" 5 #include "base/i18n/rtl.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 std::string GetCanonicalLocale(const char* locale) { 77 std::string GetCanonicalLocale(const char* locale) {
78 return GetLocaleString(icu::Locale::createCanonical(locale)); 78 return GetLocaleString(icu::Locale::createCanonical(locale));
79 } 79 }
80 80
81 // Convert Chrome locale name to ICU locale name 81 // Convert Chrome locale name to ICU locale name
82 std::string ICULocaleName(const std::string& locale_string) { 82 std::string ICULocaleName(const std::string& locale_string) {
83 // If not Spanish, just return it. 83 // If not Spanish, just return it.
84 if (locale_string.substr(0, 2) != "es") 84 if (locale_string.substr(0, 2) != "es")
85 return locale_string; 85 return locale_string;
86 // Expand es to es-ES. 86 // Expand es to es-ES.
87 if (base::LowerCaseEqualsASCII(locale_string, "es")) 87 if (LowerCaseEqualsASCII(locale_string, "es"))
88 return "es-ES"; 88 return "es-ES";
89 // Map es-419 (Latin American Spanish) to es-FOO depending on the system 89 // Map es-419 (Latin American Spanish) to es-FOO depending on the system
90 // locale. If it's es-RR other than es-ES, map to es-RR. Otherwise, map 90 // locale. If it's es-RR other than es-ES, map to es-RR. Otherwise, map
91 // to es-MX (the most populous in Spanish-speaking Latin America). 91 // to es-MX (the most populous in Spanish-speaking Latin America).
92 if (base::LowerCaseEqualsASCII(locale_string, "es-419")) { 92 if (LowerCaseEqualsASCII(locale_string, "es-419")) {
93 const icu::Locale& locale = icu::Locale::getDefault(); 93 const icu::Locale& locale = icu::Locale::getDefault();
94 std::string language = locale.getLanguage(); 94 std::string language = locale.getLanguage();
95 const char* country = locale.getCountry(); 95 const char* country = locale.getCountry();
96 if (base::LowerCaseEqualsASCII(language, "es") && 96 if (LowerCaseEqualsASCII(language, "es") &&
97 !base::LowerCaseEqualsASCII(country, "es")) { 97 !LowerCaseEqualsASCII(country, "es")) {
98 language += '-'; 98 language += '-';
99 language += country; 99 language += country;
100 return language; 100 return language;
101 } 101 }
102 return "es-MX"; 102 return "es-MX";
103 } 103 }
104 // Currently, Chrome has only "es" and "es-419", but later we may have 104 // Currently, Chrome has only "es" and "es-419", but later we may have
105 // more specific "es-RR". 105 // more specific "es-RR".
106 return locale_string; 106 return locale_string;
107 } 107 }
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 begin == kRightToLeftOverride) 385 begin == kRightToLeftOverride)
386 ++begin_index; 386 ++begin_index;
387 size_t end_index = text.length() - 1; 387 size_t end_index = text.length() - 1;
388 if (text[end_index] == kPopDirectionalFormatting) 388 if (text[end_index] == kPopDirectionalFormatting)
389 --end_index; 389 --end_index;
390 return text.substr(begin_index, end_index - begin_index + 1); 390 return text.substr(begin_index, end_index - begin_index + 1);
391 } 391 }
392 392
393 } // namespace i18n 393 } // namespace i18n
394 } // namespace base 394 } // namespace base
OLDNEW
« no previous file with comments | « trunk/src/base/files/file_path.cc ('k') | trunk/src/base/strings/string_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698