Bug 1791178 - Convert nsContextMenu saveHelper() localization to Fluent. r=Gijs,fluent-reviewers,flod

These strings are only used from browser, so it doesn't make sense to keep them under toolkit.

Differential Revision: https://phabricator.services.mozilla.com/D158466
This commit is contained in:
Eemeli Aro 2022-11-09 23:32:29 +00:00
Родитель e794f85d42
Коммит 4c0e3b006e
4 изменённых файлов: 62 добавлений и 20 удалений

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

@ -1801,13 +1801,9 @@ class nsContextMenu {
// some other error occured; notify the user...
if (!Components.isSuccessCode(aRequest.status)) {
try {
const bundle = Services.strings.createBundle(
"chrome://mozapps/locale/downloads/downloads.properties"
);
const title = bundle.GetStringFromName("downloadErrorAlertTitle");
let msg = bundle.GetStringFromName("downloadErrorGeneric");
const l10n = new Localization(["browser/downloads.ftl"], true);
let msg = null;
try {
const channel = aRequest.QueryInterface(Ci.nsIChannel);
const reason = channel.loadInfo.requestBlockingReason;
@ -1817,17 +1813,19 @@ class nsContextMenu {
try {
const properties = channel.QueryInterface(Ci.nsIPropertyBag);
const id = properties.getProperty("cancelledByExtension");
msg = bundle.formatStringFromName("downloadErrorBlockedBy", [
WebExtensionPolicy.getByID(id).name,
]);
msg = l10n.formatValueSync("downloads-error-blocked-by", {
extension: WebExtensionPolicy.getByID(id).name,
});
} catch (err) {
// "cancelledByExtension" doesn't have to be available.
msg = bundle.GetStringFromName("downloadErrorExtension");
msg = l10n.formatValueSync("downloads-error-extension");
}
}
} catch (ex) {}
msg ??= l10n.formatValueSync("downloads-error-generic");
let window = Services.wm.getOuterWindowWithId(windowID);
const window = Services.wm.getOuterWindowWithId(windowID);
const title = l10n.formatValueSync("downloads-error-alert-title");
Services.prompt.alert(window, title, msg);
} catch (ex) {}
return;

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

@ -227,3 +227,17 @@ downloads-more-downloading =
[one] { $count } more file downloading
*[other] { $count } more files downloading
}
## Download errors
downloads-error-alert-title = Download Error
# Variables:
# $extension (String): the name of the blocking extension.
downloads-error-blocked-by = The download cannot be saved because it is blocked by { $extension }.
# Used when the name of the blocking extension is unavailable.
downloads-error-extension = The download cannot be saved because it is blocked by an extension.
# Line breaks in this message are meaningful, and should be maintained.
downloads-error-generic =
The download cannot be saved because an unknown error occurred.
Please try again.

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

@ -0,0 +1,39 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
import fluent.syntax.ast as FTL
from fluent.migrate.helpers import VARIABLE_REFERENCE
from fluent.migrate.transforms import COPY, REPLACE
def migrate(ctx):
"""Bug 1791178 - Convert nsContextMenu saveHelper() localization to Fluent, part {index}."""
source = "toolkit/chrome/mozapps/downloads/downloads.properties"
target = "browser/browser/downloads.ftl"
ctx.add_transforms(
target,
target,
[
FTL.Message(
id=FTL.Identifier("downloads-error-alert-title"),
value=COPY(source, "downloadErrorAlertTitle"),
),
FTL.Message(
id=FTL.Identifier("downloads-error-blocked-by"),
value=REPLACE(
source,
"downloadErrorBlockedBy",
{"%1$S": VARIABLE_REFERENCE("extension")},
),
),
FTL.Message(
id=FTL.Identifier("downloads-error-extension"),
value=COPY(source, "downloadErrorExtension"),
),
FTL.Message(
id=FTL.Identifier("downloads-error-generic"),
value=COPY(source, "downloadErrorGeneric"),
),
],
)

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

@ -22,15 +22,6 @@ shortHours=h;h
# d is the short form for days
shortDays=d;d
downloadErrorAlertTitle=Download Error
# LOCALIZATION NOTE (downloadErrorBlockedBy): %S is the name of the blocking
# extension.
downloadErrorBlockedBy=The download cannot be saved because it is blocked by %S.
# LOCALIZATION NOTE (downloadErrorExtension): used when the blocking extension
# name is unavailable.
downloadErrorExtension=The download cannot be saved because it is blocked by an extension.
downloadErrorGeneric=The download cannot be saved because an unknown error occurred.\n\nPlease try again.
# LOCALIZATION NOTE: we don't have proper plural support in the CPP code; bug 463102
quitCancelDownloadsAlertTitle=Cancel All Downloads?
quitCancelDownloadsAlertMsg=If you exit now, 1 download will be canceled. Are you sure you want to exit?