Skip to content

Commit

Permalink
Bug 1608200 - port toolkit/chrome/global/wizard.dtd to Fluent r=Gijs,…
Browse files Browse the repository at this point in the history
…fluent-reviewers,flod

Differential Revision: https://phabricator.services.mozilla.com/D66771

--HG--
extra : moz-landing-system : lando
  • Loading branch information
jshomali committed Mar 27, 2020
1 parent 0cda85b commit 8f869c8
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 46 deletions.
50 changes: 50 additions & 0 deletions python/l10n/fluent_migrations/bug_1608200_wizard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# 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
from fluent.migrate import COPY, REPLACE
from fluent.migrate.helpers import MESSAGE_REFERENCE, TERM_REFERENCE

def migrate(ctx):
"""Bug 1608200 - Migrate wizard to Fluent, part {index}."""

ctx.add_transforms(
"toolkit/toolkit/global/wizard.ftl",
"toolkit/toolkit/global/wizard.ftl",
transforms_from(
"""
wizard-macos-button-back =
.label = { COPY(from_path, "button-back-mac.label") }
.accesskey = { COPY(from_path, "button-back-mac.accesskey") }
wizard-linux-button-back =
.label = { COPY(from_path, "button-back-unix.label") }
.accesskey = { COPY(from_path, "button-back-unix.accesskey") }
wizard-win-button-back =
.label = { COPY(from_path, "button-back-win.label") }
.accesskey = { COPY(from_path, "button-back-win.accesskey") }
wizard-macos-button-next =
.label = { COPY(from_path, "button-next-mac.label") }
.accesskey = { COPY(from_path, "button-next-mac.accesskey") }
wizard-linux-button-next =
.label = { COPY(from_path, "button-next-unix.label") }
.accesskey = { COPY(from_path, "button-next-unix.accesskey") }
wizard-win-button-next =
.label = { COPY(from_path, "button-next-win.label") }
.accesskey = { COPY(from_path, "button-next-win.accesskey") }
wizard-macos-button-finish =
.label = { COPY(from_path, "button-finish-mac.label") }
wizard-linux-button-finish =
.label = { COPY(from_path, "button-finish-unix.label") }
wizard-win-button-finish =
.label = { COPY(from_path, "button-finish-win.label") }
wizard-macos-button-cancel =
.label = { COPY(from_path, "button-cancel-mac.label") }
wizard-linux-button-cancel =
.label = { COPY(from_path, "button-cancel-unix.label") }
wizard-win-button-cancel =
.label = { COPY(from_path, "button-cancel-win.label") }
""", from_path="toolkit/chrome/global/wizard.dtd"))
50 changes: 29 additions & 21 deletions toolkit/content/widgets/wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
"resource://gre/modules/Services.jsm"
);

const kDTDs = ["chrome://global/locale/wizard.dtd"];

// Note: MozWizard currently supports adding, but not removing MozWizardPage
// children.
class MozWizard extends MozXULElement {
Expand Down Expand Up @@ -519,7 +517,17 @@
this._wizard = this.getRootNode().host;

this.textContent = "";
this.appendChild(MozXULElement.parseXULToFragment(this._markup, kDTDs));
this.appendChild(MozXULElement.parseXULToFragment(this._markup));

MozXULElement.insertFTLIfNeeded("toolkit/global/wizard.ftl");
document.addEventListener(
"DOMContentLoaded",
e => {
document.l10n.connectRoot(this);
document.l10n.translateRoots();
},
{ once: true }
);

this._wizardButtonDeck = this.querySelector(".wizard-next-deck");

Expand Down Expand Up @@ -558,17 +566,17 @@
<hbox class="wizard-buttons-btm">
<button class="wizard-button" dlgtype="extra1" hidden="true"/>
<button class="wizard-button" dlgtype="extra2" hidden="true"/>
<button label="&button-cancel-mac.label;"
<button data-l10n-id="wizard-macos-button-cancel"
class="wizard-button" dlgtype="cancel"/>
<spacer flex="1"/>
<button label="&button-back-mac.label;"
accesskey="&button-back-mac.accesskey;"
<button data-l10n-id="wizard-macos-button-back"
accesskey="wizard-macos-button-back"
class="wizard-button wizard-nav-button" dlgtype="back"/>
<button label="&button-next-mac.label;"
accesskey="&button-next-mac.accesskey;"
<button data-l10n-id="wizard-macos-button-next"
accesskey="wizard-macos-button-next"
class="wizard-button wizard-nav-button" dlgtype="next"
default="true" />
<button label="&button-finish-mac.label;" class="wizard-button"
<button data-l10n-id="wizard-macos-button-finish" class="wizard-button"
dlgtype="finish" default="true" />
</hbox>
</vbox>`;
Expand All @@ -577,44 +585,44 @@
let buttons =
AppConstants.platform == "linux"
? `
<button label="&button-cancel-unix.label;"
<button data-l10n-id="wizard-linux-button-cancel"
class="wizard-button"
dlgtype="cancel"/>
<spacer style="width: 24px;"/>
<button label="&button-back-unix.label;"
accesskey="&button-back-unix.accesskey;"
<button data-l10n-id="wizard-linux-button-back"
accesskey="wizard-linux-button-back"
class="wizard-button" dlgtype="back"/>
<deck class="wizard-next-deck">
<hbox>
<button label="&button-finish-unix.label;"
<button data-l10n-id="wizard-linux-button-finish"
class="wizard-button"
dlgtype="finish" default="true" flex="1"/>
</hbox>
<hbox>
<button label="&button-next-unix.label;"
accesskey="&button-next-unix.accesskey;"
<button data-l10n-id="wizard-linux-button-next"
accesskey="wizard-linux-button-next"
class="wizard-button" dlgtype="next"
default="true" flex="1"/>
</hbox>
</deck>`
: `
<button label="&button-back-win.label;"
accesskey="&button-back-win.accesskey;"
<button data-l10n-id="wizard-win-button-back"
accesskey="wizard-win-button-back"
class="wizard-button" dlgtype="back"/>
<deck class="wizard-next-deck">
<hbox>
<button label="&button-finish-win.label;"
<button data-l10n-id="wizard-win-button-finish"
class="wizard-button"
dlgtype="finish" default="true" flex="1"/>
</hbox>
<hbox>
<button label="&button-next-win.label;"
accesskey="&button-next-win.accesskey;"
<button data-l10n-id="wizard-win-button-next"
accesskey="wizard-win-button-next"
class="wizard-button" dlgtype="next"
default="true" flex="1"/>
</hbox>
</deck>
<button label="&button-cancel-win.label;"
<button data-l10n-id="wizard-win-button-cancel"
class="wizard-button"
dlgtype="cancel"/>`;

Expand Down
24 changes: 0 additions & 24 deletions toolkit/locales/en-US/chrome/global/wizard.dtd

This file was deleted.

37 changes: 37 additions & 0 deletions toolkit/locales/en-US/toolkit/global/wizard.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# 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/.

wizard-macos-button-back =
.label = Go Back
.accesskey = B
wizard-linux-button-back =
.label = Back
.accesskey = B
wizard-win-button-back =
.label = < Back
.accesskey = B
wizard-macos-button-next =
.label = Continue
.accesskey = C
wizard-linux-button-next =
.label = Next
.accesskey = N
wizard-win-button-next =
.label = Next >
.accesskey = N
wizard-macos-button-finish =
.label = Done
wizard-linux-button-finish =
.label = Finish
wizard-win-button-finish =
.label = Finish
wizard-macos-button-cancel =
.label = Cancel
wizard-linux-button-cancel =
.label = Cancel
wizard-win-button-cancel =
.label = Cancel
1 change: 0 additions & 1 deletion toolkit/locales/jar.mn
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
locale/@AB_CD@/global/textcontext.dtd (%chrome/global/textcontext.dtd)
locale/@AB_CD@/global/videocontrols.dtd (%chrome/global/videocontrols.dtd)
locale/@AB_CD@/global/viewSource.properties (%chrome/global/viewSource.properties)
locale/@AB_CD@/global/wizard.dtd (%chrome/global/wizard.dtd)
locale/@AB_CD@/global/wizard.properties (%chrome/global/wizard.properties)
% locale global-platform @AB_CD@ %locale/@AB_CD@/global-platform/unix/ os=LikeUnix os=Android
% locale global-platform @AB_CD@ %locale/@AB_CD@/global-platform/mac/ os=Darwin
Expand Down

0 comments on commit 8f869c8

Please sign in to comment.