Bug 1476034 - about:crashes: switched to fluent. r=flod,Pike

Summary:
The about:crashes page is being updated (bug 1463515). To facilitate these changes,
this patch changes the about:crashes page to use Fluent for localization instead of the old systems.
This also includes a script to migrate strings from the old .DTD and .properties files
to the new .ftl one.

Test Plan:
1. build Firefox with the changes
2. run Firefox
3. go to the about:crashes page
4. expect nothing to be different

This extension: https://github.com/rhelmer/webext-experiment-crashme can be used to
add local crash reports for verifying the different states of the about:crashes page.

Reviewers: flod, Pike, jchen, snorp

Reviewed By: flod, Pike, jchen, snorp

Subscribers: nalexander, reviewbot

Bug #: 1476034

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

--HG--
extra : rebase_source : 0ca9516b4df78e735fd03907f2ea324bc72ca893
This commit is contained in:
Alexis Deschamps 2018-08-01 10:31:14 +03:00
Родитель 6c0e1e4469
Коммит dded25327a
18 изменённых файлов: 119 добавлений и 67 удалений

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

@ -169,11 +169,6 @@ whitelist = new Set(whitelist.filter(item =>
).map(item => item.file)); ).map(item => item.file));
const ignorableWhitelist = new Set([ const ignorableWhitelist = new Set([
// These 2 files are unreferenced only when building without the crash
// reporter (eg. Linux x64 asan builds on treeherder)
"chrome://global/locale/crashes.dtd",
"chrome://global/locale/crashes.properties",
// The following files are outside of the omni.ja file, so we only catch them // The following files are outside of the omni.ja file, so we only catch them
// when testing on a non-packaged build. // when testing on a non-packaged build.

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

@ -7,6 +7,7 @@
ChromeUtils.import("resource://gre/modules/AddonManager.jsm"); ChromeUtils.import("resource://gre/modules/AddonManager.jsm");
ChromeUtils.import("resource://gre/modules/AppConstants.jsm"); ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
ChromeUtils.import("resource://gre/modules/DelayedInit.jsm"); ChromeUtils.import("resource://gre/modules/DelayedInit.jsm");
ChromeUtils.import("resource://gre/modules/L10nRegistry.jsm");
ChromeUtils.import("resource://gre/modules/Messaging.jsm"); ChromeUtils.import("resource://gre/modules/Messaging.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm"); ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
@ -389,6 +390,11 @@ var BrowserApp = {
"Telemetry:CustomTabsPing", "Telemetry:CustomTabsPing",
]); ]);
// Initialize the default l10n resource sources for L10nRegistry.
let locales = Services.locale.getPackagedLocales();
const greSource = new FileSource("toolkit", locales, "resource://gre/localization/{locale}/");
L10nRegistry.registerSource(greSource);
// Provide compatibility for add-ons like QuitNow that send "Browser:Quit" // Provide compatibility for add-ons like QuitNow that send "Browser:Quit"
// as an observer notification. // as an observer notification.
Services.obs.addObserver((subject, topic, data) => Services.obs.addObserver((subject, topic, data) =>

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

@ -72,8 +72,6 @@ chrome.jar:
% override chrome://pluginproblem/locale/pluginproblem.dtd chrome://browser/locale/overrides/plugins/pluginproblem.dtd % override chrome://pluginproblem/locale/pluginproblem.dtd chrome://browser/locale/overrides/plugins/pluginproblem.dtd
% override chrome://global/locale/aboutSupport.dtd chrome://browser/locale/overrides/global/aboutSupport.dtd % override chrome://global/locale/aboutSupport.dtd chrome://browser/locale/overrides/global/aboutSupport.dtd
% override chrome://global/locale/aboutSupport.properties chrome://browser/locale/overrides/global/aboutSupport.properties % override chrome://global/locale/aboutSupport.properties chrome://browser/locale/overrides/global/aboutSupport.properties
% override chrome://global/locale/crashes.dtd chrome://browser/locale/overrides/crashreporter/crashes.dtd
% override chrome://global/locale/crashes.properties chrome://browser/locale/overrides/crashreporter/crashes.properties
% override chrome://global/locale/mozilla.dtd chrome://browser/locale/overrides/global/mozilla.dtd % override chrome://global/locale/mozilla.dtd chrome://browser/locale/overrides/global/mozilla.dtd
% override chrome://global/locale/aboutTelemetry.dtd chrome://browser/locale/overrides/global/aboutTelemetry.dtd % override chrome://global/locale/aboutTelemetry.dtd chrome://browser/locale/overrides/global/aboutTelemetry.dtd
% override chrome://global/locale/aboutTelemetry.properties chrome://browser/locale/overrides/global/aboutTelemetry.properties % override chrome://global/locale/aboutTelemetry.properties chrome://browser/locale/overrides/global/aboutTelemetry.properties

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

@ -5,8 +5,10 @@
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetters(this, { XPCOMUtils.defineLazyModuleGetters(this, {
FileSource: "resource://gre/modules/L10nRegistry.jsm",
GeckoViewTelemetryController: "resource://gre/modules/GeckoViewTelemetryController.jsm", GeckoViewTelemetryController: "resource://gre/modules/GeckoViewTelemetryController.jsm",
GeckoViewUtils: "resource://gre/modules/GeckoViewUtils.jsm", GeckoViewUtils: "resource://gre/modules/GeckoViewUtils.jsm",
L10nRegistry: "resource://gre/modules/L10nRegistry.jsm",
Services: "resource://gre/modules/Services.jsm", Services: "resource://gre/modules/Services.jsm",
}); });
@ -111,6 +113,11 @@ GeckoViewStartup.prototype = {
// The Telemetry initialization for the content process is performed in // The Telemetry initialization for the content process is performed in
// ContentProcessSingleton.js for consistency with Desktop Telemetry. // ContentProcessSingleton.js for consistency with Desktop Telemetry.
GeckoViewTelemetryController.setup(); GeckoViewTelemetryController.setup();
// Initialize the default l10n resource sources for L10nRegistry.
let locales = Services.locale.getPackagedLocales();
const greSource = new FileSource("toolkit", locales, "resource://gre/localization/{locale}/");
L10nRegistry.registerSource(greSource);
break; break;
} }
} }

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

@ -22,6 +22,7 @@
#endif #endif
@BINPATH@/dictionaries/* @BINPATH@/dictionaries/*
@BINPATH@/hyphenation/* @BINPATH@/hyphenation/*
@BINPATH@/localization/*
[assets destdir="assets/@ANDROID_CPU_ARCH@"] [assets destdir="assets/@ANDROID_CPU_ARCH@"]
#ifndef MOZ_STATIC_JS #ifndef MOZ_STATIC_JS

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

@ -29,12 +29,14 @@ def test(mod, path, entity=None):
"chrome/pluginproblem/pluginproblem.dtd", "chrome/pluginproblem/pluginproblem.dtd",
"chrome/global/aboutSupport.dtd", "chrome/global/aboutSupport.dtd",
"chrome/global/aboutSupport.properties", "chrome/global/aboutSupport.properties",
"crashreporter/crashes.dtd",
"crashreporter/crashes.properties",
"chrome/global/mozilla.dtd", "chrome/global/mozilla.dtd",
"chrome/global/aboutTelemetry.dtd", "chrome/global/aboutTelemetry.dtd",
"chrome/global/aboutTelemetry.properties", "chrome/global/aboutTelemetry.properties",
"chrome/global/aboutWebrtc.properties"): "chrome/global/aboutWebrtc.properties",
):
return "error"
if re.match(r"crashreporter/[^/]*.ftl", path):
# error on crashreporter/*.ftl
return "error" return "error"
return "ignore" return "ignore"

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

@ -50,9 +50,6 @@ relativesrcdir toolkit/locales:
# about:support # about:support
locale/@AB_CD@/browser/overrides/global/aboutSupport.dtd (%chrome/global/aboutSupport.dtd) locale/@AB_CD@/browser/overrides/global/aboutSupport.dtd (%chrome/global/aboutSupport.dtd)
locale/@AB_CD@/browser/overrides/global/aboutSupport.properties (%chrome/global/aboutSupport.properties) locale/@AB_CD@/browser/overrides/global/aboutSupport.properties (%chrome/global/aboutSupport.properties)
#about:crashes
locale/@AB_CD@/browser/overrides/crashreporter/crashes.dtd (%crashreporter/crashes.dtd)
locale/@AB_CD@/browser/overrides/crashreporter/crashes.properties (%crashreporter/crashes.properties)
#about:mozilla #about:mozilla
locale/@AB_CD@/browser/overrides/global/mozilla.dtd (%chrome/global/mozilla.dtd) locale/@AB_CD@/browser/overrides/global/mozilla.dtd (%chrome/global/mozilla.dtd)
#about:telemetry #about:telemetry
@ -69,3 +66,16 @@ relativesrcdir dom/locales:
locale/@AB_CD@/browser/overrides/dom/dom.properties (%chrome/dom/dom.properties) locale/@AB_CD@/browser/overrides/dom/dom.properties (%chrome/dom/dom.properties)
#about:plugins #about:plugins
locale/@AB_CD@/browser/overrides/plugins.properties (%chrome/plugins.properties) locale/@AB_CD@/browser/overrides/plugins.properties (%chrome/plugins.properties)
# Fluent files
# Note: All rules must be wildcards, as localized files are optional
# Only run this if we're not en-US, as en-US is already built
# by toolkit/locales/jar.mn.
#define EN_US en-US
#if AB_CD != EN_US
[localization] @AB_CD@.jar:
relativesrcdir toolkit/locales:
#about:crashes
crashreporter (%crashreporter/**/*.ftl)
#endif

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

@ -201,6 +201,10 @@ exclude-multi-locale = [
reference = "toolkit/locales/en-US/chrome/global/aboutSupport.properties" reference = "toolkit/locales/en-US/chrome/global/aboutSupport.properties"
l10n = "{l}toolkit/chrome/global/aboutSupport.properties" l10n = "{l}toolkit/chrome/global/aboutSupport.properties"
[[paths]]
reference = "toolkit/locales/en-US/crashreporter/*.ftl"
l10n = "{l}toolkit/crashreporter/*.ftl"
[[paths]] [[paths]]
reference = "toolkit/locales/en-US/crashreporter/crashes.dtd" reference = "toolkit/locales/en-US/crashreporter/crashes.dtd"
l10n = "{l}toolkit/crashreporter/crashes.dtd" l10n = "{l}toolkit/crashreporter/crashes.dtd"

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

@ -29,12 +29,14 @@ def test(mod, path, entity=None):
"chrome/pluginproblem/pluginproblem.dtd", "chrome/pluginproblem/pluginproblem.dtd",
"chrome/global/aboutSupport.dtd", "chrome/global/aboutSupport.dtd",
"chrome/global/aboutSupport.properties", "chrome/global/aboutSupport.properties",
"crashreporter/crashes.dtd",
"crashreporter/crashes.properties",
"chrome/global/mozilla.dtd", "chrome/global/mozilla.dtd",
"chrome/global/aboutTelemetry.dtd", "chrome/global/aboutTelemetry.dtd",
"chrome/global/aboutTelemetry.properties", "chrome/global/aboutTelemetry.properties",
"chrome/global/aboutWebrtc.properties"): "chrome/global/aboutWebrtc.properties",
):
return "error"
if re.match(r"crashreporter/[^/]*.ftl", path):
# error on crashreporter/*.ftl
return "error" return "error"
return "ignore" return "ignore"
@ -52,7 +54,7 @@ def test(mod, path, entity=None):
# we only have exceptions for mobile* # we only have exceptions for mobile*
return "error" return "error"
if mod == "mobile/android": if mod == "mobile/android":
if not entity: if entity is None:
if (re.match(r"mobile-l10n.js", path) or if (re.match(r"mobile-l10n.js", path) or
re.match(r"defines.inc", path)): re.match(r"defines.inc", path)):
return "ignore" return "ignore"

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

@ -0,0 +1,35 @@
# 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
def migrate(ctx):
"""Bug 1476034 - about:crashes localization migration from DTD to Fluent"""
ctx.add_transforms(
"toolkit/crashreporter/aboutcrashes.ftl",
"toolkit/crashreporter/aboutcrashes.ftl",
transforms_from(
"""
crash-reports-title = { COPY("toolkit/crashreporter/crashes.dtd", "crashReports.title") }
clear-all-reports-label = { COPY("toolkit/crashreporter/crashes.dtd", "clearAllReports.label") }
delete-confirm-title = { COPY("toolkit/crashreporter/crashes.properties", "deleteconfirm.title") }
delete-confirm-description = { COPY("toolkit/crashreporter/crashes.properties", "deleteconfirm.description") }
crashes-unsubmitted-label = { COPY("toolkit/crashreporter/crashes.dtd", "crashesUnsubmitted.label") }
id-heading = { COPY("toolkit/crashreporter/crashes.dtd", "id.heading") }
date-crashed-heading = { COPY("toolkit/crashreporter/crashes.dtd", "dateCrashed.heading") }
crashes-submitted-label = { COPY("toolkit/crashreporter/crashes.dtd", "crashesSubmitted.label") }
date-submitted-heading = { COPY("toolkit/crashreporter/crashes.dtd", "dateSubmitted.heading") }
no-reports-label = { COPY("toolkit/crashreporter/crashes.dtd", "noReports.label") }
no-config-label = { COPY("toolkit/crashreporter/crashes.dtd", "noConfig.label") }
""")
)

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

@ -19,7 +19,7 @@ th {
text-align: left; text-align: left;
white-space: nowrap; white-space: nowrap;
} }
th[chromedir="rtl"] { th:-moz-locale-dir(rtl) {
text-align: right; text-align: right;
} }
/* name */ /* name */
@ -51,7 +51,7 @@ td:last-child {
#clear-reports { #clear-reports {
float: right; float: right;
} }
#clear-reports[chromedir="rtl"] { #clear-reports:-moz-locale-dir(rtl) {
float: left; float: left;
} }

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

@ -130,12 +130,11 @@ function populateReportList() {
} }
var clearReports = async function() { var clearReports = async function() {
let bundle = Services.strings.createBundle("chrome://global/locale/crashes.properties"); const [title, description] = await document.l10n.formatValues([
{id: "delete-confirm-title"},
if (!Services. {id: "delete-confirm-description"},
prompt.confirm(window, ]);
bundle.GetStringFromName("deleteconfirm.title"), if (!Services.prompt.confirm(window, title, description)) {
bundle.GetStringFromName("deleteconfirm.description"))) {
return; return;
} }

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

@ -3,33 +3,28 @@
- License, v. 2.0. If a copy of the MPL was not distributed with this - 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/. --> - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" <!DOCTYPE html>
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
[
<!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd">
<!ENTITY % crashesDTD SYSTEM "chrome://global/locale/crashes.dtd">
%globalDTD;
%crashesDTD;
]>
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<link rel="localization" href="crashreporter/aboutcrashes.ftl"/>
<link rel="stylesheet" type="text/css" href="chrome://global/content/crashes.css"/> <link rel="stylesheet" type="text/css" href="chrome://global/content/crashes.css"/>
<link rel="stylesheet" media="screen, projection" type="text/css" <link rel="stylesheet" media="screen, projection" type="text/css"
href="chrome://global/skin/in-content/common.css"/> href="chrome://global/skin/in-content/common.css"/>
<script type="application/javascript" src="chrome://global/content/crashes.js"/> <script type="application/javascript" src="chrome://global/content/crashes.js"/>
<script type="text/javascript" src="chrome://global/content/l10n.js"/>
<title>&crashReports.title;</title> <title data-l10n-id="crash-reports-title"></title>
</head><body dir="&locale.dir;"> </head><body>
<button chromedir="&locale.dir;" id="clear-reports">&clearAllReports.label;</button> <button id="clear-reports" data-l10n-id="clear-all-reports-label"></button>
<div id="reportList"> <div id="reportList">
<div id="reportListUnsubmitted"> <div id="reportListUnsubmitted">
<h1>&crashesUnsubmitted.label;</h1> <h1 data-l10n-id="crashes-unsubmitted-label"></h1>
<table> <table>
<thead> <thead>
<tr> <tr>
<th chromedir="&locale.dir;">&id.heading;</th> <th data-l10n-id="id-heading"></th>
<th chromedir="&locale.dir;" colspan="2">&dateCrashed.heading;</th> <th colspan="2" data-l10n-id="date-crashed-heading"></th>
</tr> </tr>
</thead> </thead>
<tbody id="unsubmitted"> <tbody id="unsubmitted">
@ -37,12 +32,12 @@
</table> </table>
</div> </div>
<div id="reportListSubmitted"> <div id="reportListSubmitted">
<h1>&crashesSubmitted.label;</h1> <h1 data-l10n-id="crashes-submitted-label"></h1>
<table> <table>
<thead> <thead>
<tr> <tr>
<th chromedir="&locale.dir;">&id.heading;</th> <th data-l10n-id="id-heading"></th>
<th chromedir="&locale.dir;" colspan="2">&dateSubmitted.heading;</th> <th colspan="2" data-l10n-id="date-submitted-heading"></th>
</tr> </tr>
</thead> </thead>
<tbody id="submitted"> <tbody id="submitted">
@ -50,7 +45,7 @@
</table> </table>
</div> </div>
</div> </div>
<p id="noReports" style="display: none">&noReports.label;</p> <p id="noReports" style="display: none" data-l10n-id="no-reports-label"></p>
<p id="noConfig" style="display: none">&noConfig.label;</p> <p id="noConfig" style="display: none" data-l10n-id="no-config-label"></p>
</body> </body>
</html> </html>

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

@ -13,7 +13,7 @@
<!ENTITY aboutSupport.crashes.title "Crash Reports"> <!ENTITY aboutSupport.crashes.title "Crash Reports">
<!-- LOCALIZATION NOTE (aboutSupport.crashes.id): <!-- LOCALIZATION NOTE (aboutSupport.crashes.id):
This is likely the same like id.heading in crashes.dtd. --> This is likely the same like id.heading in aboutcrashes.ftl. -->
<!ENTITY aboutSupport.crashes.id "Report ID"> <!ENTITY aboutSupport.crashes.id "Report ID">
<!ENTITY aboutSupport.crashes.sendDate "Submitted"> <!ENTITY aboutSupport.crashes.sendDate "Submitted">
<!ENTITY aboutSupport.crashes.allReports "All Crash Reports"> <!ENTITY aboutSupport.crashes.allReports "All Crash Reports">

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

@ -0,0 +1,19 @@
# 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/-
crash-reports-title = Crash Reports
clear-all-reports-label = Remove All Reports
delete-confirm-title = Are you sure?
delete-confirm-description = This will delete all reports and cannot be undone.
crashes-unsubmitted-label = Unsubmitted Crash Reports
id-heading = Report ID
date-crashed-heading = Date Crashed
crashes-submitted-label = Submitted Crash Reports
date-submitted-heading = Date Submitted
no-reports-label = No crash reports have been submitted.
no-config-label = This application has not been configured to display crash reports. The preference <code>breakpad.reportURL</code> must be set.

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

@ -1,13 +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 crashReports.title "Crash Reports">
<!ENTITY crashesUnsubmitted.label "Unsubmitted Crash Reports">
<!ENTITY crashesSubmitted.label "Submitted Crash Reports">
<!ENTITY id.heading "Report ID">
<!ENTITY dateCrashed.heading "Date Crashed">
<!ENTITY dateSubmitted.heading "Date Submitted">
<!ENTITY noReports.label "No crash reports have been submitted.">
<!ENTITY noConfig.label "This application has not been configured to display crash reports. The preference <code>breakpad.reportURL</code> must be set.">
<!ENTITY clearAllReports.label "Remove All Reports">

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

@ -1,7 +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/.
deleteconfirm.title=Are you sure?
deleteconfirm.description=This will delete all reports and cannot be undone.

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

@ -4,6 +4,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
[localization] @AB_CD@.jar: [localization] @AB_CD@.jar:
crashreporter (%crashreporter/**/*.ftl)
toolkit (%toolkit/**/*.ftl) toolkit (%toolkit/**/*.ftl)
@AB_CD@.jar: @AB_CD@.jar:
@ -76,8 +77,6 @@
locale/@AB_CD@/global/viewSource.properties (%chrome/global/viewSource.properties) 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.dtd (%chrome/global/wizard.dtd)
locale/@AB_CD@/global/wizard.properties (%chrome/global/wizard.properties) locale/@AB_CD@/global/wizard.properties (%chrome/global/wizard.properties)
locale/@AB_CD@/global/crashes.dtd (%crashreporter/crashes.dtd)
locale/@AB_CD@/global/crashes.properties (%crashreporter/crashes.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/unix/ os=LikeUnix os=Android
% locale global-platform @AB_CD@ %locale/@AB_CD@/global-platform/mac/ os=Darwin % locale global-platform @AB_CD@ %locale/@AB_CD@/global-platform/mac/ os=Darwin
% locale global-platform @AB_CD@ %locale/@AB_CD@/global-platform/win/ os=WINNT % locale global-platform @AB_CD@ %locale/@AB_CD@/global-platform/win/ os=WINNT