| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // This file contains utility functions for dealing with localized | 5 // This file contains utility functions for dealing with localized |
| 6 // content. | 6 // content. |
| 7 | 7 |
| 8 #ifndef CHROME_COMMON_L10N_UTIL_H_ | 8 #ifndef CHROME_COMMON_L10N_UTIL_H_ |
| 9 #define CHROME_COMMON_L10N_UTIL_H_ | 9 #define CHROME_COMMON_L10N_UTIL_H_ |
| 10 | 10 |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 | 12 |
| 13 #if defined(OS_WIN) | 13 #if defined(OS_WIN) |
| 14 #include <windows.h> | 14 #include <windows.h> |
| 15 #endif | 15 #endif |
| 16 #include <algorithm> | 16 #include <algorithm> |
| 17 #include <functional> | 17 #include <functional> |
| 18 #include <string> | 18 #include <string> |
| 19 #include <vector> | 19 #include <vector> |
| 20 | 20 |
| 21 #include "base/basictypes.h" | 21 #include "base/basictypes.h" |
| 22 #include "base/logging.h" | 22 #include "base/logging.h" |
| 23 #include "base/scoped_ptr.h" | 23 #include "base/scoped_ptr.h" |
| 24 #include "base/string16.h" |
| 24 #include "base/string_util.h" | 25 #include "base/string_util.h" |
| 25 #include "third_party/icu38/public/common/unicode/ubidi.h" | 26 #include "third_party/icu38/public/common/unicode/ubidi.h" |
| 26 #include "unicode/coll.h" | 27 #include "unicode/coll.h" |
| 27 #include "unicode/locid.h" | 28 #include "unicode/locid.h" |
| 28 | 29 |
| 30 class FilePath; |
| 29 class PrefService; | 31 class PrefService; |
| 30 | 32 |
| 31 namespace l10n_util { | 33 namespace l10n_util { |
| 32 | 34 |
| 33 const wchar_t kRightToLeftMark[] = L"\x200f"; | 35 const char16 kRightToLeftMark = 0x200f; |
| 34 const wchar_t kLeftToRightMark[] = L"\x200e"; | 36 const char16 kLeftToRightMark = 0x200e; |
| 37 const char16 kLeftToRightEmbeddingMark = 0x202A; |
| 38 const char16 kRightToLeftEmbeddingMark = 0x202B; |
| 39 const char16 kPopDirectionalFormatting = 0x202C; |
| 35 | 40 |
| 36 // This method is responsible for determining the locale as defined below. In | 41 // This method is responsible for determining the locale as defined below. In |
| 37 // nearly all cases you shouldn't call this, rather use GetApplicationLocale | 42 // nearly all cases you shouldn't call this, rather use GetApplicationLocale |
| 38 // defined on browser_process. | 43 // defined on browser_process. |
| 39 // | 44 // |
| 40 // Returns the locale used by the Application. First we use the value from the | 45 // Returns the locale used by the Application. First we use the value from the |
| 41 // command line (--lang), second we try the value in the prefs file (passed in | 46 // command line (--lang), second we try the value in the prefs file (passed in |
| 42 // as |pref_locale|), finally, we fall back on the system locale. We only return | 47 // as |pref_locale|), finally, we fall back on the system locale. We only return |
| 43 // a value if there's a corresponding resource DLL for the locale. Otherwise, | 48 // a value if there's a corresponding resource DLL for the locale. Otherwise, |
| 44 // we fall back to en-us. | 49 // we fall back to en-us. |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 // Wraps a string with an LRE-PDF pair which essentialy marks the string as a | 149 // Wraps a string with an LRE-PDF pair which essentialy marks the string as a |
| 145 // Left-To-Right string. Doing this is useful in order to make sure LTR | 150 // Left-To-Right string. Doing this is useful in order to make sure LTR |
| 146 // strings are rendered properly in an RTL context. | 151 // strings are rendered properly in an RTL context. |
| 147 void WrapStringWithLTRFormatting(std::wstring* text); | 152 void WrapStringWithLTRFormatting(std::wstring* text); |
| 148 | 153 |
| 149 // Wraps a string with an RLE-PDF pair which essentialy marks the string as a | 154 // Wraps a string with an RLE-PDF pair which essentialy marks the string as a |
| 150 // Right-To-Left string. Doing this is useful in order to make sure RTL | 155 // Right-To-Left string. Doing this is useful in order to make sure RTL |
| 151 // strings are rendered properly in an LTR context. | 156 // strings are rendered properly in an LTR context. |
| 152 void WrapStringWithRTLFormatting(std::wstring* text); | 157 void WrapStringWithRTLFormatting(std::wstring* text); |
| 153 | 158 |
| 159 // Wraps individual file path components to get them to display correctly in an |
| 160 // RTL UI. All filepaths should be passed through this function before display |
| 161 // in UI for RTL locales. |
| 162 void WrapPathWithLTRFormatting(const FilePath& path, |
| 163 string16* rtl_safe_path); |
| 164 |
| 154 // Returns the locale-dependent extended window styles. | 165 // Returns the locale-dependent extended window styles. |
| 155 // This function is used for adding locale-dependent extended window styles | 166 // This function is used for adding locale-dependent extended window styles |
| 156 // (e.g. WS_EX_LAYOUTRTL, WS_EX_RTLREADING, etc.) when creating a window. | 167 // (e.g. WS_EX_LAYOUTRTL, WS_EX_RTLREADING, etc.) when creating a window. |
| 157 // Callers should OR this value into their extended style value when creating | 168 // Callers should OR this value into their extended style value when creating |
| 158 // a window. | 169 // a window. |
| 159 int GetExtendedStyles(); | 170 int GetExtendedStyles(); |
| 160 | 171 |
| 161 // TODO(xji): | 172 // TODO(xji): |
| 162 // This is a temporary name, it will eventually replace GetExtendedStyles | 173 // This is a temporary name, it will eventually replace GetExtendedStyles |
| 163 int GetExtendedTooltipStyles(); | 174 int GetExtendedTooltipStyles(); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 | 288 |
| 278 private: | 289 private: |
| 279 UBiDi* bidi_; | 290 UBiDi* bidi_; |
| 280 | 291 |
| 281 DISALLOW_COPY_AND_ASSIGN(BiDiLineIterator); | 292 DISALLOW_COPY_AND_ASSIGN(BiDiLineIterator); |
| 282 }; | 293 }; |
| 283 | 294 |
| 284 } | 295 } |
| 285 | 296 |
| 286 #endif // CHROME_COMMON_L10N_UTIL_H_ | 297 #endif // CHROME_COMMON_L10N_UTIL_H_ |
| OLD | NEW |