Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/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" |
| 11 #include "base/sys_string_conversions.h" | 11 #include "base/sys_string_conversions.h" |
| 12 #include "unicode/coll.h" | 12 #include "unicode/coll.h" |
| 13 #include "unicode/locid.h" | 13 #include "unicode/locid.h" |
| 14 #include "unicode/uchar.h" | 14 #include "unicode/uchar.h" |
| 15 #include "unicode/uscript.h" | 15 #include "unicode/uscript.h" |
| 16 | 16 |
| 17 #if defined(TOOLKIT_USES_GTK) | 17 #if defined(TOOLKIT_USES_GTK) |
| 18 #include <gtk/gtk.h> | 18 #include <gtk/gtk.h> |
| 19 #endif | 19 #endif |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 // Extract language and country, ignore keywords, concatenate using dash. | 23 // Extract language and country, ignore keywords, concatenate using dash. |
|
Evan Martin
2011/06/06 21:27:39
This comment is no longer accurate.
| |
| 24 std::string GetLocaleString(const icu::Locale& locale) { | 24 std::string GetLocaleString(const icu::Locale& locale) { |
| 25 const char* language = locale.getLanguage(); | 25 const char* language = locale.getLanguage(); |
| 26 const char* country = locale.getCountry(); | 26 const char* country = locale.getCountry(); |
| 27 const char* variant = locale.getVariant(); | |
| 27 | 28 |
| 28 std::string result = | 29 std::string result = |
| 29 (language != NULL && *language != '\0') ? language : "und"; | 30 (language != NULL && *language != '\0') ? language : "und"; |
| 30 | 31 |
| 31 if (country != NULL && *country != '\0') { | 32 if (country != NULL && *country != '\0') { |
| 32 result += '-'; | 33 result += '-'; |
| 33 result += country; | 34 result += country; |
| 34 } | 35 } |
| 35 | 36 |
| 37 if (variant != NULL && *variant != '\0') { | |
| 38 std::string variant_str(variant); | |
| 39 StringToLowerASCII(&variant_str); | |
| 40 result += '@' + variant_str; | |
| 41 } | |
| 42 | |
| 36 return result; | 43 return result; |
| 37 } | 44 } |
| 38 | 45 |
| 39 } // namespace | 46 } // namespace |
| 40 | 47 |
| 41 namespace base { | 48 namespace base { |
| 42 namespace i18n { | 49 namespace i18n { |
| 43 | 50 |
| 44 // Represents the locale-specific ICU text direction. | 51 // Represents the locale-specific ICU text direction. |
| 45 static TextDirection g_icu_text_direction = UNKNOWN_DIRECTION; | 52 static TextDirection g_icu_text_direction = UNKNOWN_DIRECTION; |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 304 begin == kRightToLeftOverride) | 311 begin == kRightToLeftOverride) |
| 305 ++begin_index; | 312 ++begin_index; |
| 306 size_t end_index = text.length() - 1; | 313 size_t end_index = text.length() - 1; |
| 307 if (text[end_index] == kPopDirectionalFormatting) | 314 if (text[end_index] == kPopDirectionalFormatting) |
| 308 --end_index; | 315 --end_index; |
| 309 return text.substr(begin_index, end_index - begin_index + 1); | 316 return text.substr(begin_index, end_index - begin_index + 1); |
| 310 } | 317 } |
| 311 | 318 |
| 312 } // namespace i18n | 319 } // namespace i18n |
| 313 } // namespace base | 320 } // namespace base |
| OLD | NEW |