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 #import <Foundation/Foundation.h> | 5 #import <Foundation/Foundation.h> |
6 | 6 |
7 #include "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "ui/base/l10n/l10n_util.h" | 10 #include "ui/base/l10n/l10n_util.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 | 63 |
64 // Remove the Windows-style accelerator marker and change "..." into an | 64 // Remove the Windows-style accelerator marker and change "..." into an |
65 // ellipsis. Returns the result in an autoreleased NSString. | 65 // ellipsis. Returns the result in an autoreleased NSString. |
66 NSString* FixUpWindowsStyleLabel(const string16& label) { | 66 NSString* FixUpWindowsStyleLabel(const string16& label) { |
67 const char16 kEllipsisUTF16 = 0x2026; | 67 const char16 kEllipsisUTF16 = 0x2026; |
68 string16 ret; | 68 string16 ret; |
69 size_t label_len = label.length(); | 69 size_t label_len = label.length(); |
70 ret.reserve(label_len); | 70 ret.reserve(label_len); |
71 for (size_t i = 0; i < label_len; ++i) { | 71 for (size_t i = 0; i < label_len; ++i) { |
72 char16 c = label[i]; | 72 char16 c = label[i]; |
73 if (c == '&') { | 73 if (c == '(' && i + 3 < label_len && label[i + 1] == '&' |
| 74 && label[i + 3] == ')') { |
| 75 // Strip '(&?)' patterns which means Windows-style accelerator in some |
| 76 // non-English locales such as Japanese. |
| 77 i += 3; |
| 78 } else if (c == '&') { |
74 if (i + 1 < label_len && label[i + 1] == '&') { | 79 if (i + 1 < label_len && label[i + 1] == '&') { |
75 ret.push_back(c); | 80 ret.push_back(c); |
76 ++i; | 81 ++i; |
77 } | 82 } |
78 } else if (c == '.' && i + 2 < label_len && label[i + 1] == '.' | 83 } else if (c == '.' && i + 2 < label_len && label[i + 1] == '.' |
79 && label[i + 2] == '.') { | 84 && label[i + 2] == '.') { |
80 ret.push_back(kEllipsisUTF16); | 85 ret.push_back(kEllipsisUTF16); |
81 i += 2; | 86 i += 2; |
82 } else { | 87 } else { |
83 ret.push_back(c); | 88 ret.push_back(c); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 const string16& a, | 163 const string16& a, |
159 const string16& b, | 164 const string16& b, |
160 const string16& c, | 165 const string16& c, |
161 const string16& d) { | 166 const string16& d) { |
162 return FixUpWindowsStyleLabel(l10n_util::GetStringFUTF16(message_id, | 167 return FixUpWindowsStyleLabel(l10n_util::GetStringFUTF16(message_id, |
163 a, b, c, d)); | 168 a, b, c, d)); |
164 } | 169 } |
165 | 170 |
166 | 171 |
167 } // namespace l10n_util | 172 } // namespace l10n_util |
OLD | NEW |