diff options
-rw-r--r-- | tools/grit/grit/format/js_map_format.py | 7 | ||||
-rw-r--r-- | tools/grit/grit/format/js_map_format_unittest.py | 6 | ||||
-rw-r--r-- | webkit/glue/devtools/js/devtools.js | 40 | ||||
-rw-r--r-- | webkit/glue/devtools/js/devtools_host_stub.js | 6 | ||||
-rw-r--r-- | webkit/glue/devtools/js/inspector_controller_impl.js | 4 | ||||
-rwxr-xr-x | webkit/tools/build/merge_localized_strings.py | 154 | ||||
-rw-r--r-- | webkit/webkit.gyp | 131 |
7 files changed, 86 insertions, 262 deletions
diff --git a/tools/grit/grit/format/js_map_format.py b/tools/grit/grit/format/js_map_format.py index ac7d47f..94efb6b 100644 --- a/tools/grit/grit/format/js_map_format.py +++ b/tools/grit/grit/format/js_map_format.py @@ -25,7 +25,7 @@ class TopLevel(interface.ItemFormatter): if not begin_item: return '' else: - return '''// Copyright %d Google Inc. All Rights Reserved. + return '''// Copyright %d Google Inc. All Rights Reserved. // This file is automatically generated by GRIT. Do not edit. ''' % (util.GetCurrentYear()) @@ -35,10 +35,7 @@ class StringTable(interface.ItemFormatter): def Format(self, item, lang='en', begin_item=True, output_dir='.'): if begin_item: - return ''' -// Check to see if already defined in current scope. -var localizedStrings = localizedStrings || {}; -''' + return '' else: return '\n' diff --git a/tools/grit/grit/format/js_map_format_unittest.py b/tools/grit/grit/format/js_map_format_unittest.py index 0ed7fd3..fcd812b 100644 --- a/tools/grit/grit/format/js_map_format_unittest.py +++ b/tools/grit/grit/format/js_map_format_unittest.py @@ -51,9 +51,6 @@ class JsMapFormatUnittest(unittest.TestCase): build.RcBuilder.ProcessNode(root, DummyOutput('js_map_format', 'en'), buf) output = buf.getvalue() test = u""" -// Check to see if already defined in current scope. -var localizedStrings = localizedStrings || {}; - localizedStrings["Simple message."] = "Simple message."; localizedStrings["element\u2019s \u201c%s\u201d attribute"] = "element\u2019s \u201c%s\u201d attribute"; localizedStrings["%d error, %d warning"] = "%1$d error, %2$d warning"; @@ -76,9 +73,6 @@ localizedStrings["A \\\"double quoted\\\" message."] = "A \\\"double quoted\\\" build.RcBuilder.ProcessNode(root, DummyOutput('js_map_format', 'fr'), buf) output = buf.getvalue() test = u""" -// Check to see if already defined in current scope. -var localizedStrings = localizedStrings || {}; - localizedStrings["Hello!"] = "H\xe9P\xe9ll\xf4P\xf4!"; localizedStrings["Hello %s"] = "H\xe9P\xe9ll\xf4P\xf4 %s"; """ diff --git a/webkit/glue/devtools/js/devtools.js b/webkit/glue/devtools/js/devtools.js index e8e63ca..830895e 100644 --- a/webkit/glue/devtools/js/devtools.js +++ b/webkit/glue/devtools/js/devtools.js @@ -153,8 +153,26 @@ var context = {}; // Used by WebCore's inspector routines. /////////////////////////////////////////////////////////////////////////////// // Here and below are overrides to existing WebInspector methods only. // TODO(pfeldman): Patch WebCore and upstream changes. +(function () { + var oldLoaded = WebInspector.loaded; -WebInspector.loaded = function() { + +function loadDevToolsStrings() { + var locale = DevToolsHost.getApplicationLocale(); + locale = locale.replace('_', '-'); + + var devtoolsStringsScriptElement = document.createElement('script'); + devtoolsStringsScriptElement.addEventListener( + "load", + devToolsHandleLoaded.bind(WebInspector), + false); + devtoolsStringsScriptElement.type = 'text/javascript'; + devtoolsStringsScriptElement.src = 'l10n/devtoolsStrings_' + locale + '.js'; + document.getElementsByTagName("head").item(0).appendChild( + devtoolsStringsScriptElement); +}; + +function devToolsHandleLoaded() { devtools.tools = new devtools.ToolsAgent(); devtools.tools.reset(); @@ -180,6 +198,17 @@ WebInspector.loaded = function() { DevToolsHost.loaded(); }; +// l10n is turned off in tests mode because delayed loading of strings +// causes test failures. +if (!window.___interactiveUiTestsMode) { + window.localizedStrings = {}; + WebInspector.loaded = loadDevToolsStrings; +} else { + WebInspector.loaded = devToolsHandleLoaded; +} + +})(); + var webkitUpdateChildren = WebInspector.ElementsTreeElement.prototype.updateChildren; @@ -533,15 +562,6 @@ WebInspector.ScriptsPanel.prototype.doEvalInCallFrame = })(); -/* - * @override - * TODO(mnaganov): Restore l10n when it will be agreed that it is needed. - */ -WebInspector.UIString = function(string) { - return String.vsprintf(string, Array.prototype.slice.call(arguments, 1)); -}; - - // There is no clear way of setting frame title yet. So sniffing main resource // load. (function OverrideUpdateResource() { diff --git a/webkit/glue/devtools/js/devtools_host_stub.js b/webkit/glue/devtools/js/devtools_host_stub.js index 7365bea..5142bbe 100644 --- a/webkit/glue/devtools/js/devtools_host_stub.js +++ b/webkit/glue/devtools/js/devtools_host_stub.js @@ -255,6 +255,11 @@ RemoteDebuggerCommandExecutorStub.prototype.sendResponse_ = function(response) { */ DevToolsHostStub = function() { this.isStub = true; + window.domAutomationController = { + send: function(text) { + debugPrint(text); + } + }; }; @@ -289,6 +294,7 @@ function addDummyResource() { DevToolsHostStub.prototype.loaded = function() { addDummyResource(); + uiTests.runAllTests(); }; diff --git a/webkit/glue/devtools/js/inspector_controller_impl.js b/webkit/glue/devtools/js/inspector_controller_impl.js index 53ee61f..a3b6d98 100644 --- a/webkit/glue/devtools/js/inspector_controller_impl.js +++ b/webkit/glue/devtools/js/inspector_controller_impl.js @@ -109,10 +109,10 @@ devtools.InspectorControllerImpl.prototype.toggleNodeSearch = function() { devtools.InspectorControllerImpl.prototype.localizedStringsURL = function() { // l10n is turned off in test mode because delayed loading of strings // causes test failures. - if (false) { + if (!window.___interactiveUiTestsMode) { var locale = DevToolsHost.getApplicationLocale(); locale = locale.replace('_', '-'); - return 'l10n/localizedStrings_' + locale + '.js'; + return 'l10n/inspectorStrings_' + locale + '.js'; } else { return undefined; } diff --git a/webkit/tools/build/merge_localized_strings.py b/webkit/tools/build/merge_localized_strings.py deleted file mode 100755 index ed1a501..0000000 --- a/webkit/tools/build/merge_localized_strings.py +++ /dev/null @@ -1,154 +0,0 @@ -#!/usr/bin/env python -# 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. - -"""Helper script to merge DevTools' localized strings for a list of locales. - -Gyp doesn't have any built-in looping capability, so this just provides a way to -loop over a list of locales. -""" - -import getopt -import os -import sys - -GRIT_DIR = None -L10N_OUT_DIR = None - - -class Usage(Exception): - def __init__(self, msg): - self.msg = msg - - -def calc_output(locale): - """Determine the file that will be generated for the given locale.""" - #e.g. '<(PRODUCT_DIR)/resources/inspector/l10n/localizedStrings_da.js', - return '%s/localizedStrings_%s.js' % (L10N_OUT_DIR, locale) - - -def calc_inputs(locale): - """Determine the files that need processing for the given locale.""" - inputs = [] - - #e.g. '<(grit_out_dir)/inspectorStrings_da.pak' - inputs.append('%s/inspectorStrings_%s.js' % (GRIT_DIR, locale)) - - #e.g. '<(grit_out_dir)/devtoolsStrings_da.pak' - inputs.append('%s/devtoolsStrings_%s.js' % (GRIT_DIR, locale)) - - return inputs - - -def list_outputs(locales): - """Print the names of files that will be generated for the given locales. - - This is to provide gyp the list of output files, so build targets can - properly track what needs to be built. - """ - outputs = [] - for locale in locales: - outputs.append(calc_output(locale)) - # Quote each element so filename spaces don't mess up gyp's attempt to parse - # it into a list. - print " ".join(['"%s"' % x for x in outputs]) - - -def list_inputs(locales): - """Print the names of files that will be processed for the given locales. - - This is to provide gyp the list of input files, so build targets can properly - track their prerequisites. - """ - inputs = [] - for locale in locales: - inputs += calc_inputs(locale) - # Quote each element so filename spaces don't mess up gyp's attempt to parse - # it into a list. - print " ".join(['"%s"' % x for x in inputs]) - - -def merge_localized_strings(locales): - """ Loop over and repack the given locales.""" - for locale in locales: - inputs = [] - inputs += calc_inputs(locale) - output = calc_output(locale) - print 'Merging %s -> %s' % (inputs, output) - out = open(output, 'w') - for inp in inputs: - out.write('\n// %s\n\n' % (inp)) - out.write(open(inp).read()) - out.close() - - -def main(argv=None): - global GRIT_DIR - global L10N_OUT_DIR - - if argv is None: - argv = sys.argv - - short_options = 'iog:l:h' - long_options = 'help' - - print_inputs = False - print_outputs = False - usage_msg = '' - - helpstr = """\ -Usage: %s [-h] [-i | -o] -g <DIR> -l <DIR> <locale> [...] - -h, --help Print this help, then exit. - -i Print the expected input file list, then exit. - -o Print the expected output file list, then exit. - -g DIR GRIT build files output directory. - -l DIR Output dir for l10n files. - locale [...] One or more locales.""" % (argv[0]) - - try: - try: - opts, locales = getopt.getopt(argv[1:], short_options, long_options) - except getopt.GetoptError, msg: - raise Usage(str(msg)) - - if not locales: - usage_msg = 'Please specificy at least one locale to process.\n' - - for o, a in opts: - if o in ('-i'): - print_inputs = True - elif o in ('-o'): - print_outputs = True - elif o in ('-g'): - GRIT_DIR = a - elif o in ('-l'): - L10N_OUT_DIR = a - elif o in ('-h', '--help'): - print helpstr - return 0 - - if not (GRIT_DIR and L10N_OUT_DIR): - usage_msg += 'Please specify "-g" and "-l".\n' - if print_inputs and print_outputs: - usage_msg += 'Please specify only one of "-i" or "-o".\n' - - if usage_msg: - raise Usage(usage_msg) - except Usage, err: - sys.stderr.write(err.msg + '\n') - sys.stderr.write(helpstr + '\n') - return 2 - - if print_inputs: - list_inputs(locales) - return 0 - - if print_outputs: - list_outputs(locales) - return 0 - - merge_localized_strings(locales) - -if __name__ == '__main__': - sys.exit(main(sys.argv)) diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp index 7191e32d..c228e47 100644 --- a/webkit/webkit.gyp +++ b/webkit/webkit.gyp @@ -1254,8 +1254,9 @@ 'msvs_guid': 'C66B126D-0ECE-4CA2-B6DC-FA780AFBBF09', 'dependencies': [ '../net/net.gyp:net', + 'devtools_strings', 'inspector_resources', - 'localized_strings', + 'inspector_strings', 'webcore', 'webkit', 'webkit_resources', @@ -1578,32 +1579,32 @@ 'type': 'none', 'msvs_guid': '14F3FA5A-C401-4A7F-8F25-C23739D1C0BE', 'variables': { - 'grit_path': '../tools/grit/grit.py', - 'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/webkit/glue/inspector', + 'grit_path': '../tools/grit/grit.py', + 'grit_out_dir': '<(PRODUCT_DIR)/resources/inspector/l10n', }, 'actions': [ - { - 'action_name': 'inspector_strings', - 'variables': { - 'input_path': 'glue/inspector_strings.grd', - }, - 'inputs': [ - '<(input_path)', - ], - 'outputs': [ - '<(grit_out_dir)/inspectorStrings_da.js', - '<(grit_out_dir)/inspectorStrings_en-US.js', - '<(grit_out_dir)/inspectorStrings_he.js', - '<(grit_out_dir)/inspectorStrings_zh-TW.js', - ], - 'action': ['python', '<(grit_path)', '-i', '<(input_path)', 'build', '-o', '<(grit_out_dir)'], - 'message': 'Generating resources from <(input_path)', - }, + { + 'action_name': 'inspector_strings', + 'variables': { + 'input_path': 'glue/inspector_strings.grd', + }, + 'inputs': [ + '<(input_path)', + ], + 'outputs': [ + '<(grit_out_dir)/inspectorStrings_da.js', + '<(grit_out_dir)/inspectorStrings_en-US.js', + '<(grit_out_dir)/inspectorStrings_he.js', + '<(grit_out_dir)/inspectorStrings_zh-TW.js', + ], + 'action': ['python', '<(grit_path)', '-i', '<(input_path)', 'build', '-o', '<(grit_out_dir)'], + 'message': 'Generating resources from <(input_path)', + }, ], 'conditions': [ - ['OS=="win"', { - 'dependencies': ['../build/win/system.gyp:cygwin'], - }], + ['OS=="win"', { + 'dependencies': ['../build/win/system.gyp:cygwin'], + }], ], }, { @@ -1611,72 +1612,32 @@ 'type': 'none', 'msvs_guid': 'AE42E1EB-E848-4FD2-B42F-800604062918', 'variables': { - 'grit_path': '../tools/grit/grit.py', - 'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/webkit/glue/inspector', - }, - 'actions': [ - { - 'action_name': 'devtools_strings', - 'variables': { - 'input_path': 'glue/devtools_strings.grd', - }, - 'inputs': [ - '<(input_path)', - ], - 'outputs': [ - '<(grit_out_dir)/devtoolsStrings_da.js', - '<(grit_out_dir)/devtoolsStrings_en-US.js', - '<(grit_out_dir)/devtoolsStrings_he.js', - '<(grit_out_dir)/devtoolsStrings_zh-TW.js', - ], - 'action': ['python', '<(grit_path)', '-i', '<(input_path)', 'build', '-o', '<(grit_out_dir)'], - 'message': 'Generating resources from <(input_path)', - }, - ], - 'conditions': [ - ['OS=="win"', { - 'dependencies': ['../build/win/system.gyp:cygwin'], - }], - ], - }, - { - 'target_name': 'localized_strings', - 'type': 'none', - 'msvs_guid': '6CC1A748-A343-4469-BB17-11038E354858', - 'dependencies': [ - 'inspector_strings', - 'devtools_strings', - ], - 'variables': { - 'merge_strings_cmd': ['python', 'tools/build/merge_localized_strings.py',], - 'l10n_out_dir': '<(PRODUCT_DIR)/resources/inspector/l10n', - # TODO(mnaganov): use the same list as in 'chrome.gyp'. - 'locales': ['en-US',], + 'grit_path': '../tools/grit/grit.py', + 'grit_out_dir': '<(PRODUCT_DIR)/resources/inspector/l10n', }, 'actions': [ - { - 'action_name': 'localized_strings', - 'variables': { - 'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/webkit/glue/inspector', - }, - 'inputs': [ - 'tools/build/merge_localized_strings.py', - '>!@(<@(merge_strings_cmd) -i -g \'<(grit_out_dir)\' -l \'<(l10n_out_dir)\' <@(locales))', - ], - 'outputs': [ - '>!@(<@(merge_strings_cmd) -o -g \'<(grit_out_dir)\' -l \'<(l10n_out_dir)\' <@(locales))', - ], - 'action': ['<@(merge_strings_cmd)', - '-g', '<(grit_out_dir)', - '-l', '<(l10n_out_dir)', - '<@(locales)'], - 'message': 'Merging localized strings', - }, + { + 'action_name': 'devtools_strings', + 'variables': { + 'input_path': 'glue/devtools_strings.grd', + }, + 'inputs': [ + '<(input_path)', + ], + 'outputs': [ + '<(grit_out_dir)/devtoolsStrings_da.js', + '<(grit_out_dir)/devtoolsStrings_en-US.js', + '<(grit_out_dir)/devtoolsStrings_he.js', + '<(grit_out_dir)/devtoolsStrings_zh-TW.js', + ], + 'action': ['python', '<(grit_path)', '-i', '<(input_path)', 'build', '-o', '<(grit_out_dir)'], + 'message': 'Generating resources from <(input_path)', + }, ], 'conditions': [ - ['OS=="win"', { - 'dependencies': ['../build/win/system.gyp:cygwin'], - }], + ['OS=="win"', { + 'dependencies': ['../build/win/system.gyp:cygwin'], + }], ], }, ], |