Devtools: Tab titles are not localizable
Tab titles in the devtools are not localizable, this PR makes the title function to actually use l10n tagged templates and fixes the following comment on the code:
third_party\blink\renderer\devtools\front_end\Runtime.js
// FIXME: should be Common.UIString() but runtime is not l10n aware yet.
Change-Id: I4a651e2f1b4ef0e0e6d07b54d52e44c17aeda057
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1554648
Commit-Queue: Vidal Diazleal <[email protected]>
Reviewed-by: Joel Einbinder <[email protected]>
Cr-Original-Commit-Position: refs/heads/master@{#652717}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 47fe01c857b5aff69d66e36e994bb7796748907b
diff --git a/front_end/Runtime.js b/front_end/Runtime.js
index 28cb0dc..a89806c 100644
--- a/front_end/Runtime.js
+++ b/front_end/Runtime.js
@@ -378,6 +378,13 @@
return '\n/*# sourceURL=' + sourceURL + ' */';
}
+ /**
+ * @param {function(string):string} localizationFunction
+ */
+ static setL10nCallback(localizationFunction) {
+ Runtime._l10nCallback = localizationFunction;
+ }
+
useTestBase() {
Runtime._remoteBase = 'http://localhost:8000/inspector-sources/';
if (Runtime.queryParam('debugFrontend'))
@@ -890,8 +897,10 @@
* @return {string}
*/
title() {
- // FIXME: should be Common.UIString() but runtime is not l10n aware yet.
- return this._descriptor['title-' + Runtime._platform] || this._descriptor['title'];
+ const title = this._descriptor['title-' + Runtime._platform] || this._descriptor['title'];
+ if (title && Runtime._l10nCallback)
+ return Runtime._l10nCallback(title);
+ return title;
}
/**
@@ -1071,6 +1080,10 @@
/** @type {Function} */
Runtime._appStartedPromiseCallback;
Runtime._appStartedPromise = new Promise(fulfil => Runtime._appStartedPromiseCallback = fulfil);
+
+/** @type {function(string):string} */
+Runtime._l10nCallback;
+
/**
* @type {?string}
*/
diff --git a/front_end/main/Main.js b/front_end/main/Main.js
index 8206ed8..0e186d5 100644
--- a/front_end/main/Main.js
+++ b/front_end/main/Main.js
@@ -62,6 +62,7 @@
console.timeStamp('Main._loaded');
await Runtime.appStarted();
Runtime.setPlatform(Host.platform());
+ Runtime.setL10nCallback(ls);
InspectorFrontendHost.getPreferences(this._gotPreferences.bind(this));
}
diff --git a/front_end/source_frame/SourceFrame.js b/front_end/source_frame/SourceFrame.js
index 1a7f0ce..7b7e662 100644
--- a/front_end/source_frame/SourceFrame.js
+++ b/front_end/source_frame/SourceFrame.js
@@ -733,7 +733,7 @@
let textRange = selections[0];
if (textRange.isEmpty()) {
const location = this._prettyToRawLocation(textRange.endLine, textRange.endColumn);
- this._sourcePosition.setText(`Line ${location[0] + 1}, Column ${location[1] + 1}`);
+ this._sourcePosition.setText(ls`Line ${location[0] + 1}, Column ${location[1] + 1}`);
return;
}
textRange = textRange.normalize();