Bug 1703003 - Migrate Bookmark panel Cancel/Remove buttons to Fluent and fix capitalization, r=mconley

Differential Revision: https://phabricator.services.mozilla.com/D110894
This commit is contained in:
Francesco Lodolo (:flod) 2021-04-06 17:15:31 +00:00
Родитель 7b81541330
Коммит 830a1bba6e
5 изменённых файлов: 77 добавлений и 41 удалений

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

@ -255,29 +255,13 @@ var StarUI = {
let removeButton = this._element("editBookmarkPanelRemoveButton");
if (this._isNewBookmark) {
removeButton.label = gNavigatorBundle.getString(
"editBookmarkPanel.cancel.label"
);
removeButton.setAttribute(
"accesskey",
gNavigatorBundle.getString("editBookmarkPanel.cancel.accesskey")
);
document.l10n.setAttributes(removeButton, "bookmark-panel-cancel");
} else {
// The label of the remove button differs if the URI is bookmarked
// multiple times.
let bookmarksCount = this._itemGuids.length;
let forms = gNavigatorBundle.getString(
"editBookmark.removeBookmarks.label"
);
let label = PluralForm.get(bookmarksCount, forms).replace(
"#1",
bookmarksCount
);
removeButton.label = label;
removeButton.setAttribute(
"accesskey",
gNavigatorBundle.getString("editBookmark.removeBookmarks.accesskey")
);
document.l10n.setAttributes(removeButton, "bookmark-panel-remove", {
count: this._itemGuids.length,
});
}
this._setIconAndPreviewImage();

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

@ -106,13 +106,8 @@ async function test_bookmarks_popup({
"title should match isEditingBookmark state"
);
Assert.equal(
bookmarkRemoveButton.label,
isNewBookmark
? gNavigatorBundle.getString("editBookmarkPanel.cancel.label")
: PluralForm.get(
1,
gNavigatorBundle.getString("editBookmark.removeBookmarks.label")
).replace("#1", 1),
bookmarkRemoveButton.dataset.l10nId,
isNewBookmark ? "bookmark-panel-cancel" : "bookmark-panel-remove",
"remove/cancel button label should match isEditingBookmark state"
);

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

@ -267,8 +267,20 @@ search-one-offs-history =
## Bookmark Panel
bookmarks-add-bookmark = Add Bookmark
bookmarks-edit-bookmark = Edit Bookmark
bookmarks-add-bookmark = Add bookmark
bookmarks-edit-bookmark = Edit bookmark
bookmark-panel-cancel =
.label = Cancel
.accesskey = C
# Variables:
# $count (number): number of bookmarks that will be removed
bookmark-panel-remove =
.label =
{ $count ->
[1] Remove bookmark
*[other] Remove { $count } bookmarks
}
.accesskey = R
bookmark-panel-show-editor-checkbox =
.label = Show editor when saving
.accesskey = S

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

@ -569,18 +569,6 @@ protections.footer.blockedTrackerCounter.tooltip=Since %S
# In English this looks like "Firefox blocked over 10,000 trackers since Oct 2019"
protections.milestone.description=#1 blocked #2 tracker since #3;#1 blocked over #2 trackers since #3
# Edit Bookmark UI
editBookmarkPanel.cancel.label=Cancel
editBookmarkPanel.cancel.accesskey=C
# LOCALIZATION NOTE (editBookmark.removeBookmarks.label): Semicolon-separated list of plural forms.
# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
# Replacement for #1 is the number of bookmarks to be removed.
# If this causes problems with localization you can also do "Remove Bookmarks (#1)"
# instead of "Remove #1 Bookmarks".
editBookmark.removeBookmarks.label=Remove Bookmark;Remove #1 Bookmarks
editBookmark.removeBookmarks.accesskey=R
# Application menu
# LOCALIZATION NOTE(zoomReduce-button.tooltip): %S is the keyboard shortcut.

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

@ -0,0 +1,57 @@
# coding=utf8
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
from __future__ import absolute_import
from fluent.migrate.helpers import transforms_from
import fluent.syntax.ast as FTL
from fluent.migrate import COPY, PLURALS, REPLACE, REPLACE_IN_TEXT
from fluent.migrate.helpers import COPY, VARIABLE_REFERENCE
def migrate(ctx):
"""Bug 1703003 - Migrate remove/cancel button in Bookmark panel to Fluent - part {index}"""
ctx.add_transforms(
"browser/browser/browser.ftl",
"browser/browser/browser.ftl",
transforms_from(
"""
bookmark-panel-cancel =
.label = { COPY(from_path, "editBookmarkPanel.cancel.label") }
.accesskey = { COPY(from_path, "editBookmarkPanel.cancel.accesskey") }
""",
from_path="browser/chrome/browser/browser.properties",
),
)
ctx.add_transforms(
"browser/browser/browser.ftl",
"browser/browser/browser.ftl",
[
FTL.Message(
id=FTL.Identifier("bookmark-panel-remove"),
attributes=[
FTL.Attribute(
id=FTL.Identifier("label"),
value=PLURALS(
"browser/chrome/browser/browser.properties",
"editBookmark.removeBookmarks.label",
VARIABLE_REFERENCE("count"),
lambda text: REPLACE_IN_TEXT(
text, {"#1": VARIABLE_REFERENCE("count")}
),
),
),
FTL.Attribute(
id=FTL.Identifier("accesskey"),
value=COPY(
"browser/chrome/browser/browser.properties",
"editBookmark.removeBookmarks.accesskey",
),
),
],
)
],
)