Bug 1760029 - Migrate tabbrowser.properties strings used by OpenInTabsUtils.jsm to Fluent. r=dao,fluent-reviewers,flod

Differential Revision: https://phabricator.services.mozilla.com/D159020
This commit is contained in:
Eemeli Aro 2022-11-22 17:12:23 +00:00
Родитель fc6d78c4e0
Коммит 7fa5435add
4 изменённых файлов: 68 добавлений и 31 удалений

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

@ -107,6 +107,18 @@ tabbrowser-confirm-close-tabs-with-key-button = Quit { -brand-short-name }
# $quitKey (String): the text of the keyboard shortcut for quitting.
tabbrowser-confirm-close-tabs-with-key-checkbox = Confirm before quitting with { $quitKey }
## Confirmation dialog when opening multiple tabs simultaneously
tabbrowser-confirm-open-multiple-tabs-title = Confirm open
# Variables:
# $tabCount (Number): The number of tabs that will be opened.
tabbrowser-confirm-open-multiple-tabs-message =
{ $tabCount ->
*[other] You are about to open { $tabCount } tabs. This might slow down { -brand-short-name } while the pages are loading. Are you sure you want to continue?
}
tabbrowser-confirm-open-multiple-tabs-button = Open tabs
tabbrowser-confirm-open-multiple-tabs-checkbox = Warn me when opening multiple tabs might slow down { -brand-short-name }
## Confirmation dialog for enabling caret browsing
tabbrowser-confirm-caretbrowsing-title = Caret Browsing

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

@ -1,11 +1,3 @@
# 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/.
# LOCALIZATION NOTE (tabs.openWarningTitle, tabs.openWarningMultipleBranded, tabs.openButtonMultiple, tabs.openWarningPromptMeBranded):
# These items are moved from chrome/browser/places/places.properties
# Now they are not specific to bookmark.
tabs.openWarningTitle=Confirm open
tabs.openWarningMultipleBranded=You are about to open %S tabs. This might slow down %S while the pages are loading. Are you sure you want to continue?
tabs.openButtonMultiple=Open tabs
tabs.openWarningPromptMeBranded=Warn me when opening multiple tabs might slow down %S

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

@ -12,9 +12,10 @@ const { XPCOMUtils } = ChromeUtils.importESModule(
const lazy = {};
XPCOMUtils.defineLazyGetter(lazy, "bundle", function() {
return Services.strings.createBundle(
"chrome://browser/locale/tabbrowser.properties"
XPCOMUtils.defineLazyGetter(lazy, "l10n", () => {
return new Localization(
["browser/tabbrowser.ftl", "branding/brand.ftl"],
true
);
});
@ -23,14 +24,6 @@ XPCOMUtils.defineLazyGetter(lazy, "bundle", function() {
* called without any tabbrowser instance.
*/
const OpenInTabsUtils = {
getString(key) {
return lazy.bundle.GetStringFromName(key);
},
getFormattedString(key, params) {
return lazy.bundle.formatStringFromName(key, params);
},
/**
* Gives the user a chance to cancel loading lots of tabs at once.
*/
@ -47,25 +40,26 @@ const OpenInTabsUtils = {
// default to true: if it were false, we wouldn't get this far
let warnOnOpen = { value: true };
const messageKey = "tabs.openWarningMultipleBranded";
const openKey = "tabs.openButtonMultiple";
const BRANDING_BUNDLE_URI = "chrome://branding/locale/brand.properties";
let brandShortName = Services.strings
.createBundle(BRANDING_BUNDLE_URI)
.GetStringFromName("brandShortName");
const [title, message, button, checkbox] = lazy.l10n.formatMessagesSync([
{ id: "tabbrowser-confirm-open-multiple-tabs-title" },
{
id: "tabbrowser-confirm-open-multiple-tabs-message",
args: { tabCount: numTabsToOpen },
},
{ id: "tabbrowser-confirm-open-multiple-tabs-button" },
{ id: "tabbrowser-confirm-open-multiple-tabs-checkbox" },
]);
let buttonPressed = Services.prompt.confirmEx(
aWindow,
this.getString("tabs.openWarningTitle"),
this.getFormattedString(messageKey, [numTabsToOpen, brandShortName]),
title.value,
message.value,
Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_0 +
Services.prompt.BUTTON_TITLE_CANCEL * Services.prompt.BUTTON_POS_1,
this.getString(openKey),
button.value,
null,
null,
this.getFormattedString("tabs.openWarningPromptMeBranded", [
brandShortName,
]),
checkbox.value,
warnOnOpen
);

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

@ -248,6 +248,45 @@ def migrate(ctx):
{"%1$S": VARIABLE_REFERENCE("quitKey")},
),
),
FTL.Message(
id=FTL.Identifier("tabbrowser-confirm-open-multiple-tabs-title"),
value=COPY(source, "tabs.openWarningTitle"),
),
FTL.Message(
id=FTL.Identifier("tabbrowser-confirm-open-multiple-tabs-message"),
value=Transform.pattern_of(
FTL.SelectExpression(
selector=VARIABLE_REFERENCE("tabCount"),
variants=[
FTL.Variant(
key=FTL.Identifier("other"),
value=REPLACE(
source,
"tabs.openWarningMultipleBranded",
{
"%1$S": VARIABLE_REFERENCE("tabCount"),
"%2$S": TERM_REFERENCE("brand-short-name"),
". ": FTL.TextElement(". "),
},
),
default=True,
),
],
)
),
),
FTL.Message(
id=FTL.Identifier("tabbrowser-confirm-open-multiple-tabs-button"),
value=COPY(source, "tabs.openButtonMultiple"),
),
FTL.Message(
id=FTL.Identifier("tabbrowser-confirm-open-multiple-tabs-checkbox"),
value=REPLACE(
source,
"tabs.openWarningPromptMeBranded",
{"%1$S": TERM_REFERENCE("brand-short-name")},
),
),
FTL.Message(
id=FTL.Identifier("tabbrowser-confirm-caretbrowsing-title"),
value=COPY(source, "browsewithcaret.checkWindowTitle"),