Bug 1497694 - Migrate Update History in Update section of Preferences to use Fluent for localization r=Gijs,flod,zbraniecki,jaws

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Qinghao_Jack_Song 2018-10-31 16:11:30 +00:00
Родитель 692726391c
Коммит 0f0e2e06e2
10 изменённых файлов: 103 добавлений и 44 удалений

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

@ -459,7 +459,10 @@
class="accessory-button"
data-l10n-id="update-history"
preference="app.update.disable_button.showUpdateHistory"
searchkeywords="&history.title; &history2.intro;"/>
search-l10n-ids="
history-title,
history-intro
"/>
</vbox>
#endif
</hbox>

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

@ -18,14 +18,12 @@
<!DOCTYPE page [
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
<!ENTITY % historyDTD SYSTEM "chrome://mozapps/locale/update/history.dtd">
<!ENTITY % certManagerDTD SYSTEM "chrome://pippki/locale/certManager.dtd">
<!ENTITY % deviceManangerDTD SYSTEM "chrome://pippki/locale/deviceManager.dtd">
<!ENTITY % sanitizeDTD SYSTEM "chrome://browser/locale/sanitize.dtd">
<!ENTITY % aboutDialogDTD SYSTEM "chrome://browser/locale/aboutDialog.dtd" >
%aboutDialogDTD;
%brandDTD;
%historyDTD;
%certManagerDTD;
%deviceManangerDTD;
%sanitizeDTD;
@ -52,6 +50,7 @@
<link rel="localization" href="browser/preferences/permissions.ftl"/>
<link rel="localization" href="browser/preferences/selectBookmark.ftl"/>
<link rel="localization" href="browser/preferences/siteDataSettings.ftl"/>
<link rel="localization" href="toolkit/updates/history.ftl"/>
</linkset>
<html:link rel="shortcut icon"

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

@ -140,8 +140,11 @@ add_task(async function() {
for (let i = 0; i < updates.length; ++i) {
update = updates[i];
updateData = mockUpdateManager.getUpdateAt(i);
is(update.name, updateData.name + " (" + updateData.buildID + ")", "Wrong update name");
const l10nAttrs = frameDoc.l10n.getAttributes(update);
Assert.deepEqual(l10nAttrs, {
id: "update-full-name",
args: { name: updateData.name, buildID: updateData.buildID },
}, "Wrong update name");
is(update.installDate, formatInstallDate(updateData.installDate), "Wrong update installDate");
is(update.detailsURL, updateData.detailsURL, "Wrong update detailsURL");
is(update.status, updateData.statusText, "Wrong update status");

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

@ -0,0 +1,58 @@
# 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
from fluent.migrate import REPLACE
from fluent.migrate import REPLACE_IN_TEXT
from fluent.migrate.helpers import VARIABLE_REFERENCE
def migrate(ctx):
"""Bug 1497687 - Migrate Update History in Update section of Preferences to use Fluent for localization, part {index}."""
ctx.add_transforms(
"toolkit/toolkit/updates/history.ftl",
"toolkit/toolkit/updates/history.ftl",
transforms_from(
"""
history-title = { COPY("toolkit/chrome/mozapps/update/history.dtd", "history.title") }
history-intro = { COPY("toolkit/chrome/mozapps/update/history.dtd", "history2.intro") }
close-button-label =
.buttonlabelcancel = { COPY("toolkit/chrome/mozapps/update/history.dtd", "closebutton.label") }
.title = { COPY("toolkit/chrome/mozapps/update/history.dtd", "history.title") }
no-updates-label = { COPY("toolkit/chrome/mozapps/update/history.dtd", "noupdates.label") }
name-header = { COPY("toolkit/chrome/mozapps/update/history.dtd", "name.header") }
date-header = { COPY("toolkit/chrome/mozapps/update/history.dtd", "date.header") }
type-header = { COPY("toolkit/chrome/mozapps/update/history.dtd", "type.header") }
state-header = { COPY("toolkit/chrome/mozapps/update/history.dtd", "state.header") }
""")
)
ctx.add_transforms(
"toolkit/toolkit/updates/history.ftl",
"toolkit/toolkit/updates/history.ftl",
[
FTL.Message(
id=FTL.Identifier("update-full-name"),
attributes=[
FTL.Attribute(
id=FTL.Identifier("name"),
value=REPLACE(
"toolkit/chrome/mozapps/update/updates.properties",
"updateFullName",
{
"%1$S": VARIABLE_REFERENCE("name"),
"%2$S": VARIABLE_REFERENCE("buildID"),
},
normalize_printf=True
)
)
]
)
]
)

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

@ -1,16 +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 history.title "Update History">
<!ENTITY history2.intro "The following updates have been installed">
<!ENTITY closebutton.label "Close">
<!ENTITY noupdates.label "No updates installed yet">
<!ENTITY name.header "Update Name">
<!ENTITY date.header "Install Date">
<!ENTITY type.header "Type">
<!ENTITY state.header "State">

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

@ -2,11 +2,6 @@
# 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/.
# LOCALIZATION NOTE: The 1st %S is the update name and the 2nd %S is the build
# identifier from the local updates.xml for displaying update history
# example: MyApplication (20081022033543)
updateFullName=%S (%S)
# LOCALIZATION NOTE: The 1st %S is brandShortName and 2nd %S is update version
# where update version from the update xml
# example: MyApplication 10.0.5

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

@ -0,0 +1,24 @@
# 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/.
history-title = Update History
history-intro = The following updates have been installed
close-button-label =
.buttonlabelcancel = Close
.title = Update History
no-updates-label = No updates installed yet
name-header = Update Name
date-header = Install Date
type-header = Type
state-header = State
# Used to display update history
#
# Variables:
# $name (String): name of the update
# $buildID (String): build identifier from the local updates.xml
update-full-name =
.name = { $name } ({ $buildID })

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

@ -98,7 +98,6 @@
locale/@AB_CD@/mozapps/update/updates.dtd (%chrome/mozapps/update/updates.dtd)
locale/@AB_CD@/mozapps/update/updates.properties (%chrome/mozapps/update/updates.properties)
#endif
locale/@AB_CD@/mozapps/update/history.dtd (%chrome/mozapps/update/history.dtd)
% locale pluginproblem @AB_CD@ %locale/@AB_CD@/pluginproblem/
locale/@AB_CD@/pluginproblem/pluginproblem.dtd (%chrome/pluginproblem/pluginproblem.dtd)
% locale alerts @AB_CD@ %locale/@AB_CD@/alerts/

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

@ -20,8 +20,6 @@ var gUpdateHistory = {
while (this._view.hasChildNodes())
this._view.firstChild.remove();
var bundle = document.getElementById("updateBundle");
for (var i = 0; i < uc; ++i) {
var update = um.getUpdateAt(i);
@ -36,8 +34,8 @@ var gUpdateHistory = {
var element = document.createXULElement("richlistitem");
element.className = "update";
this._view.appendChild(element);
element.name = bundle.getFormattedString("updateFullName",
[update.name, update.buildID]);
element.setAttribute("data-l10n-attrs", "name");
document.l10n.setAttributes(element, "update-full-name", { name: update.name, buildID: update.buildID});
element.installDate = this._formatDate(update.installDate);
if (update.detailsURL)
element.detailsURL = update.detailsURL;

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

@ -4,12 +4,7 @@
- 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 dialog [
<!ENTITY % historyDTD SYSTEM "chrome://mozapps/locale/update/history.dtd">
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
%historyDTD;
%brandDTD;
]>
<!DOCTYPE dialog>
<?xml-stylesheet href="chrome://global/skin/"?>
<?xml-stylesheet href="chrome://mozapps/content/update/updates.css"?>
@ -20,20 +15,21 @@
style="width: 35em;"
buttons="cancel"
defaultButton="cancel"
buttonlabelcancel="&closebutton.label;"
title="&history.title;"
data-l10n-id="close-button-label"
data-l10n-attrs="buttonlabelcancel"
onload="gUpdateHistory.onLoad();">
<linkset>
<link rel="localization" href="toolkit/updates/history.ftl"/>
</linkset>
<script type="application/javascript"
src="chrome://mozapps/content/update/history.js"/>
<stringbundle id="updateBundle"
src="chrome://mozapps/locale/update/updates.properties"/>
<label>&history2.intro;</label>
<label data-l10n-id="history-intro"></label>
<separator class="thin"/>
<richlistbox id="historyItems" flex="1">
<label>&noupdates.label;</label>
<label data-l10n-id="no-updates-label"></label>
</richlistbox>
<separator class="thin"/>
</dialog>