summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r--chrome/browser/cocoa/ui_localizer.h4
-rw-r--r--chrome/browser/cocoa/ui_localizer.mm33
-rw-r--r--chrome/browser/cocoa/ui_localizer_unittest.mm46
3 files changed, 4 insertions, 79 deletions
diff --git a/chrome/browser/cocoa/ui_localizer.h b/chrome/browser/cocoa/ui_localizer.h
index 36efc59..50c480a 100644
--- a/chrome/browser/cocoa/ui_localizer.h
+++ b/chrome/browser/cocoa/ui_localizer.h
@@ -13,10 +13,6 @@
namespace ui_localizer {
-// Remove the Windows-style accelerator marker and change "..." into an
-// ellipsis. Returns the result in an autoreleased NSString.
-NSString* FixUpWindowsStyleLabel(const string16& label);
-
struct ResourceMap {
const char* const name;
unsigned int label_id;
diff --git a/chrome/browser/cocoa/ui_localizer.mm b/chrome/browser/cocoa/ui_localizer.mm
index 5467203..7fd4d44 100644
--- a/chrome/browser/cocoa/ui_localizer.mm
+++ b/chrome/browser/cocoa/ui_localizer.mm
@@ -6,36 +6,12 @@
#import <Foundation/Foundation.h>
-#include "app/l10n_util.h"
+#include "app/l10n_util_mac.h"
#include "base/sys_string_conversions.h"
#include "base/logging.h"
namespace ui_localizer {
-NSString* FixUpWindowsStyleLabel(const string16& label) {
- const char16 kEllipsisUTF16 = 0x2026;
- string16 ret;
- size_t label_len = label.length();
- ret.reserve(label_len);
- for (size_t i = 0; i < label_len; ++i) {
- char16 c = label[i];
- if (c == '&') {
- if (i + 1 < label_len && label[i + 1] == '&') {
- ret.push_back(c);
- ++i;
- }
- } else if (c == '.' && i + 2 < label_len && label[i + 1] == '.'
- && label[i + 2] == '.') {
- ret.push_back(kEllipsisUTF16);
- i += 2;
- } else {
- ret.push_back(c);
- }
- }
-
- return base::SysUTF16ToNSString(ret);
-}
-
NSString* LocalizedStringForKeyFromMapList(NSString* key,
const ResourceMap* map_list,
size_t map_list_len) {
@@ -54,12 +30,11 @@ NSString* LocalizedStringForKeyFromMapList(NSString* key,
if (map_list[i].label_arg_id != 0) {
const string16 label_arg(
l10n_util::GetStringUTF16(map_list[i].label_arg_id));
- return FixUpWindowsStyleLabel(
- l10n_util::GetStringFUTF16(map_list[i].label_id, label_arg));
+ return l10n_util::GetNSStringFWithFixup(map_list[i].label_id,
+ label_arg);
}
- return FixUpWindowsStyleLabel(
- l10n_util::GetStringUTF16(map_list[i].label_id));
+ return l10n_util::GetNSStringWithFixup(map_list[i].label_id);
}
// If we've passed where the string would be, give up.
diff --git a/chrome/browser/cocoa/ui_localizer_unittest.mm b/chrome/browser/cocoa/ui_localizer_unittest.mm
deleted file mode 100644
index a6756a9..0000000
--- a/chrome/browser/cocoa/ui_localizer_unittest.mm
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#import <Foundation/Foundation.h>
-
-#include "base/sys_string_conversions.h"
-#include "chrome/browser/cocoa/ui_localizer.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "testing/platform_test.h"
-
-typedef PlatformTest UILocalizerTest;
-
-TEST_F(UILocalizerTest, FixUpWindowsStyleLabel) {
- struct TestData {
- NSString* input;
- NSString* output;
- };
-
- TestData data[] = {
- { @"", @"" },
- { @"nothing", @"nothing" },
- { @"foo &bar", @"foo bar" },
- { @"foo &&bar", @"foo &bar" },
- { @"foo &&&bar", @"foo &bar" },
- { @"&foo &&bar", @"foo &bar" },
- { @"&foo &bar", @"foo bar" },
- { @"foo bar.", @"foo bar." },
- { @"foo bar..", @"foo bar.." },
- { @"foo bar...", @"foo bar\u2026" },
- { @"foo.bar", @"foo.bar" },
- { @"foo..bar", @"foo..bar" },
- { @"foo...bar", @"foo\u2026bar" },
- { @"foo...bar...", @"foo\u2026bar\u2026" },
- };
- for (size_t idx = 0; idx < ARRAYSIZE_UNSAFE(data); ++idx) {
- string16 input16(base::SysNSStringToUTF16(data[idx].input));
-
- NSString* result = ui_localizer::FixUpWindowsStyleLabel(input16);
- EXPECT_TRUE(result != nil) << "Fixup Failed, idx = " << idx;
-
- EXPECT_TRUE([data[idx].output isEqualTo:result])
- << "For idx " << idx << ", expected '" << [data[idx].output UTF8String]
- << "', got '" << [result UTF8String] << "'";
- }
-}