summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbuild/mac/generate_localizer121
-rw-r--r--chrome/app/nibs/BookmarkBar.xib18
-rw-r--r--chrome/app/nibs/BookmarkEditor.xib10
-rw-r--r--chrome/app/nibs/BookmarkNameFolder.xib14
-rw-r--r--chrome/app/nibs/TabView.xib10
-rw-r--r--chrome/app/nibs/Toolbar.xib37
-rw-r--r--chrome/browser/app_controller_mac.mm6
-rw-r--r--chrome/browser/cocoa/ui_localizer.h20
-rw-r--r--chrome/browser/cocoa/ui_localizer.mm98
-rw-r--r--chrome/chrome.gyp97
10 files changed, 165 insertions, 266 deletions
diff --git a/build/mac/generate_localizer b/build/mac/generate_localizer
index c9d49f9..228751e 100755
--- a/build/mac/generate_localizer
+++ b/build/mac/generate_localizer
@@ -20,52 +20,22 @@ localizer_template_h = \
'''// ---------- WARNING ----------
// THIS IS A GENERATED FILE, DO NOT EDIT IT DIRECTLY!
//
-// Generated by %(generate_localizer)s.
-// Generated from %(xib_file)s.
+// This header includes the table used by ui_localizer.mm. Nothing else should
+// be including this file.
//
-
-#ifndef %(class_name)s_LOCALIZER_H_
-#define %(class_name)s_LOCALIZER_H_
-
-#import "chrome/browser/cocoa/ui_localizer.h"
-
-// A subclass of ChromeUILocalizer that handles localization based on resource
-// constants.
-
-@interface %(class_name)sLocalizer : ChromeUILocalizer
-@end
-
-#endif // %(class_name)s_LOCALIZER_H_
-'''
-
-localizer_template_mm = \
-'''// ---------- WARNING ----------
-// THIS IS A GENERATED FILE, DO NOT EDIT IT DIRECTLY!
-//
-// Generated by '%(generate_localizer)s'.
-// Generated from '%(xib_file)s'.
+// Generated by %(generate_localizer)s.
+// Generated from:
+// %(xib_files)s
//
-#import "%(header_name)s"
-
-#include "grit/app_strings.h"
-#include "grit/chromium_strings.h"
-#include "grit/generated_resources.h"
+#ifndef UI_LOCALIZER_TABLE_H_
+#define UI_LOCALIZER_TABLE_H_
-@implementation %(class_name)sLocalizer
-
-- (NSString *)localizedStringForString:(NSString *)string {
-
- static const ui_localizer::ResourceMap kUIResources[] = {
+static const UILocalizerResourceMap kUIResources[] = {
%(resource_map_list)s };
- static const size_t kUIResourcesSize = arraysize(kUIResources);
+static const size_t kUIResourcesSize = arraysize(kUIResources);
- return ui_localizer::LocalizedStringForKeyFromMapList(string,
- kUIResources,
- kUIResourcesSize);
-}
-
-@end
+#endif // UI_LOCALIZER_TABLE_H_
'''
def xib_localizable_strings(xib_path):
@@ -95,8 +65,8 @@ def extract_resource_constants(plist_localizable_strings_dict, xib_path):
% (xib_path, generate_localizer, item_value));
return constants_list
-def generate_files_contents(class_name, constants_list, header_name, xib_path):
- """Generates a localizer files contents from the list of constants."""
+def generate_file_contents(constants_list, xib_paths):
+ """Generates the header listing the constants."""
# Bounce through a set to uniq the strings, sort the list, then build the
# values we need from it.
constants_list = sorted(set(constants_list))
@@ -112,15 +82,12 @@ def generate_files_contents(class_name, constants_list, header_name, xib_path):
( item, label_id[1:], label_arg_id)
# Assemble the contents from the templates.
values_dict = {
- 'class_name': class_name,
- 'header_name': header_name,
'resource_map_list': constant_list_str,
'generate_localizer': generate_localizer,
- 'xib_file': xib_path,
+ 'xib_files': "\n// ".join(xib_paths),
}
h_file = localizer_template_h % values_dict
- mm_file = localizer_template_mm % values_dict
- return (h_file, mm_file)
+ return h_file
def Main(argv=None):
@@ -128,49 +95,37 @@ def Main(argv=None):
generate_localizer = os.path.basename(argv[0])
# Args
- if len(argv) != 4:
- sys.stderr.write('%s:0: error: Expected xib and output file arguments\n' %
+ if len(argv) < 4:
+ sys.stderr.write('%s:0: error: Expected output file and then xibs\n' %
generate_localizer);
return 1
- xib_path, output_h_path, output_mm_path = argv[1:]
-
- # Run ibtool and convert to something Python can deal with
- plist_string = xib_localizable_strings(xib_path)
- if not plist_string:
- return 2
- plist = plistlib.readPlistFromString(plist_string)
-
- # Extract the resource constant strings
- localizable_strings = plist['com.apple.ibtool.document.localizable-strings']
- constants_list = extract_resource_constants(localizable_strings, xib_path)
- if not constants_list:
- sys.stderr.write("%s:0: warning: %s didn't find any resource strings\n" %
- (xib_path, generate_localizer));
- # Seed constant_list with an entry so things will compile even though the
- # array sould really be empty (array_size in the generated file doesn't
- # like an empty array).
- constants_list.append('^0');
-
- # Name the class based on the output file
- class_name = os.path.splitext(os.path.basename(output_h_path))[0]
- suffix = '_localizer'
- if class_name.endswith(suffix):
- class_name = class_name[:-len(suffix)];
- class_name = class_name.replace('_', ' ').title().replace(' ', '');
+ output_path = argv[1];
+ xib_paths = argv[2:]
+
+ full_constants_list = []
+ for xib_path in xib_paths:
+ # Run ibtool and convert to something Python can deal with
+ plist_string = xib_localizable_strings(xib_path)
+ if not plist_string:
+ return 2
+ plist = plistlib.readPlistFromString(plist_string)
+
+ # Extract the resource constant strings
+ localizable_strings = plist['com.apple.ibtool.document.localizable-strings']
+ constants_list = extract_resource_constants(localizable_strings, xib_path)
+ if not constants_list:
+ sys.stderr.write("%s:0: warning: %s didn't find any resource strings\n" %
+ (xib_path, generate_localizer));
+ full_constants_list.extend(constants_list)
# Generate our file contents
- (h_file_content, mm_file_content) = \
- generate_files_contents(class_name, constants_list,
- os.path.basename(output_h_path),
- xib_path)
+ h_file_content = \
+ generate_file_contents(full_constants_list, xib_paths)
- # Write out the files
- file_fd = open(output_h_path, 'w')
+ # Write out the file
+ file_fd = open(output_path, 'w')
file_fd.write(h_file_content)
file_fd.close()
- file_fd = open(output_mm_path, 'w')
- file_fd.write(mm_file_content)
- file_fd.close()
return 0
diff --git a/chrome/app/nibs/BookmarkBar.xib b/chrome/app/nibs/BookmarkBar.xib
index b8da664..2dc0c3d 100644
--- a/chrome/app/nibs/BookmarkBar.xib
+++ b/chrome/app/nibs/BookmarkBar.xib
@@ -8,9 +8,9 @@
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
+ <integer value="1"/>
<integer value="18"/>
<integer value="4"/>
- <integer value="1"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -303,7 +303,7 @@
</object>
</object>
<object class="NSCustomObject" id="849863465">
- <string key="NSClassName">BookmarkBarLocalizer</string>
+ <string key="NSClassName">ChromeUILocalizer</string>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
@@ -901,15 +901,17 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<string>buttonContextMenu_</string>
<string>buttonView_</string>
- <string>delegate_</string>
<string>offTheSideButton_</string>
+ <string>resizeDelegate_</string>
+ <string>urlDelegate_</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>NSMenu</string>
<string>NSView</string>
- <string>id</string>
<string>NSButton</string>
+ <string>id</string>
+ <string>id</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
@@ -918,14 +920,6 @@
</object>
</object>
<object class="IBPartialClassDescription">
- <string key="className">BookmarkBarLocalizer</string>
- <string key="superclassName">ChromeUILocalizer</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBProjectSource</string>
- <string key="minorKey">../xcodebuild/chrome.build/DerivedSources/Debug/xib_localizers/bookmark_bar_localizer.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
<string key="className">ChromeUILocalizer</string>
<string key="superclassName">GTMUILocalizer</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
diff --git a/chrome/app/nibs/BookmarkEditor.xib b/chrome/app/nibs/BookmarkEditor.xib
index 0d03abc..85d005e 100644
--- a/chrome/app/nibs/BookmarkEditor.xib
+++ b/chrome/app/nibs/BookmarkEditor.xib
@@ -301,7 +301,7 @@
<string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
</object>
<object class="NSCustomObject" id="764065517">
- <string key="NSClassName">BookmarkEditorLocalizer</string>
+ <string key="NSClassName">ChromeUILocalizer</string>
</object>
<object class="NSCustomObject" id="12470901">
<string key="NSClassName">GTMUILocalizerAndLayoutTweaker</string>
@@ -764,14 +764,6 @@
</object>
</object>
<object class="IBPartialClassDescription">
- <string key="className">BookmarkEditorLocalizer</string>
- <string key="superclassName">ChromeUILocalizer</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBProjectSource</string>
- <string key="minorKey">../xcodebuild/chrome.build/DerivedSources/Debug/xib_localizers/bookmark_editor_localizer.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
<string key="className">ChromeUILocalizer</string>
<string key="superclassName">GTMUILocalizer</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
diff --git a/chrome/app/nibs/BookmarkNameFolder.xib b/chrome/app/nibs/BookmarkNameFolder.xib
index 82b8da5..7271553 100644
--- a/chrome/app/nibs/BookmarkNameFolder.xib
+++ b/chrome/app/nibs/BookmarkNameFolder.xib
@@ -162,7 +162,7 @@
<string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
</object>
<object class="NSCustomObject" id="352865609">
- <string key="NSClassName">BookmarkNameFolderLocalizer</string>
+ <string key="NSClassName">ChromeUILocalizer</string>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
@@ -352,9 +352,9 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{816, 841}, {480, 102}}</string>
+ <string>{{688, 841}, {480, 102}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{816, 841}, {480, 102}}</string>
+ <string>{{688, 841}, {480, 102}}</string>
<boolean value="NO"/>
<string>{196, 240}</string>
<string>{{357, 418}, {480, 270}}</string>
@@ -421,14 +421,6 @@
</object>
</object>
<object class="IBPartialClassDescription">
- <string key="className">BookmarkNameFolderLocalizer</string>
- <string key="superclassName">ChromeUILocalizer</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBProjectSource</string>
- <string key="minorKey">../xcodebuild/chrome.build/DerivedSources/Debug/xib_localizers/bookmark_name_folder_localizer.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
<string key="className">ChromeUILocalizer</string>
<string key="superclassName">GTMUILocalizer</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
diff --git a/chrome/app/nibs/TabView.xib b/chrome/app/nibs/TabView.xib
index 0a80d73..e7e0950 100644
--- a/chrome/app/nibs/TabView.xib
+++ b/chrome/app/nibs/TabView.xib
@@ -271,7 +271,7 @@
</object>
</object>
<object class="NSCustomObject" id="208901833">
- <string key="NSClassName">TabViewLocalizer</string>
+ <string key="NSClassName">ChromeUILocalizer</string>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
@@ -848,14 +848,6 @@
<string key="minorKey">browser/cocoa/tab_view.h</string>
</object>
</object>
- <object class="IBPartialClassDescription">
- <string key="className">TabViewLocalizer</string>
- <string key="superclassName">ChromeUILocalizer</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBProjectSource</string>
- <string key="minorKey">../xcodebuild/chrome.build/DerivedSources/Debug/xib_localizers/tab_view_localizer.h</string>
- </object>
- </object>
</object>
</object>
<int key="IBDocument.localizationMode">0</int>
diff --git a/chrome/app/nibs/Toolbar.xib b/chrome/app/nibs/Toolbar.xib
index ad59b58..190add7 100644
--- a/chrome/app/nibs/Toolbar.xib
+++ b/chrome/app/nibs/Toolbar.xib
@@ -8,8 +8,8 @@
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="88"/>
<integer value="4"/>
+ <integer value="88"/>
<integer value="102"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
@@ -673,7 +673,7 @@
</object>
</object>
<object class="NSCustomObject" id="1044322163">
- <string key="NSClassName">ToolbarLocalizer</string>
+ <string key="NSClassName">ChromeUILocalizer</string>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
@@ -1667,7 +1667,7 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{984, 816}, {306, 263}}</string>
+ <string>{{862, 816}, {306, 263}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -1796,6 +1796,14 @@
</object>
</object>
<object class="IBPartialClassDescription">
+ <string key="className">ChromeUILocalizer</string>
+ <string key="superclassName">GTMUILocalizer</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">browser/cocoa/ui_localizer.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
<string key="className">ClickHoldButtonCell</string>
<string key="superclassName">GradientButtonCell</string>
<object class="NSMutableDictionary" key="outlets">
@@ -1828,6 +1836,29 @@
</object>
</object>
<object class="IBPartialClassDescription">
+ <string key="className">GTMUILocalizer</string>
+ <string key="superclassName">NSObject</string>
+ <object class="NSMutableDictionary" key="outlets">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSMutableArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>otherObjectToLocalize_</string>
+ <string>owner_</string>
+ <string>yetAnotherObjectToLocalize_</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ </object>
+ </object>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">../third_party/GTM/AppKit/GTMUILocalizer.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
<string key="className">GradientButtonCell</string>
<string key="superclassName">NSButtonCell</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm
index 0cdee36..d7f4a97 100644
--- a/chrome/browser/app_controller_mac.mm
+++ b/chrome/browser/app_controller_mac.mm
@@ -24,6 +24,7 @@
#import "chrome/browser/cocoa/preferences_window_controller.h"
#import "chrome/browser/cocoa/tab_strip_controller.h"
#import "chrome/browser/cocoa/tab_window_controller.h"
+#import "chrome/browser/cocoa/ui_localizer.h"
#include "chrome/browser/command_updater.h"
#include "chrome/browser/download/download_manager.h"
#include "chrome/browser/sessions/tab_restore_service.h"
@@ -32,7 +33,6 @@
#include "chrome/browser/profile_manager.h"
#include "chrome/common/temp_scaffolding_stubs.h"
#include "grit/generated_resources.h"
-#import "xib_localizers/main_menu_localizer.h"
@interface AppController(PRIVATE)
- (void)initMenuState;
@@ -228,8 +228,8 @@
// 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<MainMenuLocalizer> localizer(
- [[MainMenuLocalizer alloc] initWithBundle:nil]);
+ scoped_nsobject<ChromeUILocalizer> localizer(
+ [[ChromeUILocalizer alloc] initWithBundle:nil]);
[localizer localizeObject:[NSApplication sharedApplication]
recursively:YES];
diff --git a/chrome/browser/cocoa/ui_localizer.h b/chrome/browser/cocoa/ui_localizer.h
index 50c480a..fc7b57b 100644
--- a/chrome/browser/cocoa/ui_localizer.h
+++ b/chrome/browser/cocoa/ui_localizer.h
@@ -5,30 +5,14 @@
#ifndef CHROME_BROWSER_COCOA_UI_LOCALIZER_H_
#define CHROME_BROWSER_COCOA_UI_LOCALIZER_H_
-#include "base/basictypes.h"
-#include "base/string16.h"
#import "third_party/GTM/AppKit/GTMUILocalizer.h"
@class NSString;
-namespace ui_localizer {
-
-struct ResourceMap {
- const char* const name;
- unsigned int label_id;
- unsigned int label_arg_id;
-};
-
-NSString* LocalizedStringForKeyFromMapList(NSString* key,
- const ResourceMap* map_list,
- size_t map_list_len);
-
-} // namespace ui_localizer
-
// A base class for generated localizers.
//
-// To use this, have the build run generate_localizer on your xib file (see
-// chrome.gyp). Then add an instance of the generated subclass to the xib.
+// To use this, include your xib file in the list generate_localizer scans (see
+// chrome.gyp). Then add an instance of ChromeUILocalizer to the xib.
// Connect the owner_ outlet of the instance to the "File's Owner" of the xib.
// It expects the owner_ outlet to be an instance or subclass of
// NSWindowController or NSViewController. It will then localize any items in
diff --git a/chrome/browser/cocoa/ui_localizer.mm b/chrome/browser/cocoa/ui_localizer.mm
index 7fd4d44..77e9154 100644
--- a/chrome/browser/cocoa/ui_localizer.mm
+++ b/chrome/browser/cocoa/ui_localizer.mm
@@ -6,53 +6,33 @@
#import <Foundation/Foundation.h>
+#include <stdlib.h>
#include "app/l10n_util_mac.h"
#include "base/sys_string_conversions.h"
#include "base/logging.h"
+#include "grit/app_strings.h"
+#include "grit/chromium_strings.h"
+#include "grit/generated_resources.h"
-namespace ui_localizer {
+struct UILocalizerResourceMap {
+ const char* const name;
+ unsigned int label_id;
+ unsigned int label_arg_id;
+};
-NSString* LocalizedStringForKeyFromMapList(NSString* key,
- const ResourceMap* map_list,
- size_t map_list_len) {
- DCHECK(key != nil);
- DCHECK(map_list != NULL);
- // Look up the string for the resource id to fetch.
- const char* utf8_key = [key UTF8String];
- if (utf8_key) {
- // If we end up with enough string constants in here, look at using bsearch
- // to speed up the searching.
- for (size_t i = 0; i < map_list_len; ++i) {
- int strcmp_result = strcmp(utf8_key, map_list[i].name);
- if (strcmp_result == 0) {
- // Do we need to build the string, or just fetch it?
- if (map_list[i].label_arg_id != 0) {
- const string16 label_arg(
- l10n_util::GetStringUTF16(map_list[i].label_arg_id));
- return l10n_util::GetNSStringFWithFixup(map_list[i].label_id,
- label_arg);
- }
-
- return l10n_util::GetNSStringWithFixup(map_list[i].label_id);
- }
-
- // If we've passed where the string would be, give up.
- if (strcmp_result < 0)
- break;
- }
- }
+namespace {
- // Sanity check, there shouldn't be any strings with this id that aren't
- // in our map.
- DLOG_IF(WARNING, [key hasPrefix:@"^ID"]) << "Key '" << utf8_key
- << "' wasn't in the resource map?";
-
- // If we didn't find anything, this string doesn't need localizing.
- return nil;
+// Utility function for bsearch on a ResourceMap table
+int ResourceMapCompare(const void* utf8Void,
+ const void* resourceMapVoid) {
+ const char* utf8_key = reinterpret_cast<const char*>(utf8Void);
+ const UILocalizerResourceMap* res_map =
+ reinterpret_cast<const UILocalizerResourceMap*> (resourceMapVoid);
+ return strcmp(utf8_key, res_map->name);
}
-} // namespace ui_localizer
+} // namespace
@interface GTMUILocalizer (PrivateAdditions)
- (void)localizedObjects;
@@ -69,17 +49,49 @@ NSString* LocalizedStringForKeyFromMapList(NSString* key,
@end
@implementation ChromeUILocalizer
+
- (void)awakeFromNib {
// The GTM base is bundle based, since don't need the bundle, use this
// override to bypass the bundle lookup and directly do the localization
// calls.
[self localizedObjects];
}
-#ifndef NDEBUG
-// Catch anyone that uses this directly.
+
- (NSString *)localizedStringForString:(NSString *)string {
- LOG(FATAL) << "Don't use ChromeUILocalizer directly.";
- return @"Don't use ChromeUILocalizer directly.";
+
+ // Include the table here so it is a local static. This header provides
+ // kUIResources and kUIResourcesSize.
+#include "ui_localizer_table.h"
+
+ // Look up the string for the resource id to fetch.
+ const char* utf8_key = [string UTF8String];
+ if (utf8_key) {
+ const void* valVoid = bsearch(utf8_key,
+ kUIResources,
+ kUIResourcesSize,
+ sizeof(UILocalizerResourceMap),
+ ResourceMapCompare);
+ const UILocalizerResourceMap* val =
+ reinterpret_cast<const UILocalizerResourceMap*>(valVoid);
+ if (val) {
+ // Do we need to build the string, or just fetch it?
+ if (val->label_arg_id != 0) {
+ const string16 label_arg(l10n_util::GetStringUTF16(val->label_arg_id));
+ return l10n_util::GetNSStringFWithFixup(val->label_id,
+ label_arg);
+ }
+
+ return l10n_util::GetNSStringWithFixup(val->label_id);
+ }
+
+ // Sanity check, there shouldn't be any strings with this id that aren't
+ // in our map.
+ DLOG_IF(WARNING, [string hasPrefix:@"^ID"]) << "Key '" << utf8_key
+ << "' wasn't in the resource map?";
+ }
+
+ // If we didn't find anything, this string doesn't need localizing.
+ return nil;
}
-#endif
+
@end
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index c963157..d84fa80 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -20,8 +20,6 @@
'../webkit/webkit.gyp:inspector_resources',
],
'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/chrome',
- 'mac_xib_localizer_tool_path': '<(DEPTH)/build/mac/generate_localizer',
- 'mac_xib_localizers_dir': '<(INTERMEDIATE_DIR)/xib_localizers',
# TODO(mmoss) This might need to go somewhere more general, then we can use
# it to also rewrite app/locales/locales.gyp with a helper script.
'locales': [
@@ -2091,87 +2089,36 @@
],
},
'actions': [
- # This block of actions are used to extract the localization data
- # from xib files and generate a localizer out of it.
{
+ # This action is used to extract the localization data from xib
+ # files and generate table for the ui localizer from it.
+ 'variables': {
+ 'xib_localizer_tool_path':
+ '<(DEPTH)/build/mac/generate_localizer',
+ 'xib_files_to_scan': [
+ # The xib that need localization
+ 'app/nibs/BookmarkBar.xib',
+ 'app/nibs/BookmarkEditor.xib',
+ 'app/nibs/BookmarkNameFolder.xib',
+ 'app/nibs/MainMenu.xib',
+ 'app/nibs/TabView.xib',
+ 'app/nibs/Toolbar.xib',
+ # TODO(tvl): add other xibs as needed
+ ],
+ },
'action_name': 'process_bookmark_bar_xib',
'process_outputs_as_sources': 1,
'inputs': [
- '<(mac_xib_localizer_tool_path)',
- 'app/nibs/BookmarkBar.xib'
- ],
- 'outputs': [
- '<(mac_xib_localizers_dir)/bookmark_bar_localizer.h',
- '<(mac_xib_localizers_dir)/bookmark_bar_localizer.mm',
- ],
- 'action': ['<@(_inputs)', '<@(_outputs)'],
- },
- {
- 'action_name': 'process_bookmark_editor_xib',
- 'process_outputs_as_sources': 1,
- 'inputs': [
- '<(mac_xib_localizer_tool_path)',
- 'app/nibs/BookmarkEditor.xib'
- ],
- 'outputs': [
- '<(mac_xib_localizers_dir)/bookmark_editor_localizer.h',
- '<(mac_xib_localizers_dir)/bookmark_editor_localizer.mm',
- ],
- 'action': ['<@(_inputs)', '<@(_outputs)'],
- },
- {
- 'action_name': 'process_bookmark_name_folder_xib',
- 'process_outputs_as_sources': 1,
- 'inputs': [
- '<(mac_xib_localizer_tool_path)',
- 'app/nibs/BookmarkNameFolder.xib'
- ],
- 'outputs': [
- '<(mac_xib_localizers_dir)/bookmark_name_folder_localizer.h',
- '<(mac_xib_localizers_dir)/bookmark_name_folder_localizer.mm',
- ],
- 'action': ['<@(_inputs)', '<@(_outputs)'],
- },
- {
- 'action_name': 'process_mainmenu_xib',
- 'process_outputs_as_sources': 1,
- 'inputs': [
- '<(mac_xib_localizer_tool_path)',
- 'app/nibs/MainMenu.xib'
- ],
- 'outputs': [
- '<(mac_xib_localizers_dir)/main_menu_localizer.h',
- '<(mac_xib_localizers_dir)/main_menu_localizer.mm',
- ],
- 'action': ['<@(_inputs)', '<@(_outputs)'],
- },
- {
- 'action_name': 'process_tab_view_xib',
- 'process_outputs_as_sources': 1,
- 'inputs': [
- '<(mac_xib_localizer_tool_path)',
- 'app/nibs/TabView.xib'
- ],
- 'outputs': [
- '<(mac_xib_localizers_dir)/tab_view_localizer.h',
- '<(mac_xib_localizers_dir)/tab_view_localizer.mm',
- ],
- 'action': ['<@(_inputs)', '<@(_outputs)'],
- },
- {
- 'action_name': 'process_toolbar_xib',
- 'process_outputs_as_sources': 1,
- 'inputs': [
- '<(mac_xib_localizer_tool_path)',
- 'app/nibs/Toolbar.xib'
+ '<(xib_localizer_tool_path)',
+ '<@(xib_files_to_scan)',
],
'outputs': [
- '<(mac_xib_localizers_dir)/toolbar_localizer.h',
- '<(mac_xib_localizers_dir)/toolbar_localizer.mm',
+ '<(INTERMEDIATE_DIR)/ui_localizer_table.h',
],
- 'action': ['<@(_inputs)', '<@(_outputs)'],
+ 'action': ['<(xib_localizer_tool_path)',
+ '<@(_outputs)',
+ '<@(xib_files_to_scan)'],
},
- # TODO(tvl): add other xibs
],
}],
['OS=="win"', {