diff --git a/all_devtools_modules.gni b/all_devtools_modules.gni index f52f36e64b..e9b2e63aba 100644 --- a/all_devtools_modules.gni +++ b/all_devtools_modules.gni @@ -53,7 +53,6 @@ all_typescript_module_sources = [ "changes/ChangesSidebar.js", "changes/ChangesTextEditor.js", "changes/ChangesView.js", - "changes/ModuleUIStrings.js", "cm_modes/DefaultCodeMirrorMimeMode.js", "color_picker/ContrastDetails.js", "color_picker/ContrastInfo.js", diff --git a/devtools_grd_files.gni b/devtools_grd_files.gni index 627950b4ee..6bfd50fa27 100644 --- a/devtools_grd_files.gni +++ b/devtools_grd_files.gni @@ -436,7 +436,6 @@ grd_files_debug_sources = [ "front_end/changes/ChangesSidebar.js", "front_end/changes/ChangesTextEditor.js", "front_end/changes/ChangesView.js", - "front_end/changes/ModuleUIStrings.js", "front_end/cm_modes/DefaultCodeMirrorMimeMode.js", "front_end/color_picker/ContrastDetails.js", "front_end/color_picker/ContrastInfo.js", diff --git a/front_end/changes/BUILD.gn b/front_end/changes/BUILD.gn index 2a77727ae2..9aa11bf48c 100644 --- a/front_end/changes/BUILD.gn +++ b/front_end/changes/BUILD.gn @@ -11,13 +11,11 @@ devtools_module("changes") { "ChangesSidebar.js", "ChangesTextEditor.js", "ChangesView.js", - "ModuleUIStrings.js", ] deps = [ "../common:bundle", "../diff:bundle", - "../i18n:bundle", "../snippets:bundle", "../text_editor:bundle", "../ui:bundle", diff --git a/front_end/changes/ChangesSidebar.js b/front_end/changes/ChangesSidebar.js index b94b6edae7..dce014250c 100644 --- a/front_end/changes/ChangesSidebar.js +++ b/front_end/changes/ChangesSidebar.js @@ -3,22 +3,11 @@ // found in the LICENSE file. import * as Common from '../common/common.js'; -import * as i18n from '../i18n/i18n.js'; import * as Snippets from '../snippets/snippets.js'; import * as UI from '../ui/ui.js'; import * as Workspace from '../workspace/workspace.js'; import * as WorkspaceDiff from '../workspace_diff/workspace_diff.js'; -export const UIStrings = { - /** - *@description Name of an item from source map - *@example {compile.html} PH1 - */ - sFromSourceMap: '{PH1} (from source map)', -}; -const str_ = i18n.i18n.registerUIStrings('changes/ChangesSidebar.js', UIStrings); -const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_); - export class ChangesSidebar extends UI.Widget.Widget { /** * @param {!WorkspaceDiff.WorkspaceDiff.WorkspaceDiffImpl} workspaceDiff @@ -157,7 +146,7 @@ export class UISourceCodeTreeElement extends UI.TreeOutline.TreeElement { let tooltip = this.uiSourceCode.url(); if (this.uiSourceCode.contentType().isFromSourceMap()) { - tooltip = i18nString(UIStrings.sFromSourceMap, {PH1: this.uiSourceCode.displayName()}); + tooltip = Common.UIString.UIString('%s (from source map)', this.uiSourceCode.displayName()); } this.tooltip = tooltip; } diff --git a/front_end/changes/ChangesTextEditor.js b/front_end/changes/ChangesTextEditor.js index 02e0402e5f..8e6d744a82 100644 --- a/front_end/changes/ChangesTextEditor.js +++ b/front_end/changes/ChangesTextEditor.js @@ -2,27 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import * as i18n from '../i18n/i18n.js'; import * as TextEditor from '../text_editor/text_editor.js'; import * as UI from '../ui/ui.js'; // eslint-disable-line no-unused-vars import {Row, RowType} from './ChangesView.js'; // eslint-disable-line no-unused-vars -export const UIStrings = { - /** - *@description Text prepended to a removed line in a diff in the Changes tool, viewable only by screen reader. - *@example {function log () } PH1 - */ - deletions: 'Deletion:{PH1}', - /** - *@description Text prepended to a new line in a diff in the Changes tool, viewable only by screen reader. - *@example {function log () } PH1 - */ - additions: 'Addition:{PH1}', -}; -const str_ = i18n.i18n.registerUIStrings('changes/ChangesTextEditor.js', UIStrings); -const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_); - /** * @extends {TextEditor.CodeMirrorTextEditor.CodeMirrorTextEditor} */ @@ -102,10 +86,10 @@ export class DevToolsAccessibleDiffTextArea extends TextEditor.CodeMirrorTextEdi const rowType = diffRows[lineNumber].type; if (rowType === RowType.Deletion) { - this.textarea.value = i18nString(UIStrings.deletions, {PH1: this.textarea.value}); + this.textarea.value = ls`Deletion:${this.textarea.value}`; } if (rowType === RowType.Addition) { - this.textarea.value = i18nString(UIStrings.additions, {PH1: this.textarea.value}); + this.textarea.value = ls`Addition:${this.textarea.value}`; } this.prevInput = this.textarea.value; } diff --git a/front_end/changes/ChangesView.js b/front_end/changes/ChangesView.js index ad3a44a1be..c4e8abc460 100644 --- a/front_end/changes/ChangesView.js +++ b/front_end/changes/ChangesView.js @@ -4,7 +4,6 @@ import * as Common from '../common/common.js'; import * as Diff from '../diff/diff.js'; -import * as i18n from '../i18n/i18n.js'; import * as UI from '../ui/ui.js'; import * as Workspace from '../workspace/workspace.js'; // eslint-disable-line no-unused-vars import * as WorkspaceDiff from '../workspace_diff/workspace_diff.js'; @@ -12,52 +11,6 @@ import * as WorkspaceDiff from '../workspace_diff/workspace_diff.js'; import {ChangesSidebar, Events} from './ChangesSidebar.js'; import {ChangesTextEditor} from './ChangesTextEditor.js'; -export const UIStrings = { - /** - *@description Screen-reader accessible name for the code editor in the Changes tool showing the user's changes. - */ - changesDiffViewer: 'Changes diff viewer', - /** - *@description Screen reader/tooltip label for a button in the Changes tool that reverts all changes to the currently open file. - */ - revertAllChangesToCurrentFile: 'Revert all changes to current file', - /** - *@description Text in Changes View of the Changes tab - */ - noChanges: 'No changes', - /** - *@description Text in Changes View of the Changes tab - */ - binaryData: 'Binary data', - /** - *@description Insertion text in Changes View of the Changes tab - *@example {1} PH1 - */ - sInsertion: '{PH1} insertion (+),', - /** - *@description Insertion text in Changes View of the Changes tab - *@example {2} PH1 - */ - sInsertions: '{PH1} insertions (+),', - /** - *@description Deletion text in Changes View of the Changes tab - *@example {1} PH1 - */ - sDeletion: '{PH1} deletion (-)', - /** - *@description Deletion text in Changes View of the Changes tab - *@example {2} PH1 - */ - sDeletions: '{PH1} deletions (-)', - /** - *@description Text in Changes View of the Changes tab - *@example {2} PH1 - */ - SkippingDMatchingLines: '( … Skipping {PH1} matching lines … )', -}; -const str_ = i18n.i18n.registerUIStrings('changes/ChangesView.js', UIStrings); -const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_); - /** @type {!ChangesView} */ let changesViewInstance; @@ -91,7 +44,7 @@ export class ChangesView extends UI.Widget.VBox { this._editor = new ChangesTextEditor({ bracketMatchingSetting: undefined, - devtoolsAccessibleName: i18nString(UIStrings.changesDiffViewer), + devtoolsAccessibleName: ls`Changes diff viewer`, lineNumbers: true, lineWrapping: false, mimeType: undefined, @@ -111,15 +64,14 @@ export class ChangesView extends UI.Widget.VBox { self.onInvokeElement(this._editor.element, this._click.bind(this)); this._toolbar = new UI.Toolbar.Toolbar('changes-toolbar', mainWidget.element); - const revertButton = - new UI.Toolbar.ToolbarButton(i18nString(UIStrings.revertAllChangesToCurrentFile), 'largeicon-undo'); + const revertButton = new UI.Toolbar.ToolbarButton(ls`Revert all changes to current file`, 'largeicon-undo'); revertButton.addEventListener(UI.Toolbar.ToolbarButton.Events.Click, this._revert.bind(this)); this._toolbar.appendToolbarItem(revertButton); this._diffStats = new UI.Toolbar.ToolbarText(''); this._toolbar.appendToolbarItem(this._diffStats); this._toolbar.setEnabled(false); - this._hideDiff(i18nString(UIStrings.noChanges)); + this._hideDiff(ls`No changes`); this._selectedUISourceCodeChanged(); } @@ -198,7 +150,7 @@ export class ChangesView extends UI.Widget.VBox { } const uiSourceCode = this._selectedUISourceCode; if (!uiSourceCode.contentType().isTextType()) { - this._hideDiff(i18nString(UIStrings.binaryData)); + this._hideDiff(ls`Binary data`); return; } this._workspaceDiff.requestDiff(uiSourceCode).then(diff => { @@ -227,7 +179,7 @@ export class ChangesView extends UI.Widget.VBox { this._diffRows = []; if (!diff || (diff.length === 1 && diff[0][0] === Diff.Diff.Operation.Equal)) { - this._hideDiff(i18nString(UIStrings.noChanges)); + this._hideDiff(ls`No changes`); return; } @@ -278,16 +230,16 @@ export class ChangesView extends UI.Widget.VBox { let insertionText = ''; if (insertions === 1) { - insertionText = i18nString(UIStrings.sInsertion, {PH1: insertions}); + insertionText = ls`${insertions} insertion (+),`; } else { - insertionText = i18nString(UIStrings.sInsertions, {PH1: insertions}); + insertionText = ls`${insertions} insertions (+),`; } let deletionText = ''; if (deletions === 1) { - deletionText = i18nString(UIStrings.sDeletion, {PH1: deletions}); + deletionText = ls`${deletions} deletion (-)`; } else { - deletionText = i18nString(UIStrings.sDeletions, {PH1: deletions}); + deletionText = ls`${deletions} deletions (-)`; } this._diffStats.setText(`${insertionText} ${deletionText}`); @@ -322,7 +274,8 @@ export class ChangesView extends UI.Widget.VBox { } if (lines.length > paddingLines * 2 + 1 && !atEnd) { equalRows.push(createRow( - i18nString(UIStrings.SkippingDMatchingLines, {PH1: (lines.length - paddingLines * 2)}), RowType.Spacer)); + Common.UIString.UIString('( … Skipping %d matching lines … )', lines.length - paddingLines * 2), + RowType.Spacer)); } } if (!atEnd) { diff --git a/front_end/changes/ModuleUIStrings.js b/front_end/changes/ModuleUIStrings.js deleted file mode 100644 index dfe89c1e04..0000000000 --- a/front_end/changes/ModuleUIStrings.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2020 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 * as i18n from '../i18n/i18n.js'; -export const UIStrings = { - /** - *@description Title of the 'Changes' tool in the bottom drawer - */ - changes: 'Changes', - /** - *@description The UI destination when right clicking an item that can be revealed - */ - changesDrawer: 'Changes drawer', -}; -i18n.i18n.registerUIStrings('changes/ModuleUIStrings.js', UIStrings); diff --git a/front_end/changes/changes_strings.grdp b/front_end/changes/changes_strings.grdp new file mode 100644 index 0000000000..ddbf75b5d1 --- /dev/null +++ b/front_end/changes/changes_strings.grdp @@ -0,0 +1,42 @@ + + + + $1s2 deletions (-) + + + Changes diff viewer + + + No changes + + + $1s1 insertion (+), + + + $1s2 insertions (+), + + + Revert all changes to current file + + + Addition:$1sfunction log () { + + + Changes + + + ( … Skipping $1d2 matching lines … ) + + + Changes drawer + + + $1s1 deletion (-) + + + Deletion:$1sfunction log () { + + + Binary data + + diff --git a/front_end/changes/module.json b/front_end/changes/module.json index caa92e56dc..9339e10178 100644 --- a/front_end/changes/module.json +++ b/front_end/changes/module.json @@ -22,7 +22,6 @@ "text_editor", "workspace", "diff", - "i18n", "bindings", "persistence", "snippets", diff --git a/front_end/i18n/locales/en-US.json b/front_end/i18n/locales/en-US.json index 637e4694d1..31d25e54d0 100644 --- a/front_end/i18n/locales/en-US.json +++ b/front_end/i18n/locales/en-US.json @@ -53,48 +53,6 @@ "animation/ModuleUIStrings.js | animations": { "message": "Animations" }, - "changes/ChangesSidebar.js | sFromSourceMap": { - "message": "{PH1} (from source map)" - }, - "changes/ChangesTextEditor.js | additions": { - "message": "Addition:{PH1}" - }, - "changes/ChangesTextEditor.js | deletions": { - "message": "Deletion:{PH1}" - }, - "changes/ChangesView.js | binaryData": { - "message": "Binary data" - }, - "changes/ChangesView.js | changesDiffViewer": { - "message": "Changes diff viewer" - }, - "changes/ChangesView.js | noChanges": { - "message": "No changes" - }, - "changes/ChangesView.js | revertAllChangesToCurrentFile": { - "message": "Revert all changes to current file" - }, - "changes/ChangesView.js | sDeletion": { - "message": "{PH1} deletion (-)" - }, - "changes/ChangesView.js | sDeletions": { - "message": "{PH1} deletions (-)" - }, - "changes/ChangesView.js | sInsertion": { - "message": "{PH1} insertion (+)," - }, - "changes/ChangesView.js | sInsertions": { - "message": "{PH1} insertions (+)," - }, - "changes/ChangesView.js | SkippingDMatchingLines": { - "message": "( … Skipping {PH1} matching lines … )" - }, - "changes/ModuleUIStrings.js | changes": { - "message": "Changes" - }, - "changes/ModuleUIStrings.js | changesDrawer": { - "message": "Changes drawer" - }, "coverage/CoverageListView.js | Byte": { "message": "1 byte" }, diff --git a/front_end/langpacks/devtools_ui_strings.grd b/front_end/langpacks/devtools_ui_strings.grd index f8e45b233d..e45cdcbe26 100644 --- a/front_end/langpacks/devtools_ui_strings.grd +++ b/front_end/langpacks/devtools_ui_strings.grd @@ -15,6 +15,7 @@ + diff --git a/front_end/langpacks/shared_strings.grdp b/front_end/langpacks/shared_strings.grdp index b306541ebc..504f415565 100644 --- a/front_end/langpacks/shared_strings.grdp +++ b/front_end/langpacks/shared_strings.grdp @@ -592,6 +592,9 @@ Script + + $1scompile.html (from source map) + Load profile… diff --git a/front_end/sources/sources_strings.grdp b/front_end/sources/sources_strings.grdp index 718fcb951e..d244f9246f 100644 --- a/front_end/sources/sources_strings.grdp +++ b/front_end/sources/sources_strings.grdp @@ -630,9 +630,6 @@ Terminate current JavaScript call - - $1scompile.html (from source map) - Descendant $1snode removed diff --git a/scripts/localization/utils/check_localized_strings.js b/scripts/localization/utils/check_localized_strings.js index 842a3ce9a4..3fb71106b1 100644 --- a/scripts/localization/utils/check_localized_strings.js +++ b/scripts/localization/utils/check_localized_strings.js @@ -106,7 +106,6 @@ let devtoolsFrontendDirs; // TODO(crbug.com/941561): Remove once localization V1 is no longer used. const migratedDirsSet = new Set([ 'animation', - 'changes', 'coverage', 'developer_resources', 'devices',