Bug 1517529 - Migrate safeMode dialog to Fluent for localization, r=Gijs,flod

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
cowlesni 2019-01-21 21:51:10 +00:00
Родитель a41077218e
Коммит 994165ff86
8 изменённых файлов: 160 добавлений и 46 удалений

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

@ -77,4 +77,6 @@ function onLoad() {
document.documentElement.getButton("extra1").hidden = true;
document.getElementById("resetProfileInstead").hidden = true;
}
document.l10n.translateElements(document.querySelectorAll("label, description")).then(
() => window.sizeToContent());
}

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

@ -4,46 +4,43 @@
- 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/. -->
<!DOCTYPE prefwindow [
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" >
%brandDTD;
<!ENTITY % safeModeDTD SYSTEM "chrome://browser/locale/safeMode.dtd" >
%safeModeDTD;
<!ENTITY % resetProfileDTD SYSTEM "chrome://global/locale/resetProfile.dtd" >
%resetProfileDTD;
]>
<?xml-stylesheet href="chrome://global/skin/"?>
<?xml-stylesheet href="chrome://browser/content/safeMode.css"?>
<dialog id="safeModeDialog"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&safeModeDialog.title;"
data-l10n-id="safe-mode-window"
data-l10n-attrs="title,style"
buttons="accept,extra1"
buttonlabelaccept="&startSafeMode.label;"
buttonlabelextra1="&refreshProfile.label;"
maxwidth="&window.maxWidth;"
buttonidaccept="start-safe-mode"
buttonidextra1="refresh-profile"
ondialogaccept="return onDefaultButton()"
ondialogcancel="onCancel();"
ondialogextra1="return onExtra1()"
onload="onLoad()">
<linkset>
<link rel="localization" href="branding/brand.ftl"/>
<link rel="localization" href="browser/safeMode.ftl"/>
</linkset>
<script type="application/javascript" src="chrome://browser/content/safeMode.js"/>
<vbox id="autoSafeMode" hidden="true">
<description>&autoSafeModeDescription3.label;</description>
<description data-l10n-id="auto-safe-mode-description"/>
</vbox>
<vbox id="safeMode">
<label>&safeModeDescription3.label;</label>
<label data-l10n-id="safe-mode-description" />
<separator class="thin"/>
<label>&safeModeDescription5.label;</label>
<label data-l10n-id="safe-mode-description-details" />
<separator class="thin"/>
<label id="resetProfileInstead">&refreshProfileInstead.label;</label>
<label id="resetProfileInstead" data-l10n-id="refresh-profile-instead"/>
</vbox>
<vbox id="resetProfile" hidden="true">
<label id="resetProfileInstead">&refreshProfileInstead.label;</label>
<label data-l10n-id="refresh-profile-instead" />
</vbox>
<separator class="thin"/>

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

@ -1007,6 +1007,14 @@ BrowserGlue.prototype = {
PdfJs.earlyInit();
}
// Initialize the default l10n resource sources for L10nRegistry.
let locales = Services.locale.packagedLocales;
const greSource = new FileSource("toolkit", locales, "resource://gre/localization/{locale}/");
L10nRegistry.registerSource(greSource);
const appSource = new FileSource("app", locales, "resource://app/localization/{locale}/");
L10nRegistry.registerSource(appSource);
// check if we're in safe mode
if (Services.appinfo.inSafeMode) {
Services.ww.openWindow(null, "chrome://browser/content/safeMode.xul",
@ -1073,14 +1081,6 @@ BrowserGlue.prototype = {
Normandy.init();
// Initialize the default l10n resource sources for L10nRegistry.
let locales = Services.locale.packagedLocales;
const greSource = new FileSource("toolkit", locales, "resource://gre/localization/{locale}/");
L10nRegistry.registerSource(greSource);
const appSource = new FileSource("app", locales, "resource://app/localization/{locale}/");
L10nRegistry.registerSource(appSource);
SaveToPocket.init();
Services.obs.notifyObservers(null, "browser-ui-startup-complete");
},

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

@ -0,0 +1,16 @@
# 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/.
safe-mode-window =
.title = { -brand-short-name } Safe Mode
.style = max-width: 400px
start-safe-mode =
.label = Start in Safe Mode
refresh-profile =
.label = Refresh { -brand-short-name }
safe-mode-description = Safe Mode is a special mode of { -brand-short-name } that can be used to troubleshoot issues.
safe-mode-description-details = Your add-ons and custom settings will be temporarily disabled, and { -brand-short-name } features may not perform as they currently do.
refresh-profile-instead = You can also skip troubleshooting and try refreshing { -brand-short-name }.
# Shown on the safe mode dialog after multiple startup crashes.
auto-safe-mode-description = { -brand-short-name } closed unexpectedly while starting. This might be caused by add-ons or other problems. You can try to resolve the problem by troubleshooting in Safe Mode.

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

@ -1,17 +0,0 @@
<!-- 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/. -->
<!ENTITY safeModeDialog.title "&brandShortName; Safe Mode">
<!ENTITY window.maxWidth "400">
<!ENTITY startSafeMode.label "Start in Safe Mode">
<!ENTITY refreshProfile.label "Refresh &brandShortName;">
<!ENTITY safeModeDescription3.label "Safe Mode is a special mode of &brandShortName; that can be used to troubleshoot issues.">
<!ENTITY safeModeDescription5.label "Your add-ons and custom settings will be temporarily disabled, and &brandShortName; features may not perform as they currently do.">
<!ENTITY refreshProfileInstead.label "You can also skip troubleshooting and try refreshing &brandShortName;.">
<!-- LOCALIZATION NOTE (autoSafeModeDescription3.label): Shown on the safe mode dialog after multiple startup crashes. See also chrome/global/resetProfile.dtd -->
<!ENTITY autoSafeModeDescription3.label "&brandShortName; closed unexpectedly while starting. This might be caused by add-ons or other problems. You can try to resolve the problem by troubleshooting in Safe Mode.">

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

@ -27,7 +27,6 @@
locale/browser/pageInfo.dtd (%chrome/browser/pageInfo.dtd)
locale/browser/pageInfo.properties (%chrome/browser/pageInfo.properties)
locale/browser/pocket.properties (%chrome/browser/pocket.properties)
locale/browser/safeMode.dtd (%chrome/browser/safeMode.dtd)
locale/browser/search.properties (%chrome/browser/search.properties)
locale/browser/siteData.properties (%chrome/browser/siteData.properties)
locale/browser/sitePermissions.properties (%chrome/browser/sitePermissions.properties)

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

@ -0,0 +1,117 @@
# 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.helpers import MESSAGE_REFERENCE, TERM_REFERENCE
from fluent.migrate import COPY, CONCAT, REPLACE
def migrate(ctx):
"""Bug 1517529 - Migrate safeMode from DTD to Fluent, part {index}."""
ctx.add_transforms(
'browser/browser/safeMode.ftl',
'browser/browser/safeMode.ftl',
[
FTL.Message(
id=FTL.Identifier('safe-mode-window'),
attributes=[
FTL.Attribute(
FTL.Identifier('title'),
value=REPLACE(
'browser/chrome/browser/safeMode.dtd',
'safeModeDialog.title',
{
"&brandShortName;": TERM_REFERENCE("brand-short-name")
}
)
),
FTL.Attribute(
FTL.Identifier('style'),
value=CONCAT(
FTL.TextElement('max-width: '),
COPY(
'browser/chrome/browser/safeMode.dtd',
'window.maxWidth'
),
FTL.TextElement('px')
)
)
]
),
]
),
ctx.add_transforms(
'browser/browser/safeMode.ftl',
'browser/browser/safeMode.ftl',
transforms_from(
"""
start-safe-mode =
.label = { COPY("browser/chrome/browser/safeMode.dtd", "startSafeMode.label") }
"""
)
),
ctx.add_transforms(
'browser/browser/safeMode.ftl',
'browser/browser/safeMode.ftl',
[
FTL.Message(
id=FTL.Identifier('refresh-profile'),
attributes=[
FTL.Attribute(
FTL.Identifier('label'),
value=REPLACE(
'browser/chrome/browser/safeMode.dtd',
'refreshProfile.label',
{
"&brandShortName;": TERM_REFERENCE("brand-short-name")
}
)
)
]
),
FTL.Message(
id=FTL.Identifier('safe-mode-description'),
value=REPLACE(
'browser/chrome/browser/safeMode.dtd',
'safeModeDescription3.label',
{
"&brandShortName;": TERM_REFERENCE("brand-short-name")
}
)
),
FTL.Message(
id=FTL.Identifier('safe-mode-description-details'),
value=REPLACE(
'browser/chrome/browser/safeMode.dtd',
'safeModeDescription5.label',
{
"&brandShortName;": TERM_REFERENCE("brand-short-name")
}
)
),
FTL.Message(
id=FTL.Identifier('refresh-profile-instead'),
value=REPLACE(
'browser/chrome/browser/safeMode.dtd',
'refreshProfileInstead.label',
{
"&brandShortName;": TERM_REFERENCE("brand-short-name")
}
)
),
FTL.Message(
id=FTL.Identifier('auto-safe-mode-description'),
value=REPLACE(
'browser/chrome/browser/safeMode.dtd',
'autoSafeModeDescription3.label',
{
"&brandShortName;": TERM_REFERENCE("brand-short-name")
}
)
)
]
)

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

@ -284,13 +284,13 @@
button.setAttribute("label", this.getAttribute("buttonlabel" + dlgtype));
if (this.hasAttribute("buttonaccesskey" + dlgtype))
button.setAttribute("accesskey", this.getAttribute("buttonaccesskey" + dlgtype));
} else if (this.hasAttribute("buttonid" + dlgtype)) {
document.l10n.setAttributes(button, this.getAttribute("buttonid" + dlgtype));
} else if (dlgtype != "extra1" && dlgtype != "extra2") {
button.setAttribute("label", this.mStrBundle.GetStringFromName("button-" + dlgtype));
var accessKey = this.mStrBundle.GetStringFromName("accesskey-" + dlgtype);
if (accessKey)
button.setAttribute("accesskey", accessKey);
} else if (this.hasAttribute("buttonid" + dlgtype)) {
document.l10n.setAttributes(button, this.getAttribute("buttonid" + dlgtype));
}
}
// allow specifying alternate icons in the dialog header