diff options
author | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-20 17:59:34 +0000 |
---|---|---|
committer | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-20 17:59:34 +0000 |
commit | 7b22524519ce66c5b660bf215013adcabd8ab936 (patch) | |
tree | 1c4b7f8185116e746171ec4bca7718817243759f /chrome | |
parent | 08aafa686ea3f3121936f8d4159a8c8069c98738 (diff) | |
download | chromium_src-7b22524519ce66c5b660bf215013adcabd8ab936.zip chromium_src-7b22524519ce66c5b660bf215013adcabd8ab936.tar.gz chromium_src-7b22524519ce66c5b660bf215013adcabd8ab936.tar.bz2 |
Use GTM's l10n class to substitute the correctly branded string for "Quit Chromium" at runtime. Update the string grd files to have this string. BUG=11486. TEST=check the quit menu item in the app menu for the correct branding.
Review URL: http://codereview.chromium.org/115574
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16489 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/app/chromium_strings.grd | 9 | ||||
-rw-r--r-- | chrome/app/google_chrome_strings.grd | 9 | ||||
-rw-r--r-- | chrome/app/nibs/en.lproj/MainMenu.xib | 32 | ||||
-rw-r--r-- | chrome/browser/app_controller_mac.mm | 10 | ||||
-rw-r--r-- | chrome/browser/cocoa/menu_localizer.h | 19 | ||||
-rw-r--r-- | chrome/browser/cocoa/menu_localizer.mm | 33 | ||||
-rw-r--r-- | chrome/chrome.gyp | 3 |
7 files changed, 99 insertions, 16 deletions
diff --git a/chrome/app/chromium_strings.grd b/chrome/app/chromium_strings.grd index 67ce685..0203d66 100644 --- a/chrome/app/chromium_strings.grd +++ b/chrome/app/chromium_strings.grd @@ -340,6 +340,15 @@ be available for now. --> <message name="IDS_DEFAULT_BROWSER_INFOBAR_SHORT_TEXT" desc="More compact text to show in the default browser query infobar."> Chromium isn't your default browser. </message> + <message name="IDS_EXIT_MAC" desc="The menu item to quit the browser in the app menu."> + Quit Chromium + </message> + <message name="IDS_HIDE_MAC" desc="The menu item to hide all browser windows in the app menu."> + Hide Chromium + </message> + <message name="IDS_HELP_MAC" desc="The menu item to show help in the Help menu."> + Chromium Help + </message> </messages> </release> </grit> diff --git a/chrome/app/google_chrome_strings.grd b/chrome/app/google_chrome_strings.grd index 4df2c35..08dec3e 100644 --- a/chrome/app/google_chrome_strings.grd +++ b/chrome/app/google_chrome_strings.grd @@ -388,6 +388,15 @@ Chrome supports. --> <message name="IDS_DEFAULT_BROWSER_INFOBAR_SHORT_TEXT" desc="More compact text to show in the default browser query infobar."> Google Chrome isn't your default browser. </message> + <message name="IDS_EXIT_MAC" desc="The menu item to quit the browser in the app menu."> + Quit Google Chrome + </message> + <message name="IDS_HIDE_MAC" desc="The menu item to hide all browser windows in the app menu."> + Hide Google Chrome + </message> + <message name="IDS_HELP_MAC" desc="The menu item to show help in the Help menu."> + Google Chrome Help + </message> </messages> </release> </grit> diff --git a/chrome/app/nibs/en.lproj/MainMenu.xib b/chrome/app/nibs/en.lproj/MainMenu.xib index fdeec8bb..46ab741 100644 --- a/chrome/app/nibs/en.lproj/MainMenu.xib +++ b/chrome/app/nibs/en.lproj/MainMenu.xib @@ -2,13 +2,13 @@ <archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03"> <data> <int key="IBDocument.SystemTarget">1050</int> - <string key="IBDocument.SystemVersion">9G55</string> + <string key="IBDocument.SystemVersion">9F33</string> <string key="IBDocument.InterfaceBuilderVersion">677</string> - <string key="IBDocument.AppKitVersion">949.43</string> - <string key="IBDocument.HIToolboxVersion">353.00</string> + <string key="IBDocument.AppKitVersion">949.34</string> + <string key="IBDocument.HIToolboxVersion">352.00</string> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="465"/> + <integer value="111"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -61,7 +61,7 @@ <bool key="EncodedWithXMLCoder">YES</bool> <object class="NSMenuItem" id="238522557"> <reference key="NSMenu" ref="110575045"/> - <string key="NSTitle">About Chromium</string> + <string key="NSTitle">^About Chromium</string> <string key="NSKeyEquiv"/> <int key="NSMnemonicLoc">2147483647</int> <reference key="NSOnImage" ref="353210768"/> @@ -142,7 +142,7 @@ </object> <object class="NSMenuItem" id="755159360"> <reference key="NSMenu" ref="110575045"/> - <string key="NSTitle">Hide Chromium</string> + <string key="NSTitle">^Hide Chromium</string> <string key="NSKeyEquiv">h</string> <int key="NSKeyEquivModMask">1048576</int> <int key="NSMnemonicLoc">2147483647</int> @@ -178,7 +178,7 @@ </object> <object class="NSMenuItem" id="632727374"> <reference key="NSMenu" ref="110575045"/> - <string key="NSTitle">Quit Chromium</string> + <string key="NSTitle">^Quit Chromium</string> <string key="NSKeyEquiv">q</string> <int key="NSKeyEquivModMask">1048576</int> <int key="NSMnemonicLoc">2147483647</int> @@ -1088,7 +1088,7 @@ <bool key="EncodedWithXMLCoder">YES</bool> <object class="NSMenuItem" id="238773614"> <reference key="NSMenu" ref="374024848"/> - <string key="NSTitle">Chromium Help</string> + <string key="NSTitle">^Chromium Help</string> <string key="NSKeyEquiv">?</string> <int key="NSKeyEquivModMask">1048576</int> <int key="NSMnemonicLoc">2147483647</int> @@ -2669,7 +2669,7 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <integer value="1" id="9"/> - <string>{{507, 724}, {181, 23}}</string> + <string>{{929, 698}, {190, 23}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> <string>{{596, 852}, {216, 23}}</string> @@ -2729,7 +2729,7 @@ <reference ref="9"/> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> - <string>{{264, 573}, {243, 263}}</string> + <string>{{603, 458}, {243, 263}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> <string>{{197, 734}, {243, 243}}</string> @@ -2775,7 +2775,7 @@ <reference ref="9"/> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> - <string>{{519, 673}, {213, 163}}</string> + <string>{{858, 558}, {213, 163}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> <string>{{525, 802}, {197, 73}}</string> @@ -2828,7 +2828,7 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{425, 803}, {254, 33}}</string> + <string>{{764, 688}, {254, 33}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> @@ -2839,7 +2839,7 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{358, 683}, {230, 153}}</string> + <string>{{697, 568}, {230, 153}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> @@ -2859,7 +2859,7 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> - <string>{{381, 623}, {244, 213}}</string> + <string>{{467, 508}, {244, 213}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> <string>{{23, 794}, {245, 183}}</string> @@ -2879,7 +2879,7 @@ <reference ref="9"/> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> - <string>{{222, 533}, {249, 303}}</string> + <string>{{561, 418}, {249, 303}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> <string>{{323, 672}, {199, 203}}</string> @@ -2911,7 +2911,7 @@ </object> </object> <nil key="sourceID"/> - <int key="maxID">615</int> + <int key="maxID">619</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> 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 diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 442f2b4..982f7b1 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -648,6 +648,8 @@ 'browser/cocoa/location_bar_cell.mm', 'browser/cocoa/location_bar_view_mac.h', 'browser/cocoa/location_bar_view_mac.mm', + 'browser/cocoa/menu_localizer.h', + 'browser/cocoa/menu_localizer.mm', 'browser/cocoa/preferences_window_controller.h', 'browser/cocoa/preferences_window_controller.mm', 'browser/cocoa/sad_tab_view.h', @@ -1531,6 +1533,7 @@ '../third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.m', '../third_party/GTM/AppKit/GTMNSColor+Luminance.m', '../third_party/GTM/AppKit/GTMTheme.m', + '../third_party/GTM/AppKit/GTMUILocalizer.m', # Build necessary Mozilla sources '../third_party/mozilla/include/NSWorkspace+Utils.h', '../third_party/mozilla/include/NSWorkspace+Utils.m', |