summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/app_controller_mac.mm10
-rw-r--r--chrome/browser/cocoa/menu_localizer.h19
-rw-r--r--chrome/browser/cocoa/menu_localizer.mm33
3 files changed, 62 insertions, 0 deletions
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm
index 859840f..0b88c36 100644
--- a/chrome/browser/app_controller_mac.mm
+++ b/chrome/browser/app_controller_mac.mm
@@ -14,6 +14,7 @@
#include "chrome/browser/browser_shutdown.h"
#import "chrome/browser/cocoa/bookmark_menu_bridge.h"
#import "chrome/browser/cocoa/encoding_menu_controller_delegate_mac.h"
+#import "chrome/browser/cocoa/menu_localizer.h"
#import "chrome/browser/cocoa/preferences_window_controller.h"
#include "chrome/browser/command_updater.h"
#include "chrome/common/pref_names.h"
@@ -67,6 +68,15 @@
DCHECK(g_browser_process);
g_browser_process->AddRefModule();
+ // Create the localizer for the main menu. We can't do this in the nib
+ // because it's too early. Do it before we create any bookmark menus as well,
+ // just in case one has a title that matches any of our strings (unlikely,
+ // but technically possible).
+ scoped_nsobject<MenuLocalizer> localizer(
+ [[MenuLocalizer alloc] initWithBundle:nil]);
+ [localizer localizeObject:[NSApplication sharedApplication]
+ recursively:YES];
+
bookmarkMenuBridge_.reset(new BookmarkMenuBridge());
// Register any Mac-specific preferences.
diff --git a/chrome/browser/cocoa/menu_localizer.h b/chrome/browser/cocoa/menu_localizer.h
new file mode 100644
index 0000000..862ba20
--- /dev/null
+++ b/chrome/browser/cocoa/menu_localizer.h
@@ -0,0 +1,19 @@
+// 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.
+
+#ifndef CHROME_BROWSER_COCOA_MENU_LOCALIZER_H_
+#define CHROME_BROWSER_COCOA_MENU_LOCALIZER_H_
+
+#import <Cocoa/Cocoa.h>
+
+#import "third_party/GTM/AppKit/GTMUILocalizer.h"
+
+// A subclass of GTMUILocalizer that handles localizing our main menus. It maps
+// from the ^-prefixed strings in the nib into the strings bundles.
+
+@interface MenuLocalizer : GTMUILocalizer {
+}
+@end
+
+#endif // CHROME_BROWSER_COCOA_MENU_LOCALIZER_H_
diff --git a/chrome/browser/cocoa/menu_localizer.mm b/chrome/browser/cocoa/menu_localizer.mm
new file mode 100644
index 0000000..7b09520
--- /dev/null
+++ b/chrome/browser/cocoa/menu_localizer.mm
@@ -0,0 +1,33 @@
+// 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 "chrome/browser/cocoa/menu_localizer.h"
+
+#include "app/l10n_util.h"
+#include "base/sys_string_conversions.h"
+#include "grit/chromium_strings.h"
+
+@implementation MenuLocalizer
+
+// Override to map into our string bundles instead of strings plists.
+// TODO(pinkerton): This should use a string lookup table to map the string to
+// a constant.
+- (NSString *)localizedStringForString:(NSString *)string {
+ if ([string isEqualToString:@"^Quit Chromium"]) {
+ std::wstring quitString = l10n_util::GetString(IDS_EXIT_MAC);
+ return base::SysWideToNSString(quitString);
+ } else if ([string isEqualToString:@"^About Chromium"]) {
+ std::wstring quitString = l10n_util::GetString(IDS_ABOUT_CHROME_TITLE);
+ return base::SysWideToNSString(quitString);
+ } else if ([string isEqualToString:@"^Hide Chromium"]) {
+ std::wstring quitString = l10n_util::GetString(IDS_HIDE_MAC);
+ return base::SysWideToNSString(quitString);
+ } else if ([string isEqualToString:@"^Chromium Help"]) {
+ std::wstring quitString = l10n_util::GetString(IDS_HELP_MAC);
+ return base::SysWideToNSString(quitString);
+ }
+ return [super localizedStringForString:string];
+}
+
+@end