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

Side by Side Diff: ui/base/l10n/l10n_util_mac.mm

Issue 6409039: Menu item titles include Windows-style accelerator marker.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 10 months 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 | « no previous file | ui/base/l10n/l10n_util_mac_unittest.mm » ('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) 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
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
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
OLDNEW
« no previous file with comments | « no previous file | ui/base/l10n/l10n_util_mac_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698