summaryrefslogtreecommitdiffstats
path: root/webkit/glue
diff options
context:
space:
mode:
authormnaganov@chromium.org <mnaganov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-21 10:10:22 +0000
committermnaganov@chromium.org <mnaganov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-21 10:10:22 +0000
commita88ddbb945448faf756c8820c4a74cae2f236c14 (patch)
treeca64167234e0004ed9e90137c7134bf5a43e652d /webkit/glue
parent7cf9303dad039b26932f7c447b6d2647919f363e (diff)
downloadchromium_src-a88ddbb945448faf756c8820c4a74cae2f236c14.zip
chromium_src-a88ddbb945448faf756c8820c4a74cae2f236c14.tar.gz
chromium_src-a88ddbb945448faf756c8820c4a74cae2f236c14.tar.bz2
DevTools l10n: generate localized strings and use them.
Reapplying r23820, this time interactive UI tests should not fail. BUG=none TEST=none Review URL: http://codereview.chromium.org/174216 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23950 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r--webkit/glue/devtools/js/devtools.js41
-rw-r--r--webkit/glue/devtools/js/devtools_host_stub.js5
-rw-r--r--webkit/glue/devtools/js/inspector_controller_impl.js16
-rw-r--r--webkit/glue/devtools/js/tests.js1
-rw-r--r--webkit/glue/devtools_strings.grd60
-rw-r--r--webkit/glue/inspector_strings.grd60
-rw-r--r--webkit/glue/webdevtoolsclient.h3
-rw-r--r--webkit/glue/webdevtoolsclient_impl.cc22
-rw-r--r--webkit/glue/webdevtoolsclient_impl.h6
9 files changed, 182 insertions, 32 deletions
diff --git a/webkit/glue/devtools/js/devtools.js b/webkit/glue/devtools/js/devtools.js
index b5e817a..db94bbd 100644
--- a/webkit/glue/devtools/js/devtools.js
+++ b/webkit/glue/devtools/js/devtools.js
@@ -150,12 +150,29 @@ devtools.tools = null;
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();
@@ -181,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;
@@ -534,15 +562,6 @@ WebInspector.ScriptsPanel.prototype.doEvalInCallFrame =
})();
-/**
- * @override
- * TODO(pfeldman): Add l10n.
- */
-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 0c84e5e..5142bbe 100644
--- a/webkit/glue/devtools/js/devtools_host_stub.js
+++ b/webkit/glue/devtools/js/devtools_host_stub.js
@@ -317,6 +317,11 @@ DevToolsHostStub.prototype.addSourceToFrame = function(mimeType, source,
};
+DevToolsHostStub.prototype.getApplicationLocale = function() {
+ return "en-US";
+};
+
+
if (!window['DevToolsHost']) {
window['RemoteDebuggerAgent'] = new RemoteDebuggerAgentStub();
window['RemoteDebuggerCommandExecutor'] =
diff --git a/webkit/glue/devtools/js/inspector_controller_impl.js b/webkit/glue/devtools/js/inspector_controller_impl.js
index 03b2ee2..a3b6d98 100644
--- a/webkit/glue/devtools/js/inspector_controller_impl.js
+++ b/webkit/glue/devtools/js/inspector_controller_impl.js
@@ -106,6 +106,22 @@ devtools.InspectorControllerImpl.prototype.toggleNodeSearch = function() {
/**
* {@inheritDoc}.
*/
+devtools.InspectorControllerImpl.prototype.localizedStringsURL = function() {
+ // l10n is turned off in test mode because delayed loading of strings
+ // causes test failures.
+ if (!window.___interactiveUiTestsMode) {
+ var locale = DevToolsHost.getApplicationLocale();
+ locale = locale.replace('_', '-');
+ return 'l10n/inspectorStrings_' + locale + '.js';
+ } else {
+ return undefined;
+ }
+};
+
+
+/**
+ * {@inheritDoc}.
+ */
devtools.InspectorControllerImpl.prototype.addSourceToFrame =
function(mimeType, source, element) {
return DevToolsHost.addSourceToFrame(mimeType, source, element);
diff --git a/webkit/glue/devtools/js/tests.js b/webkit/glue/devtools/js/tests.js
index d2fbe71..f846685 100644
--- a/webkit/glue/devtools/js/tests.js
+++ b/webkit/glue/devtools/js/tests.js
@@ -12,6 +12,7 @@
if (window.domAutomationController) {
+var ___interactiveUiTestsMode = true;
/**
* Test suite for interactive UI tests.
diff --git a/webkit/glue/devtools_strings.grd b/webkit/glue/devtools_strings.grd
index 5826409..4dc6fc0 100644
--- a/webkit/glue/devtools_strings.grd
+++ b/webkit/glue/devtools_strings.grd
@@ -5,14 +5,58 @@ Google Chrome Developer Tools. -->
<grit base_dir="." latest_public_release="0" current_release="1"
source_lang_id="en" enc_check="möl">
<outputs>
- <!-- TODO add each of your output files. Modify the three below, and add
- your own for your various languages. See the user's guide
- (http://wiki/Main/GritUsersGuide) for mor details.
- Note that all output references are relative to the output directory
- which is specified at build time. -->
- <!--
- <output filename="localizedStrings_en.js" type="js_map_format" lang="en" />
- -->
+ <output filename="devtoolsStrings_ar.js" type="js_map_format" lang="ar" />
+ <output filename="devtoolsStrings_bg.js" type="js_map_format" lang="bg" />
+ <output filename="devtoolsStrings_bn.js" type="js_map_format" lang="bn" />
+ <output filename="devtoolsStrings_ca.js" type="js_map_format" lang="ca" />
+ <output filename="devtoolsStrings_cs.js" type="js_map_format" lang="cs" />
+ <output filename="devtoolsStrings_da.js" type="js_map_format" lang="da" />
+ <output filename="devtoolsStrings_de.js" type="js_map_format" lang="de" />
+ <output filename="devtoolsStrings_el.js" type="js_map_format" lang="el" />
+ <output filename="devtoolsStrings_en-GB.js" type="js_map_format" lang="en-GB" />
+ <output filename="devtoolsStrings_en-US.js" type="js_map_format" lang="en" />
+ <output filename="devtoolsStrings_es.js" type="js_map_format" lang="es" />
+ <output filename="devtoolsStrings_es-419.js" type="js_map_format" lang="es-419" />
+ <output filename="devtoolsStrings_et.js" type="js_map_format" lang="et" />
+ <output filename="devtoolsStrings_fi.js" type="js_map_format" lang="fi" />
+ <output filename="devtoolsStrings_fil.js" type="js_map_format" lang="fil" />
+ <output filename="devtoolsStrings_fr.js" type="js_map_format" lang="fr" />
+ <output filename="devtoolsStrings_gu.js" type="js_map_format" lang="gu" />
+ <output filename="devtoolsStrings_he.js" type="js_map_format" lang="he" />
+ <output filename="devtoolsStrings_hi.js" type="js_map_format" lang="hi" />
+ <output filename="devtoolsStrings_hr.js" type="js_map_format" lang="hr" />
+ <output filename="devtoolsStrings_hu.js" type="js_map_format" lang="hu" />
+ <output filename="devtoolsStrings_id.js" type="js_map_format" lang="id" />
+ <output filename="devtoolsStrings_it.js" type="js_map_format" lang="it" />
+ <output filename="devtoolsStrings_ja.js" type="js_map_format" lang="ja" />
+ <output filename="devtoolsStrings_kn.js" type="js_map_format" lang="kn" />
+ <output filename="devtoolsStrings_ko.js" type="js_map_format" lang="ko" />
+ <output filename="devtoolsStrings_lt.js" type="js_map_format" lang="lt" />
+ <output filename="devtoolsStrings_lv.js" type="js_map_format" lang="lv" />
+ <output filename="devtoolsStrings_ml.js" type="js_map_format" lang="ml" />
+ <output filename="devtoolsStrings_mr.js" type="js_map_format" lang="mr" />
+ <output filename="devtoolsStrings_nl.js" type="js_map_format" lang="nl" />
+ <!-- The translation console uses 'no' for Norwegian Bokmål. It should
+ be 'nb'. -->
+ <output filename="devtoolsStrings_nb.js" type="js_map_format" lang="no" />
+ <output filename="devtoolsStrings_or.js" type="js_map_format" lang="or" />
+ <output filename="devtoolsStrings_pl.js" type="js_map_format" lang="pl" />
+ <output filename="devtoolsStrings_pt-BR.js" type="js_map_format" lang="pt-BR" />
+ <output filename="devtoolsStrings_pt-PT.js" type="js_map_format" lang="pt-PT" />
+ <output filename="devtoolsStrings_ro.js" type="js_map_format" lang="ro" />
+ <output filename="devtoolsStrings_ru.js" type="js_map_format" lang="ru" />
+ <output filename="devtoolsStrings_sk.js" type="js_map_format" lang="sk" />
+ <output filename="devtoolsStrings_sl.js" type="js_map_format" lang="sl" />
+ <output filename="devtoolsStrings_sr.js" type="js_map_format" lang="sr" />
+ <output filename="devtoolsStrings_sv.js" type="js_map_format" lang="sv" />
+ <output filename="devtoolsStrings_ta.js" type="js_map_format" lang="ta" />
+ <output filename="devtoolsStrings_te.js" type="js_map_format" lang="te" />
+ <output filename="devtoolsStrings_th.js" type="js_map_format" lang="th" />
+ <output filename="devtoolsStrings_tr.js" type="js_map_format" lang="tr" />
+ <output filename="devtoolsStrings_uk.js" type="js_map_format" lang="uk" />
+ <output filename="devtoolsStrings_vi.js" type="js_map_format" lang="vi" />
+ <output filename="devtoolsStrings_zh-CN.js" type="js_map_format" lang="zh-CN" />
+ <output filename="devtoolsStrings_zh-TW.js" type="js_map_format" lang="zh-TW" />
</outputs>
<translations>
<!-- TODO add references to each of the XTB files (from the Translation
diff --git a/webkit/glue/inspector_strings.grd b/webkit/glue/inspector_strings.grd
index 48ac67d..c49fcdc 100644
--- a/webkit/glue/inspector_strings.grd
+++ b/webkit/glue/inspector_strings.grd
@@ -41,14 +41,58 @@ so we include the original license below:
<grit base_dir="." latest_public_release="0" current_release="1"
source_lang_id="en" enc_check="möl">
<outputs>
- <!-- TODO add each of your output files. Modify the three below, and add
- your own for your various languages. See the user's guide
- (http://wiki/Main/GritUsersGuide) for mor details.
- Note that all output references are relative to the output directory
- which is specified at build time. -->
- <!--
- <output filename="localizedStrings_en.js" type="js_map_format" lang="en" />
- -->
+ <output filename="inspectorStrings_ar.js" type="js_map_format" lang="ar" />
+ <output filename="inspectorStrings_bg.js" type="js_map_format" lang="bg" />
+ <output filename="inspectorStrings_bn.js" type="js_map_format" lang="bn" />
+ <output filename="inspectorStrings_ca.js" type="js_map_format" lang="ca" />
+ <output filename="inspectorStrings_cs.js" type="js_map_format" lang="cs" />
+ <output filename="inspectorStrings_da.js" type="js_map_format" lang="da" />
+ <output filename="inspectorStrings_de.js" type="js_map_format" lang="de" />
+ <output filename="inspectorStrings_el.js" type="js_map_format" lang="el" />
+ <output filename="inspectorStrings_en-GB.js" type="js_map_format" lang="en-GB" />
+ <output filename="inspectorStrings_en-US.js" type="js_map_format" lang="en" />
+ <output filename="inspectorStrings_es.js" type="js_map_format" lang="es" />
+ <output filename="inspectorStrings_es-419.js" type="js_map_format" lang="es-419" />
+ <output filename="inspectorStrings_et.js" type="js_map_format" lang="et" />
+ <output filename="inspectorStrings_fi.js" type="js_map_format" lang="fi" />
+ <output filename="inspectorStrings_fil.js" type="js_map_format" lang="fil" />
+ <output filename="inspectorStrings_fr.js" type="js_map_format" lang="fr" />
+ <output filename="inspectorStrings_gu.js" type="js_map_format" lang="gu" />
+ <output filename="inspectorStrings_he.js" type="js_map_format" lang="he" />
+ <output filename="inspectorStrings_hi.js" type="js_map_format" lang="hi" />
+ <output filename="inspectorStrings_hr.js" type="js_map_format" lang="hr" />
+ <output filename="inspectorStrings_hu.js" type="js_map_format" lang="hu" />
+ <output filename="inspectorStrings_id.js" type="js_map_format" lang="id" />
+ <output filename="inspectorStrings_it.js" type="js_map_format" lang="it" />
+ <output filename="inspectorStrings_ja.js" type="js_map_format" lang="ja" />
+ <output filename="inspectorStrings_kn.js" type="js_map_format" lang="kn" />
+ <output filename="inspectorStrings_ko.js" type="js_map_format" lang="ko" />
+ <output filename="inspectorStrings_lt.js" type="js_map_format" lang="lt" />
+ <output filename="inspectorStrings_lv.js" type="js_map_format" lang="lv" />
+ <output filename="inspectorStrings_ml.js" type="js_map_format" lang="ml" />
+ <output filename="inspectorStrings_mr.js" type="js_map_format" lang="mr" />
+ <output filename="inspectorStrings_nl.js" type="js_map_format" lang="nl" />
+ <!-- The translation console uses 'no' for Norwegian Bokmål. It should
+ be 'nb'. -->
+ <output filename="inspectorStrings_nb.js" type="js_map_format" lang="no" />
+ <output filename="inspectorStrings_or.js" type="js_map_format" lang="or" />
+ <output filename="inspectorStrings_pl.js" type="js_map_format" lang="pl" />
+ <output filename="inspectorStrings_pt-BR.js" type="js_map_format" lang="pt-BR" />
+ <output filename="inspectorStrings_pt-PT.js" type="js_map_format" lang="pt-PT" />
+ <output filename="inspectorStrings_ro.js" type="js_map_format" lang="ro" />
+ <output filename="inspectorStrings_ru.js" type="js_map_format" lang="ru" />
+ <output filename="inspectorStrings_sk.js" type="js_map_format" lang="sk" />
+ <output filename="inspectorStrings_sl.js" type="js_map_format" lang="sl" />
+ <output filename="inspectorStrings_sr.js" type="js_map_format" lang="sr" />
+ <output filename="inspectorStrings_sv.js" type="js_map_format" lang="sv" />
+ <output filename="inspectorStrings_ta.js" type="js_map_format" lang="ta" />
+ <output filename="inspectorStrings_te.js" type="js_map_format" lang="te" />
+ <output filename="inspectorStrings_th.js" type="js_map_format" lang="th" />
+ <output filename="inspectorStrings_tr.js" type="js_map_format" lang="tr" />
+ <output filename="inspectorStrings_uk.js" type="js_map_format" lang="uk" />
+ <output filename="inspectorStrings_vi.js" type="js_map_format" lang="vi" />
+ <output filename="inspectorStrings_zh-CN.js" type="js_map_format" lang="zh-CN" />
+ <output filename="inspectorStrings_zh-TW.js" type="js_map_format" lang="zh-TW" />
</outputs>
<translations>
<!-- TODO add references to each of the XTB files (from the Translation
diff --git a/webkit/glue/webdevtoolsclient.h b/webkit/glue/webdevtoolsclient.h
index 1e9d3c0..4e36a54 100644
--- a/webkit/glue/webdevtoolsclient.h
+++ b/webkit/glue/webdevtoolsclient.h
@@ -17,7 +17,8 @@ class WebDevToolsClient {
public:
static WebDevToolsClient* Create(
WebView* view,
- WebDevToolsClientDelegate* delegate);
+ WebDevToolsClientDelegate* delegate,
+ const std::string& application_locale);
WebDevToolsClient() {}
virtual ~WebDevToolsClient() {}
diff --git a/webkit/glue/webdevtoolsclient_impl.cc b/webkit/glue/webdevtoolsclient_impl.cc
index 1194045..70703c4 100644
--- a/webkit/glue/webdevtoolsclient_impl.cc
+++ b/webkit/glue/webdevtoolsclient_impl.cc
@@ -128,15 +128,20 @@ class RemoteDebuggerCommandExecutor : public CppBoundClass {
// static
WebDevToolsClient* WebDevToolsClient::Create(
WebView* view,
- WebDevToolsClientDelegate* delegate) {
- return new WebDevToolsClientImpl(static_cast<WebViewImpl*>(view), delegate);
+ WebDevToolsClientDelegate* delegate,
+ const std::string& application_locale) {
+ return new WebDevToolsClientImpl(static_cast<WebViewImpl*>(view),
+ delegate,
+ application_locale);
}
WebDevToolsClientImpl::WebDevToolsClientImpl(
WebViewImpl* web_view_impl,
- WebDevToolsClientDelegate* delegate)
+ WebDevToolsClientDelegate* delegate,
+ const std::string& application_locale)
: web_view_impl_(web_view_impl),
delegate_(delegate),
+ application_locale_(application_locale.c_str()),
loaded_(false) {
WebFrameImpl* frame = web_view_impl_->main_frame();
@@ -184,6 +189,9 @@ WebDevToolsClientImpl::WebDevToolsClientImpl(
dev_tools_host_->AddProtoFunction(
"toggleInspectElementMode",
WebDevToolsClientImpl::JsToggleInspectElementMode);
+ dev_tools_host_->AddProtoFunction(
+ "getApplicationLocale",
+ WebDevToolsClientImpl::JsGetApplicationLocale);
dev_tools_host_->Build();
}
@@ -372,3 +380,11 @@ v8::Handle<v8::Value> WebDevToolsClientImpl::JsToggleInspectElementMode(
client->delegate_->ToggleInspectElementMode(enabled);
return v8::Undefined();
}
+
+// static
+v8::Handle<v8::Value> WebDevToolsClientImpl::JsGetApplicationLocale(
+ const v8::Arguments& args) {
+ WebDevToolsClientImpl* client = static_cast<WebDevToolsClientImpl*>(
+ v8::External::Cast(*args.Data())->Value());
+ return v8String(client->application_locale_);
+}
diff --git a/webkit/glue/webdevtoolsclient_impl.h b/webkit/glue/webdevtoolsclient_impl.h
index 3e5b250..f407863 100644
--- a/webkit/glue/webdevtoolsclient_impl.h
+++ b/webkit/glue/webdevtoolsclient_impl.h
@@ -36,7 +36,8 @@ class WebDevToolsClientImpl : public WebDevToolsClient,
public:
WebDevToolsClientImpl(
WebViewImpl* web_view_impl,
- WebDevToolsClientDelegate* delegate);
+ WebDevToolsClientDelegate* delegate,
+ const std::string& application_locale);
virtual ~WebDevToolsClientImpl();
// DevToolsRpc::Delegate implementation.
@@ -68,9 +69,12 @@ class WebDevToolsClientImpl : public WebDevToolsClient,
static v8::Handle<v8::Value> JsUndockWindow(const v8::Arguments& args);
static v8::Handle<v8::Value> JsToggleInspectElementMode(
const v8::Arguments& args);
+ static v8::Handle<v8::Value> JsGetApplicationLocale(
+ const v8::Arguments& args);
WebViewImpl* web_view_impl_;
WebDevToolsClientDelegate* delegate_;
+ String application_locale_;
OwnPtr<CppBoundClass> debugger_command_executor_obj_;
OwnPtr<JsDebuggerAgentBoundObj> debugger_agent_obj_;
OwnPtr<JsToolsAgentBoundObj> tools_agent_obj_;