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

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

Issue 4139010: The UI language rather than the locale is now used to pick Chrome's language ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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 | « base/i18n/rtl.h ('k') | base/win/i18n.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/file_path.h" 7 #include "base/file_path.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 26 matching lines...) Expand all
37 } 37 }
38 38
39 } // namespace 39 } // namespace
40 40
41 namespace base { 41 namespace base {
42 namespace i18n { 42 namespace i18n {
43 43
44 // Represents the locale-specific ICU text direction. 44 // Represents the locale-specific ICU text direction.
45 static TextDirection g_icu_text_direction = UNKNOWN_DIRECTION; 45 static TextDirection g_icu_text_direction = UNKNOWN_DIRECTION;
46 46
47 #if defined(OS_WIN)
48 void GetLanguageAndRegionFromOS(std::string* lang, std::string* region) {
49 // Later we may have to change this to be OS-dependent so that
50 // it's not affected by ICU's default locale. It's all right
51 // to do this way because SetICUDefaultLocale is internal
52 // to this file and we know that it's not yet called when this function
53 // is called.
54 const icu::Locale& locale = icu::Locale::getDefault();
55 const char* language = locale.getLanguage();
56 const char* country = locale.getCountry();
57 DCHECK(language);
58 *lang = language;
59 *region = country;
60 }
61 #endif
62
63 // Convert the ICU default locale to a string. 47 // Convert the ICU default locale to a string.
64 std::string GetConfiguredLocale() { 48 std::string GetConfiguredLocale() {
65 return GetLocaleString(icu::Locale::getDefault()); 49 return GetLocaleString(icu::Locale::getDefault());
66 } 50 }
67 51
68 // Convert the ICU canonicalized locale to a string. 52 // Convert the ICU canonicalized locale to a string.
69 std::string GetCanonicalLocale(const char* locale) { 53 std::string GetCanonicalLocale(const char* locale) {
70 return GetLocaleString(icu::Locale::createCanonical(locale)); 54 return GetLocaleString(icu::Locale::createCanonical(locale));
71 } 55 }
72 56
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 begin == kRightToLeftOverride) 305 begin == kRightToLeftOverride)
322 ++begin_index; 306 ++begin_index;
323 size_t end_index = text.length() - 1; 307 size_t end_index = text.length() - 1;
324 if (text[end_index] == kPopDirectionalFormatting) 308 if (text[end_index] == kPopDirectionalFormatting)
325 --end_index; 309 --end_index;
326 return text.substr(begin_index, end_index - begin_index + 1); 310 return text.substr(begin_index, end_index - begin_index + 1);
327 } 311 }
328 312
329 } // namespace i18n 313 } // namespace i18n
330 } // namespace base 314 } // namespace base
OLDNEW
« no previous file with comments | « base/i18n/rtl.h ('k') | base/win/i18n.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698