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 #ifndef BASE_I18N_RTL_H_ | 5 #ifndef BASE_I18N_RTL_H_ |
| 6 #define BASE_I18N_RTL_H_ | 6 #define BASE_I18N_RTL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/i18n/base_i18n_export.h" | 11 #include "base/i18n/base_i18n_export.h" |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 | 14 |
| 15 namespace icu { | |
|
tfarina
2014/09/08 02:35:20
forward declaring this namespace does not work in
| |
| 16 class Locale; | |
| 17 } | |
| 18 | |
| 15 namespace base { | 19 namespace base { |
| 16 | 20 |
| 17 class FilePath; | 21 class FilePath; |
| 18 | 22 |
| 19 namespace i18n { | 23 namespace i18n { |
| 20 | 24 |
| 21 const char16 kRightToLeftMark = 0x200F; | 25 const char16 kRightToLeftMark = 0x200F; |
| 22 const char16 kLeftToRightMark = 0x200E; | 26 const char16 kLeftToRightMark = 0x200E; |
| 23 const char16 kLeftToRightEmbeddingMark = 0x202A; | 27 const char16 kLeftToRightEmbeddingMark = 0x202A; |
| 24 const char16 kRightToLeftEmbeddingMark = 0x202B; | 28 const char16 kRightToLeftEmbeddingMark = 0x202B; |
| 25 const char16 kPopDirectionalFormatting = 0x202C; | 29 const char16 kPopDirectionalFormatting = 0x202C; |
| 26 const char16 kLeftToRightOverride = 0x202D; | 30 const char16 kLeftToRightOverride = 0x202D; |
| 27 const char16 kRightToLeftOverride = 0x202E; | 31 const char16 kRightToLeftOverride = 0x202E; |
| 28 | 32 |
| 29 // Locale.java mirrored this enum TextDirection. Please keep in sync. | 33 // Locale.java mirrored this enum TextDirection. Please keep in sync. |
| 30 enum TextDirection { | 34 enum TextDirection { |
| 31 UNKNOWN_DIRECTION = 0, | 35 UNKNOWN_DIRECTION = 0, |
| 32 RIGHT_TO_LEFT = 1, | 36 RIGHT_TO_LEFT = 1, |
| 33 LEFT_TO_RIGHT = 2, | 37 LEFT_TO_RIGHT = 2, |
| 34 TEXT_DIRECTION_NUM_DIRECTIONS = 3, | 38 TEXT_DIRECTION_NUM_DIRECTIONS = 3, |
| 35 }; | 39 }; |
| 36 | 40 |
| 41 // Extract language, country and variant, but ignore keywords. For example, | |
| 42 // en-US, ca@valencia, ca-ES@valencia. | |
| 43 BASE_I18N_EXPORT std::string GetLocaleString(const icu::Locale& locale); | |
| 44 | |
| 37 // Get the locale that the currently running process has been configured to use. | 45 // Get the locale that the currently running process has been configured to use. |
| 38 // The return value is of the form language[-country] (e.g., en-US) where the | 46 // The return value is of the form language[-country] (e.g., en-US) where the |
| 39 // language is the 2 or 3 letter code from ISO-639. | 47 // language is the 2 or 3 letter code from ISO-639. |
| 40 BASE_I18N_EXPORT std::string GetConfiguredLocale(); | 48 BASE_I18N_EXPORT std::string GetConfiguredLocale(); |
| 41 | 49 |
| 42 // Canonicalize a string (eg. a POSIX locale string) to a Chrome locale name. | |
| 43 BASE_I18N_EXPORT std::string GetCanonicalLocale(const char* locale); | |
| 44 | |
| 45 // Sets the default locale of ICU. | 50 // Sets the default locale of ICU. |
| 46 // Once the application locale of Chrome in GetApplicationLocale is determined, | 51 // Once the application locale of Chrome in GetApplicationLocale is determined, |
| 47 // the default locale of ICU need to be changed to match the application locale | 52 // the default locale of ICU need to be changed to match the application locale |
| 48 // so that ICU functions work correctly in a locale-dependent manner. | 53 // so that ICU functions work correctly in a locale-dependent manner. |
| 49 // This is handy in that we don't have to call GetApplicationLocale() | 54 // This is handy in that we don't have to call GetApplicationLocale() |
| 50 // everytime we call locale-dependent ICU APIs as long as we make sure | 55 // everytime we call locale-dependent ICU APIs as long as we make sure |
| 51 // that this is called before any locale-dependent API is called. | 56 // that this is called before any locale-dependent API is called. |
| 52 BASE_I18N_EXPORT void SetICUDefaultLocale(const std::string& locale_string); | 57 BASE_I18N_EXPORT void SetICUDefaultLocale(const std::string& locale_string); |
| 53 | 58 |
| 54 // Returns true if the application text direction is right-to-left. | 59 // Returns true if the application text direction is right-to-left. |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 // return the text itself. Explicit bidi control characters display and have | 145 // return the text itself. Explicit bidi control characters display and have |
| 141 // semantic effect. They can be deleted so they might not always appear in a | 146 // semantic effect. They can be deleted so they might not always appear in a |
| 142 // pair. | 147 // pair. |
| 143 BASE_I18N_EXPORT string16 StripWrappingBidiControlCharacters( | 148 BASE_I18N_EXPORT string16 StripWrappingBidiControlCharacters( |
| 144 const string16& text) WARN_UNUSED_RESULT; | 149 const string16& text) WARN_UNUSED_RESULT; |
| 145 | 150 |
| 146 } // namespace i18n | 151 } // namespace i18n |
| 147 } // namespace base | 152 } // namespace base |
| 148 | 153 |
| 149 #endif // BASE_I18N_RTL_H_ | 154 #endif // BASE_I18N_RTL_H_ |
| OLD | NEW |