From 78f3c52e0b150bca85e715cd8b6010501305aca2 Mon Sep 17 00:00:00 2001 From: Niklas Baumgardner Date: Mon, 23 Aug 2021 18:46:11 +0000 Subject: [PATCH] Bug 1635548 - Migrated browser-context.inc to Fluent. r=emalysz,flod Differential Revision: https://phabricator.services.mozilla.com/D123233 --- browser/base/content/browser-context.inc | 20 ++--- browser/base/content/nsContextMenu.js | 12 +-- .../locales/en-US/browser/browserContext.ftl | 6 ++ .../locales/en-US/chrome/browser/browser.dtd | 5 -- .../en-US/chrome/browser/browser.properties | 2 - .../bug_1635548_browser_context.py | 83 +++++++++++++++++++ toolkit/content/widgets/moz-input-box.js | 10 +-- .../en-US/chrome/global/textcontext.dtd | 10 --- .../en-US/toolkit/global/textActions.ftl | 20 +++++ 9 files changed, 128 insertions(+), 40 deletions(-) create mode 100644 python/l10n/fluent_migrations/bug_1635548_browser_context.py diff --git a/browser/base/content/browser-context.inc b/browser/base/content/browser-context.inc index 03799874d5b2..6fbd5d2362ec 100644 --- a/browser/base/content/browser-context.inc +++ b/browser/base/content/browser-context.inc @@ -61,12 +61,10 @@ disabled="true" data-l10n-id="text-action-spell-no-suggestions"/> # label and data-usercontextid are dynamically set. + data-l10n-id="text-action-spell-dictionaries"> diff --git a/browser/base/content/nsContextMenu.js b/browser/base/content/nsContextMenu.js index 0728e5eaee9e..6077389beb09 100644 --- a/browser/base/content/nsContextMenu.js +++ b/browser/base/content/nsContextMenu.js @@ -394,11 +394,13 @@ class nsContextMenu { var label = ContextualIdentityService.getUserContextLabel( this.contentData.userContextId ); - item.setAttribute( - "label", - gBrowserBundle.formatStringFromName("userContextOpenLink.label", [ - label, - ]) + + document.l10n.setAttributes( + item, + "main-context-menu-open-link-in-container-tab", + { + containerName: label, + } ); } diff --git a/browser/locales/en-US/browser/browserContext.ftl b/browser/locales/en-US/browser/browserContext.ftl index eaf08796fff8..22555342cbb8 100644 --- a/browser/locales/en-US/browser/browserContext.ftl +++ b/browser/locales/en-US/browser/browserContext.ftl @@ -443,3 +443,9 @@ main-context-menu-inspect-a11y-properties = main-context-menu-eme-learn-more = .label = Learn more about DRM… .accesskey = D + +# Variables +# $containerName (String): The name of the current container +main-context-menu-open-link-in-container-tab = + .label = Open Link in New { $containerName } Tab + .accesskey = T diff --git a/browser/locales/en-US/chrome/browser/browser.dtd b/browser/locales/en-US/chrome/browser/browser.dtd index 5110226a8a64..a9c5e717254e 100644 --- a/browser/locales/en-US/chrome/browser/browser.dtd +++ b/browser/locales/en-US/chrome/browser/browser.dtd @@ -97,8 +97,6 @@ this container is a toolbar. This avoids double-speaking. --> - - @@ -110,9 +108,6 @@ this container is a toolbar. This avoids double-speaking. --> - - - diff --git a/browser/locales/en-US/chrome/browser/browser.properties b/browser/locales/en-US/chrome/browser/browser.properties index c06c94092623..3a8e88fac914 100644 --- a/browser/locales/en-US/chrome/browser/browser.properties +++ b/browser/locales/en-US/chrome/browser/browser.properties @@ -892,8 +892,6 @@ userContextNone.accesskey = N userContext.aboutPage.label = Manage Containers userContext.aboutPage.accesskey = O -userContextOpenLink.label = Open Link in New %S Tab - muteTab.label = Mute Tab muteTab.accesskey = M unmuteTab.label = Unmute Tab diff --git a/python/l10n/fluent_migrations/bug_1635548_browser_context.py b/python/l10n/fluent_migrations/bug_1635548_browser_context.py new file mode 100644 index 000000000000..68248cd38df3 --- /dev/null +++ b/python/l10n/fluent_migrations/bug_1635548_browser_context.py @@ -0,0 +1,83 @@ +# coding=utf8 + +# Any copyright is dedicated to the Public Domain. +# http://creativecommons.org/publicdomain/zero/1.0/ + +from __future__ import absolute_import +import fluent.syntax.ast as FTL +from fluent.migrate.helpers import transforms_from, VARIABLE_REFERENCE +from fluent.migrate import REPLACE, COPY + + +def migrate(ctx): + """Bug 1635548 - Migrate browser-context.inc to Fluent, part {index}""" + target = "toolkit/toolkit/global/textActions.ftl" + reference = "toolkit/toolkit/global/textActions.ftl" + ctx.add_transforms( + target, + reference, + transforms_from( + """ +text-action-spell-add-to-dictionary = + .label = { COPY(from_path, "spellAddToDictionary.label") } + .accesskey = { COPY(from_path, "spellAddToDictionary.accesskey") } + +text-action-spell-undo-add-to-dictionary = + .label = { COPY(from_path, "spellUndoAddToDictionary.label") } + .accesskey = { COPY(from_path, "spellUndoAddToDictionary.accesskey") } + +text-action-spell-check-toggle = + .label = { COPY(from_path, "spellCheckToggle.label") } + .accesskey = { COPY(from_path, "spellCheckToggle.accesskey") } + +text-action-spell-dictionaries = + .label = { COPY(from_path, "spellDictionaries.label") } + .accesskey = { COPY(from_path, "spellDictionaries.accesskey") } +""", + from_path="toolkit/chrome/global/textcontext.dtd", + ), + ) + + target = "toolkit/toolkit/global/textActions.ftl" + reference = "toolkit/toolkit/global/textActions.ftl" + ctx.add_transforms( + target, + reference, + transforms_from( + """ +text-action-spell-add-dictionaries = + .label = { COPY(from_path, "spellAddDictionaries.label") } + .accesskey = { COPY(from_path, "spellAddDictionaries.accesskey") } +""", + from_path="browser/chrome/browser/browser.dtd", + ), + ) + + target = "browser/browser/browserContext.ftl" + reference = "browser/browser/browserContext.ftl" + ctx.add_transforms( + target, + reference, + [ + FTL.Message( + id=FTL.Identifier("main-context-menu-open-link-in-container-tab"), + attributes=[ + FTL.Attribute( + FTL.Identifier("label"), + REPLACE( + "browser/chrome/browser/browser.properties", + "userContextOpenLink.label", + {"%1$S": VARIABLE_REFERENCE("containerName")}, + ), + ), + FTL.Attribute( + FTL.Identifier("accesskey"), + COPY( + "browser/chrome/browser/browser.dtd", + "openLinkCmdInTab.accesskey", + ), + ), + ], + ) + ], + ) diff --git a/toolkit/content/widgets/moz-input-box.js b/toolkit/content/widgets/moz-input-box.js index 513e3d20119d..937119ba330e 100644 --- a/toolkit/content/widgets/moz-input-box.js +++ b/toolkit/content/widgets/moz-input-box.js @@ -40,14 +40,14 @@ this.spellcheck = MozXULElement.parseXULToFragment( ` - - - + + + ${this.editMenuItems} - - + + diff --git a/toolkit/locales/en-US/chrome/global/textcontext.dtd b/toolkit/locales/en-US/chrome/global/textcontext.dtd index c8981b34b702..423b22c9e3b5 100644 --- a/toolkit/locales/en-US/chrome/global/textcontext.dtd +++ b/toolkit/locales/en-US/chrome/global/textcontext.dtd @@ -2,14 +2,4 @@ - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> - - - - - - - - - - diff --git a/toolkit/locales/en-US/toolkit/global/textActions.ftl b/toolkit/locales/en-US/toolkit/global/textActions.ftl index cb2dd294fe88..4d286e82bdf4 100644 --- a/toolkit/locales/en-US/toolkit/global/textActions.ftl +++ b/toolkit/locales/en-US/toolkit/global/textActions.ftl @@ -50,3 +50,23 @@ text-action-select-all-shortcut = text-action-spell-no-suggestions = .label = No Spelling Suggestions + +text-action-spell-add-to-dictionary = + .label = Add to Dictionary + .accesskey = o + +text-action-spell-undo-add-to-dictionary = + .label = Undo Add To Dictionary + .accesskey = n + +text-action-spell-check-toggle = + .label = Check Spelling + .accesskey = g + +text-action-spell-add-dictionaries = + .label = Add Dictionaries… + .accesskey = A + +text-action-spell-dictionaries = + .label = Languages + .accesskey = L