mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1760033 - Convert AboutReaderParent.jsm to Fluent. r=Gijs,fluent-reviewers,flod
Differential Revision: https://phabricator.services.mozilla.com/D158576
This commit is contained in:
parent
6f0bf6e62b
commit
d391f5b3f5
@ -19,10 +19,6 @@ ChromeUtils.defineModuleGetter(
|
||||
"chrome://pocket/content/pktApi.jsm"
|
||||
);
|
||||
|
||||
const gStringBundle = Services.strings.createBundle(
|
||||
"chrome://global/locale/aboutReader.properties"
|
||||
);
|
||||
|
||||
// A set of all of the AboutReaderParent actors that exist.
|
||||
// See bug 1631146 for a request for a less manual way of doing this.
|
||||
let gAllActors = new Set();
|
||||
@ -224,43 +220,30 @@ export class AboutReaderParent extends JSWindowActorParent {
|
||||
return;
|
||||
}
|
||||
|
||||
let win = browser.ownerGlobal;
|
||||
|
||||
let button = win.document.getElementById("reader-mode-button");
|
||||
let menuitem = win.document.getElementById("menu_readerModeItem");
|
||||
let key = win.document.getElementById("key_toggleReaderMode");
|
||||
let doc = browser.ownerGlobal.document;
|
||||
let button = doc.getElementById("reader-mode-button");
|
||||
let menuitem = doc.getElementById("menu_readerModeItem");
|
||||
let key = doc.getElementById("key_toggleReaderMode");
|
||||
if (this.isReaderMode()) {
|
||||
gAllActors.add(this);
|
||||
|
||||
let closeText = gStringBundle.GetStringFromName("readerView.close");
|
||||
|
||||
button.setAttribute("readeractive", true);
|
||||
button.hidden = false;
|
||||
button.setAttribute("aria-label", closeText);
|
||||
doc.l10n.setAttributes(button, "reader-view-close-button");
|
||||
|
||||
menuitem.setAttribute("label", closeText);
|
||||
menuitem.hidden = false;
|
||||
menuitem.setAttribute(
|
||||
"accesskey",
|
||||
gStringBundle.GetStringFromName("readerView.close.accesskey")
|
||||
);
|
||||
doc.l10n.setAttributes(menuitem, "reader-view-close-menuitem");
|
||||
|
||||
key.setAttribute("disabled", false);
|
||||
|
||||
Services.obs.notifyObservers(null, "reader-mode-available");
|
||||
} else {
|
||||
let enterText = gStringBundle.GetStringFromName("readerView.enter");
|
||||
|
||||
button.removeAttribute("readeractive");
|
||||
button.hidden = !browser.isArticle;
|
||||
button.setAttribute("aria-label", enterText);
|
||||
doc.l10n.setAttributes(button, "reader-view-enter-button");
|
||||
|
||||
menuitem.setAttribute("label", enterText);
|
||||
menuitem.hidden = !browser.isArticle;
|
||||
menuitem.setAttribute(
|
||||
"accesskey",
|
||||
gStringBundle.GetStringFromName("readerView.enter.accesskey")
|
||||
);
|
||||
doc.l10n.setAttributes(menuitem, "reader-view-enter-menuitem");
|
||||
|
||||
key.setAttribute("disabled", !browser.isArticle);
|
||||
|
||||
|
@ -211,6 +211,7 @@
|
||||
<menuitem id="menu_readerModeItem"
|
||||
observes="View:ReaderView"
|
||||
key="key_toggleReaderMode"
|
||||
data-l10n-id="reader-view-enter-menuitem"
|
||||
hidden="true"/>
|
||||
<menuitem id="menu_showAllTabs"
|
||||
hidden="true"
|
||||
|
@ -354,6 +354,7 @@
|
||||
<hbox id="reader-mode-button"
|
||||
class="urlbar-page-action"
|
||||
role="button"
|
||||
data-l10n-id="reader-view-enter-button"
|
||||
hidden="true"
|
||||
tooltip="dynamic-shortcut-tooltip"
|
||||
onclick="AboutReaderParent.buttonClick(event);">
|
||||
|
@ -640,6 +640,21 @@ urlbar-group-search-suggestions =
|
||||
urlbar-group-quickactions =
|
||||
.label = Quick Actions
|
||||
|
||||
## Reader View toolbar & menubar items
|
||||
## These menu items may use the same accesskey.
|
||||
|
||||
reader-view-enter-button =
|
||||
.aria-label = Enter Reader View
|
||||
reader-view-enter-menuitem =
|
||||
.label = Enter Reader View
|
||||
.accesskey = R
|
||||
|
||||
reader-view-close-button =
|
||||
.aria-label = Close Reader View
|
||||
reader-view-close-menuitem =
|
||||
.label = Close Reader View
|
||||
.accesskey = R
|
||||
|
||||
## Full Screen and Pointer Lock UI
|
||||
|
||||
# Please ensure that the domain stays in the `<span data-l10n-name="domain">` markup.
|
||||
|
62
python/l10n/fluent_migrations/bug_1760033_readerView.py
Normal file
62
python/l10n/fluent_migrations/bug_1760033_readerView.py
Normal file
@ -0,0 +1,62 @@
|
||||
# Any copyright is dedicated to the Public Domain.
|
||||
# http://creativecommons.org/publicdomain/zero/1.0/
|
||||
|
||||
import fluent.syntax.ast as FTL
|
||||
from fluent.migrate.transforms import COPY
|
||||
|
||||
|
||||
def migrate(ctx):
|
||||
"""Bug 1760033 - Convert AboutReaderParent.jsm to Fluent, part {index}."""
|
||||
|
||||
source = "toolkit/chrome/global/aboutReader.properties"
|
||||
target = "browser/browser/browser.ftl"
|
||||
ctx.add_transforms(
|
||||
target,
|
||||
target,
|
||||
[
|
||||
FTL.Message(
|
||||
id=FTL.Identifier("reader-view-enter-button"),
|
||||
attributes=[
|
||||
FTL.Attribute(
|
||||
id=FTL.Identifier("aria-label"),
|
||||
value=COPY(source, "readerView.enter"),
|
||||
),
|
||||
],
|
||||
),
|
||||
FTL.Message(
|
||||
id=FTL.Identifier("reader-view-enter-menuitem"),
|
||||
attributes=[
|
||||
FTL.Attribute(
|
||||
id=FTL.Identifier("label"),
|
||||
value=COPY(source, "readerView.enter"),
|
||||
),
|
||||
FTL.Attribute(
|
||||
id=FTL.Identifier("accesskey"),
|
||||
value=COPY(source, "readerView.enter.accesskey"),
|
||||
),
|
||||
],
|
||||
),
|
||||
FTL.Message(
|
||||
id=FTL.Identifier("reader-view-close-button"),
|
||||
attributes=[
|
||||
FTL.Attribute(
|
||||
id=FTL.Identifier("aria-label"),
|
||||
value=COPY(source, "readerView.close"),
|
||||
),
|
||||
],
|
||||
),
|
||||
FTL.Message(
|
||||
id=FTL.Identifier("reader-view-close-menuitem"),
|
||||
attributes=[
|
||||
FTL.Attribute(
|
||||
id=FTL.Identifier("label"),
|
||||
value=COPY(source, "readerView.close"),
|
||||
),
|
||||
FTL.Attribute(
|
||||
id=FTL.Identifier("accesskey"),
|
||||
value=COPY(source, "readerView.close.accesskey"),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
@ -8,9 +8,3 @@ aboutReader.fontTypeSample=Aa
|
||||
|
||||
# This is a label used for done option in the toolbar
|
||||
readerView.done.label=Done
|
||||
# These are used for the Reader View toolbar button and the menuitem within the
|
||||
# View menu.
|
||||
readerView.enter=Enter Reader View
|
||||
readerView.enter.accesskey=R
|
||||
readerView.close=Close Reader View
|
||||
readerView.close.accesskey=R
|
||||
|
Loading…
Reference in New Issue
Block a user