Skip to content

Commit

Permalink
Bug 1608197 - port createProfileWizard DTD to fluent r=Gijs,fluent-re…
Browse files Browse the repository at this point in the history
…viewers,flod

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

--HG--
extra : moz-landing-system : lando
  • Loading branch information
Artem committed Mar 24, 2020
1 parent 1a8fa11 commit 0a5bdf8
Show file tree
Hide file tree
Showing 7 changed files with 244 additions and 58 deletions.
149 changes: 149 additions & 0 deletions python/l10n/fluent_migrations/bug_1608197_create_profile_wizard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# 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 1608197 - Migrate createProfileWizard to Fluent, part {index}."""

ctx.add_transforms(
"toolkit/toolkit/global/createProfileWizard.ftl",
"toolkit/toolkit/global/createProfileWizard.ftl",
transforms_from(
"""
create-profile-window =
.title = { COPY(from_path, "newprofile.title") }
.style = { COPY(from_path, "window.size") }
profile-creation-explanation-4 = { PLATFORM() ->
[macos] { COPY(from_path, "profileCreationExplanation_4Mac.text") }
*[other] { COPY(from_path, "profileCreationExplanation_4.text") }
}
profile-creation-intro = { COPY(from_path, "profileCreationIntro.text") }
profile-prompt = { COPY(from_path, "profilePrompt.label") }
.accesskey = { COPY(from_path, "profilePrompt.accesskey") }
profile-default-name =
.value = { COPY(from_path, "profileDefaultName") }
profile-directory-explanation = { COPY(from_path, "profileDirectoryExplanation.text") }
create-profile-choose-folder =
.label = { COPY(from_path, "button.choosefolder.label") }
.accesskey = { COPY(from_path, "button.choosefolder.accesskey") }
create-profile-use-default =
.label = { COPY(from_path, "button.usedefault.label") }
.accesskey = { COPY(from_path, "button.usedefault.accesskey") }
""", from_path="toolkit/chrome/mozapps/profile/createProfileWizard.dtd"))
ctx.add_transforms(
"toolkit/toolkit/global/createProfileWizard.ftl",
"toolkit/toolkit/global/createProfileWizard.ftl",
[
FTL.Message(
id=FTL.Identifier("create-profile-first-page-header"),
value=FTL.Pattern(
elements=[
FTL.Placeable(
expression=FTL.SelectExpression(
selector=FTL.FunctionReference(
id=FTL.Identifier(name="PLATFORM"),
arguments=FTL.CallArguments(positional=[], named=[])
),
variants=[
FTL.Variant(
key=FTL.Identifier('macos'),
default=False,
value=COPY(
"toolkit/chrome/global/wizard.properties",
"default-first-title-mac",
)
),
FTL.Variant(
key=FTL.Identifier('other'),
default=True,
value=REPLACE(
"toolkit/chrome/global/wizard.properties",
"default-first-title",
{
"%1$S": MESSAGE_REFERENCE("create-profile-window.title"),
},
normalize_printf=True
)
)
]
)
)
]
)
),
FTL.Message(
id=FTL.Identifier("profile-creation-explanation-1"),
value=REPLACE(
"toolkit/chrome/mozapps/profile/createProfileWizard.dtd",
"profileCreationExplanation_1.text",
{
"&brandShortName;": TERM_REFERENCE("brand-short-name")
}
)
),
FTL.Message(
id=FTL.Identifier("profile-creation-explanation-2"),
value=REPLACE(
"toolkit/chrome/mozapps/profile/createProfileWizard.dtd",
"profileCreationExplanation_2.text",
{
"&brandShortName;": TERM_REFERENCE("brand-short-name")
}
)
),
FTL.Message(
id=FTL.Identifier("profile-creation-explanation-3"),
value=REPLACE(
"toolkit/chrome/mozapps/profile/createProfileWizard.dtd",
"profileCreationExplanation_3.text",
{
"&brandShortName;": TERM_REFERENCE("brand-short-name")
}
)
),
FTL.Message(
id=FTL.Identifier("create-profile-last-page-header"),
value=FTL.Pattern(
elements=[
FTL.Placeable(
expression=FTL.SelectExpression(
selector=FTL.FunctionReference(
id=FTL.Identifier(name="PLATFORM"),
arguments=FTL.CallArguments(positional=[], named=[])
),
variants=[
FTL.Variant(
key=FTL.Identifier('macos'),
default=False,
value=COPY(
"toolkit/chrome/global/wizard.properties",
"default-last-title-mac",
)
),
FTL.Variant(
key=FTL.Identifier('other'),
default=True,
value=REPLACE(
"toolkit/chrome/global/wizard.properties",
"default-last-title",
{
"%1$S": MESSAGE_REFERENCE("create-profile-window.title"),
},
normalize_printf=True
)
)
]
)
)
]
)
),
]
)
18 changes: 18 additions & 0 deletions toolkit/content/widgets/wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@
}

connectedCallback() {
if (document.l10n) {
document.l10n.connectRoot(this.shadowRoot);
}
document.documentElement.setAttribute("role", "dialog");
this._maybeStartWizard();

Expand Down Expand Up @@ -419,6 +422,10 @@
}

_adjustWizardHeader() {
if (document.l10n) {
this._adjustFluentHeaders();
return;
}
var label = this.currentPage.getAttribute("label");
if (!label && this.onFirstPage && this._bundle) {
if (AppConstants.platform == "macosx") {
Expand Down Expand Up @@ -448,6 +455,17 @@
}
}

_adjustFluentHeaders() {
let value = this.currentPage.getAttribute("data-header-label-id");
let label = this._wizardHeader.querySelector(".wizard-header-label");
if (value) {
document.l10n.setAttributes(label, value);
} else {
label.removeAttribute("data-l10n-id");
label.textContent = "";
}
}

_hitEnter(evt) {
if (!evt.defaultPrevented) {
this.advance();
Expand Down

This file was deleted.

53 changes: 53 additions & 0 deletions toolkit/locales/en-US/toolkit/global/createProfileWizard.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# 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/.

create-profile-window =
.title = Create Profile Wizard
.style = width: 45em; height: 32em;
## First wizard page

create-profile-first-page-header =
{ PLATFORM() ->
[macos] Introduction
*[other] Welcome to the { create-profile-window.title }
}
profile-creation-explanation-1 = { -brand-short-name } stores information about your settings and preferences in your personal profile.
profile-creation-explanation-2 = If you are sharing this copy of { -brand-short-name } with other users, you can use profiles to keep each user’s information separate. To do this, each user should create his or her own profile.
profile-creation-explanation-3 = If you are the only person using this copy of { -brand-short-name }, you must have at least one profile. If you would like, you can create multiple profiles for yourself to store different sets of settings and preferences. For example, you may want to have separate profiles for business and personal use.
profile-creation-explanation-4 =
{ PLATFORM() ->
[macos] To begin creating your profile, click Continue.
*[other] To begin creating your profile, click Next.
}
## Second wizard page

create-profile-last-page-header =
{ PLATFORM() ->
[macos] Conclusion
*[other] Completing the { create-profile-window.title }
}
profile-creation-intro = If you create several profiles you can tell them apart by the profile names. You may use the name provided here or use one of your own.
profile-prompt = Enter new profile name:
.accesskey = E
profile-default-name =
.value = Default User
profile-directory-explanation = Your user settings, preferences and other user-related data will be stored in:
create-profile-choose-folder =
.label = Choose Folder…
.accesskey = C
create-profile-use-default =
.label = Use Default Folder
.accesskey = U
1 change: 0 additions & 1 deletion toolkit/locales/jar.mn
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
#endif
locale/@AB_CD@/mozapps/handling/handling.dtd (%chrome/mozapps/handling/handling.dtd)
locale/@AB_CD@/mozapps/handling/handling.properties (%chrome/mozapps/handling/handling.properties)
locale/@AB_CD@/mozapps/profile/createProfileWizard.dtd (%chrome/mozapps/profile/createProfileWizard.dtd)
locale/@AB_CD@/mozapps/profile/profileSelection.properties (%chrome/mozapps/profile/profileSelection.properties)
#ifdef MOZ_BLOCK_PROFILE_DOWNGRADE
locale/@AB_CD@/mozapps/profile/profileDowngrade.dtd (%chrome/mozapps/profile/profileDowngrade.dtd)
Expand Down
54 changes: 23 additions & 31 deletions toolkit/profile/content/createProfileWizard.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@

<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<!DOCTYPE wizard [
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
%brandDTD;
<!ENTITY % profileDTD SYSTEM "chrome://mozapps/locale/profile/createProfileWizard.dtd">
%profileDTD;
]>
<!DOCTYPE wizard>

<window id="createProfileWizard"
title="&newprofile.title;"
data-l10n-id="create-profile-window"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="initWizard();"
style="&window.size;">
data-l10n-attrs="style"
>

<linkset>
<html:link rel="localization" href="branding/brand.ftl"/>
<html:link rel="localization" href="toolkit/global/createProfileWizard.ftl"/>
</linkset>

<script src="chrome://global/content/customElements.js"/>
<script src="chrome://global/content/globalOverlay.js"/>
Expand All @@ -29,44 +30,35 @@
<stringbundle id="bundle_profileManager"
src="chrome://mozapps/locale/profile/profileSelection.properties"/>

<wizardpage id="explanation">
<description>&profileCreationExplanation_1.text;</description>
<description>&profileCreationExplanation_2.text;</description>
<description>&profileCreationExplanation_3.text;</description>
<wizardpage id="explanation" data-header-label-id="create-profile-first-page-header">
<description data-l10n-id="profile-creation-explanation-1"></description>
<description data-l10n-id="profile-creation-explanation-2"></description>
<description data-l10n-id="profile-creation-explanation-3"></description>
<spacer flex="1"/>
#ifdef XP_MACOSX
<description>&profileCreationExplanation_4Mac.text;</description>
#else
#ifdef XP_UNIX
<description>&profileCreationExplanation_4Gnome.text;</description>
#else
<description>&profileCreationExplanation_4.text;</description>
#endif
#endif
<description data-l10n-id="profile-creation-explanation-4"></description>
</wizardpage>

<wizardpage id="createProfile">
<description>&profileCreationIntro.text;</description>
<wizardpage id="createProfile" data-header-label-id="create-profile-last-page-header">
<description data-l10n-id="profile-creation-intro"></description>

<label accesskey="&profilePrompt.accesskey;" control="ProfileName">&profilePrompt.label;</label>
<html:input id="profileName" value="&profileDefaultName;"
oninput="updateProfileName(this.value);"/>
<label data-l10n-id="profile-prompt" control="ProfileName"></label>
<html:input id="profileName" data-l10n-id="profile-default-name"
data-l10n-attrs="value" oninput="updateProfileName(this.value);"/>

<separator/>

<description>&profileDirectoryExplanation.text;</description>
<description data-l10n-id="profile-directory-explanation"></description>

<vbox class="indent" flex="1" style="overflow: auto;">
<description id="profileDisplay">*</description>
</vbox>

<hbox>
<button label="&button.choosefolder.label;" oncommand="chooseProfileFolder();"
accesskey="&button.choosefolder.accesskey;"/>
<button data-l10n-id="create-profile-choose-folder" oncommand="chooseProfileFolder();"/>

<button id="useDefault" label="&button.usedefault.label;"
<button id="useDefault" data-l10n-id="create-profile-use-default"
oncommand="setDisplayToDefaultFolder(); updateProfileDisplay();"
accesskey="&button.usedefault.accesskey;" disabled="true"/>
disabled="true"/>
</hbox>

<separator/>
Expand Down
2 changes: 1 addition & 1 deletion toolkit/profile/jar.mn
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

toolkit.jar:
content/mozapps/profile/createProfileWizard.js (content/createProfileWizard.js)
* content/mozapps/profile/createProfileWizard.xhtml (content/createProfileWizard.xhtml)
content/mozapps/profile/createProfileWizard.xhtml (content/createProfileWizard.xhtml)
content/mozapps/profile/profileSelection.js (content/profileSelection.js)
content/mozapps/profile/profileSelection.xhtml (content/profileSelection.xhtml)
#ifdef MOZ_BLOCK_PROFILE_DOWNGRADE
Expand Down

0 comments on commit 0a5bdf8

Please sign in to comment.