Bug 1955586 - Move three home button confirmation prompts to Fluent toolbarDropHandler.ftl and out of browser.properties r=Gijs,fluent-reviewers,bolsson

Differential Revision: https://phabricator.services.mozilla.com/D242820
This commit is contained in:
shaneziegler
2025-03-26 18:18:53 +00:00
parent 043740f576
commit a33c5f3935
4 changed files with 51 additions and 8 deletions

View File

@@ -4,6 +4,10 @@
let lazy = {};
ChromeUtils.defineLazyGetter(lazy, "FluentStrings", function () {
return new Localization(["browser/toolbarDropHandler.ftl"], true);
});
ChromeUtils.defineESModuleGetters(lazy, {
HomePage: "resource:///modules/HomePage.sys.mjs",
OpenInTabsUtils:
@@ -21,13 +25,19 @@ export var ToolbarDropHandler = {
}
},
_openHomeDialog(aURL, win) {
var promptTitle = win.gNavigatorBundle.getString("droponhometitle");
async _openHomeDialog(aURL, win) {
const [promptTitle, promptMsgSingle, promptMsgMultiple] =
await lazy.FluentStrings.formatValues([
"toolbar-drop-on-home-title",
"toolbar-drop-on-home-msg",
"toolbar-drop-on-home-msg-multiple",
]);
var promptMsg;
if (aURL.includes("|")) {
promptMsg = win.gNavigatorBundle.getString("droponhomemsgMultiple");
promptMsg = promptMsgMultiple;
} else {
promptMsg = win.gNavigatorBundle.getString("droponhomemsg");
promptMsg = promptMsgSingle;
}
var pressedVal = Services.prompt.confirmEx(

View File

@@ -0,0 +1,7 @@
# 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/.
toolbar-drop-on-home-title = Set Home Page
toolbar-drop-on-home-msg = Do you want this document to be your new home page?
toolbar-drop-on-home-msg-multiple = Do you want these documents to be your new home pages?

View File

@@ -5,10 +5,6 @@
nv_timeout=Timed Out
openFile=Open File
droponhometitle=Set Home Page
droponhomemsg=Do you want this document to be your new home page?
droponhomemsgMultiple=Do you want these documents to be your new home pages?
# context menu strings
# LOCALIZATION NOTE (contextMenuSearch): %1$S is the search engine,

View File

@@ -0,0 +1,30 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
import fluent.syntax.ast as FTL
from fluent.migrate.transforms import COPY
def migrate(ctx):
"""Bug 1955586 - Convert three browser.properties used in ToolbarDropHandler.sys.mjs to Fluent, part {index}."""
source = "browser/chrome/browser/browser.properties"
target = "browser/browser/toolbarDropHandler.ftl"
ctx.add_transforms(
target,
target,
[
FTL.Message(
id=FTL.Identifier("toolbar-drop-on-home-title"),
value=COPY(source, "droponhometitle"),
),
FTL.Message(
id=FTL.Identifier("toolbar-drop-on-home-msg"),
value=COPY(source, "droponhomemsg"),
),
FTL.Message(
id=FTL.Identifier("toolbar-drop-on-home-msg-multiple"),
value=COPY(source, "droponhomemsgMultiple"),
),
],
)