Bug 1635548 - Migrated browser-context.inc to Fluent. r=emalysz,flod

Differential Revision: https://phabricator.services.mozilla.com/D123233
This commit is contained in:
Niklas Baumgardner 2021-08-23 18:46:11 +00:00
Родитель 0a4ffe90a7
Коммит 78f3c52e0b
9 изменённых файлов: 128 добавлений и 40 удалений

Просмотреть файл

@ -61,12 +61,10 @@
disabled="true"
data-l10n-id="text-action-spell-no-suggestions"/>
<menuitem id="spell-add-to-dictionary"
label="&spellAddToDictionary.label;"
accesskey="&spellAddToDictionary.accesskey;"
data-l10n-id="text-action-spell-add-to-dictionary"
oncommand="InlineSpellCheckerUI.addToDictionary();"/>
<menuitem id="spell-undo-add-to-dictionary"
label="&spellUndoAddToDictionary.label;"
accesskey="&spellUndoAddToDictionary.accesskey;"
data-l10n-id="text-action-spell-undo-add-to-dictionary"
oncommand="InlineSpellCheckerUI.undoAddToDictionary();" />
<menuseparator id="spell-suggestions-separator"/>
<menuitem id="context-openlinkincurrent"
@ -74,7 +72,7 @@
oncommand="gContextMenu.openLinkInCurrent();"/>
# label and data-usercontextid are dynamically set.
<menuitem id="context-openlinkincontainertab"
accesskey="&openLinkCmdInTab.accesskey;"
data-l10n-id="main-context-menu-open-link-in-container-tab"
oncommand="gContextMenu.openLinkInTab(event);"/>
<menuitem id="context-openlinkintab"
data-l10n-id="main-context-menu-open-link-new-tab"
@ -361,22 +359,18 @@
</menu>
<menuseparator id="spell-separator"/>
<menuitem id="spell-check-enabled"
label="&spellCheckToggle.label;"
data-l10n-id="text-action-spell-check-toggle"
type="checkbox"
accesskey="&spellCheckToggle.accesskey;"
oncommand="InlineSpellCheckerUI.toggleEnabled(window);"/>
<menuitem id="spell-add-dictionaries-main"
label="&spellAddDictionaries.label;"
accesskey="&spellAddDictionaries.accesskey;"
data-l10n-id="text-action-spell-add-dictionaries"
oncommand="gContextMenu.addDictionaries();"/>
<menu id="spell-dictionaries"
label="&spellDictionaries.label;"
accesskey="&spellDictionaries.accesskey;">
data-l10n-id="text-action-spell-dictionaries">
<menupopup id="spell-dictionaries-menu">
<menuseparator id="spell-language-separator"/>
<menuitem id="spell-add-dictionaries"
label="&spellAddDictionaries.label;"
accesskey="&spellAddDictionaries.accesskey;"
data-l10n-id="text-action-spell-add-dictionaries"
oncommand="gContextMenu.addDictionaries();"/>
</menupopup>
</menu>

Просмотреть файл

@ -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,
}
);
}

Просмотреть файл

@ -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

Просмотреть файл

@ -97,8 +97,6 @@ this container is a toolbar. This avoids double-speaking. -->
<!ENTITY searchInput.placeholder "Search">
<!ENTITY searchIcon.tooltip "Search">
<!ENTITY openLinkCmdInTab.accesskey "T">
<!ENTITY fullZoom.label "Zoom">
<!ENTITY sidebarCloseButton.tooltip "Close sidebar">
@ -110,9 +108,6 @@ this container is a toolbar. This avoids double-speaking. -->
<!ENTITY editPopupSettings.label "Edit Pop-up Blocker Options…">
<!ENTITY editPopupSettings.accesskey "E">
<!ENTITY spellAddDictionaries.label "Add Dictionaries…">
<!ENTITY spellAddDictionaries.accesskey "A">
<!-- Name for the tabs toolbar as spoken by screen readers.
The word "toolbar" is appended automatically and should not be contained below! -->
<!ENTITY tabsToolbar.label "Browser tabs">

Просмотреть файл

@ -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

Просмотреть файл

@ -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",
),
),
],
)
],
)

Просмотреть файл

@ -40,14 +40,14 @@
this.spellcheck = MozXULElement.parseXULToFragment(
`
<menupopup class="textbox-contextmenu">
<menuitem label="&spellNoSuggestions.label;" anonid="spell-no-suggestions" disabled="true"></menuitem>
<menuitem label="&spellAddToDictionary.label;" accesskey="&spellAddToDictionary.accesskey;" anonid="spell-add-to-dictionary" oncommand="this.parentNode.parentNode.spellCheckerUI.addToDictionary();"></menuitem>
<menuitem label="&spellUndoAddToDictionary.label;" accesskey="&spellUndoAddToDictionary.accesskey;" anonid="spell-undo-add-to-dictionary" oncommand="this.parentNode.parentNode.spellCheckerUI.undoAddToDictionary();"></menuitem>
<menuitem data-l10n-id="text-action-spell-no-suggestions" anonid="spell-no-suggestions" disabled="true"></menuitem>
<menuitem data-l10n-id="text-action-spell-add-to-dictionary" anonid="spell-add-to-dictionary" oncommand="this.parentNode.parentNode.spellCheckerUI.addToDictionary();"></menuitem>
<menuitem data-l10n-id="text-action-spell-undo-add-to-dictionary" anonid="spell-undo-add-to-dictionary" oncommand="this.parentNode.parentNode.spellCheckerUI.undoAddToDictionary();"></menuitem>
<menuseparator anonid="spell-suggestions-separator"></menuseparator>
${this.editMenuItems}
<menuseparator anonid="spell-check-separator"></menuseparator>
<menuitem label="&spellCheckToggle.label;" type="checkbox" accesskey="&spellCheckToggle.accesskey;" anonid="spell-check-enabled" oncommand="this.parentNode.parentNode.spellCheckerUI.toggleEnabled();"></menuitem>
<menu label="&spellDictionaries.label;" accesskey="&spellDictionaries.accesskey;" anonid="spell-dictionaries">
<menuitem data-l10n-id="text-action-spell-check-toggle" type="checkbox" anonid="spell-check-enabled" oncommand="this.parentNode.parentNode.spellCheckerUI.toggleEnabled();"></menuitem>
<menu data-l10n-id="text-action-spell-dictionaries" anonid="spell-dictionaries">
<menupopup anonid="spell-dictionaries-menu" onpopupshowing="event.stopPropagation();" onpopuphiding="event.stopPropagation();"></menupopup>
</menu>
</menupopup>

Просмотреть файл

@ -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/. -->
<!ENTITY spellAddToDictionary.label "Add to Dictionary">
<!ENTITY spellAddToDictionary.accesskey "o">
<!ENTITY spellUndoAddToDictionary.label "Undo Add To Dictionary">
<!ENTITY spellUndoAddToDictionary.accesskey "n">
<!ENTITY spellCheckToggle.label "Check Spelling">
<!ENTITY spellCheckToggle.accesskey "g">
<!ENTITY spellNoSuggestions.label "(No Spelling Suggestions)">
<!ENTITY spellDictionaries.label "Languages">
<!ENTITY spellDictionaries.accesskey "l">
<!ENTITY searchTextBox.clear.label "Clear">

Просмотреть файл

@ -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