[tbb-commits] [Git][tpo/applications/mullvad-browser][mullvad-browser-115.9.0esr-13.5-1] 3 commits: fixup! Bug 40926: Implemented the New Identity feature
richard (@richard)
git at gitlab.torproject.org
Wed Mar 20 20:55:57 UTC 2024
richard pushed to branch mullvad-browser-115.9.0esr-13.5-1 at The Tor Project / Applications / Mullvad Browser
Commits:
2ce971c7 by Henry Wilkes at 2024-03-20T20:54:07+00:00
fixup! Bug 40926: Implemented the New Identity feature
Bug 42211: Migrate to Fluent.
- - - - -
5a1f3b54 by Henry Wilkes at 2024-03-20T20:54:14+00:00
fixup! Base Browser strings
Bug 42211: Migrate new identity to Fluent.
Also change some strings to sentence case in en-US.
Also removed the hard-coded "Tor Browser", which is not appropriate in
base-browser (e.g. for Mullvad Browser).
- - - - -
a8282d9c by Henry Wilkes at 2024-03-20T20:54:20+00:00
fixup! Tor Browser localization migration scripts.
Bug 42211: Migrate new identity strings to Fluent.
- - - - -
10 changed files:
- browser/base/content/appmenu-viewcache.inc.xhtml
- browser/base/content/browser-menubar.inc
- browser/base/content/navigator-toolbox.inc.xhtml
- browser/components/newidentity/content/newIdentityDialog.js
- browser/components/newidentity/content/newIdentityDialog.xhtml
- browser/components/newidentity/content/newidentity.js
- browser/locales/en-US/browser/base-browser.ftl
- − browser/locales/en-US/chrome/browser/newIdentity.properties
- browser/locales/jar.mn
- + tools/torbrowser/l10n/migrations/bug-42211-new-identity.py
Changes:
=====================================
browser/base/content/appmenu-viewcache.inc.xhtml
=====================================
@@ -57,6 +57,7 @@
<toolbarseparator/>
<toolbarbutton id="appMenu-new-identity"
class="subviewbutton"
+ data-l10n-id="appmenuitem-new-identity"
key="new-identity-key"/>
<toolbarseparator/>
<toolbarbutton id="appMenu-bookmarks-button"
=====================================
browser/base/content/browser-menubar.inc
=====================================
@@ -30,7 +30,7 @@
key="key_privatebrowsing" data-l10n-id="menu-file-new-private-window"/>
<menuseparator/>
<menuitem id="menu_newIdentity"
- key="new-identity-key"/>
+ key="new-identity-key" data-l10n-id="menu-new-identity"/>
<menuseparator/>
<menuitem id="menu_openLocation"
hidden="true"
=====================================
browser/base/content/navigator-toolbox.inc.xhtml
=====================================
@@ -590,7 +590,8 @@
ondragover="newWindowButtonObserver.onDragOver(event)"
ondragenter="newWindowButtonObserver.onDragOver(event)"/>
- <toolbarbutton id="new-identity-button" class="toolbarbutton-1 chromeclass-toolbar-additional"/>
+ <toolbarbutton id="new-identity-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
+ data-l10n-id="toolbar-new-identity"/>
<toolbarbutton id="fullscreen-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
observes="View:FullScreen"
=====================================
browser/components/newidentity/content/newIdentityDialog.js
=====================================
@@ -5,20 +5,13 @@
document.addEventListener("dialogaccept", () => {
const retvals = window.arguments[0];
retvals.confirmed = true;
- retvals.neverAskAgain = document.querySelector("#neverAskAgain").checked;
+ retvals.neverAskAgain = document.getElementById("neverAskAgain").checked;
});
document.addEventListener("DOMContentLoaded", () => {
- const { NewIdentityStrings } = window.arguments[0];
- const dialog = document.querySelector("#newIdentityDialog");
+ const dialog = document.getElementById("newIdentityDialog");
- dialog.querySelector("#infoTitle").textContent =
- NewIdentityStrings.new_identity_prompt_title;
- dialog.querySelector("#infoBody").textContent =
- NewIdentityStrings.new_identity_prompt;
- dialog.querySelector("#neverAskAgain").label =
- NewIdentityStrings.new_identity_ask_again;
const accept = dialog.getButton("accept");
- accept.label = NewIdentityStrings.new_identity_restart;
+ document.l10n.setAttributes(accept, "new-identity-dialog-confirm");
accept.classList.add("danger-button");
});
=====================================
browser/components/newidentity/content/newIdentityDialog.xhtml
=====================================
@@ -21,9 +21,8 @@
>
<dialog id="newIdentityDialog" buttons="accept,cancel" defaultButton="accept">
<linkset>
- <!-- Without this document.l10n is not initialized, and we need it for the
- cancel button. -->
<html:link rel="localization" href="branding/brand.ftl" />
+ <html:link rel="localization" href="browser/base-browser.ftl" />
</linkset>
<div xmlns="http://www.w3.org/1999/xhtml">
@@ -33,13 +32,18 @@
<xul:image id="infoIcon" />
</div>
<div id="infoContainer">
- <xul:description id="infoTitle" />
+ <xul:description
+ id="infoTitle"
+ data-l10n-id="new-identity-dialog-title"
+ />
<xul:description
id="infoBody"
- context="contentAreaContextMenu"
- noinitialfocus="true"
+ data-l10n-id="new-identity-dialog-description"
+ />
+ <xul:checkbox
+ id="neverAskAgain"
+ data-l10n-id="new-identity-dialog-never-ask-checkbox"
/>
- <xul:checkbox id="neverAskAgain" />
</div>
</div>
</div>
=====================================
browser/components/newidentity/content/newidentity.js
=====================================
@@ -1,40 +1,6 @@
"use strict";
-/* globals CustomizableUI Services gFindBarInitialized gFindBar
- OpenBrowserWindow PrivateBrowsingUtils XPCOMUtils
- */
-
-XPCOMUtils.defineLazyGetter(this, "NewIdentityStrings", () => {
- const brandBundle = Services.strings.createBundle(
- "chrome://branding/locale/brand.properties"
- );
- const brandShortName = brandBundle.GetStringFromName("brandShortName");
-
- const fallbackBundle = Services.strings.createBundle(
- "resource:///chrome/en-US/locale/browser/newIdentity.properties"
- );
- const strings = {};
- const brandedStrings = ["new_identity_prompt", "new_identity_restart"];
- for (let { key } of fallbackBundle.getSimpleEnumeration()) {
- strings[key] = fallbackBundle.GetStringFromName(key);
- }
- try {
- const bundle = Services.strings.createBundle(
- "chrome://browser/locale/newIdentity.properties"
- );
- for (const key of Object.keys(strings)) {
- try {
- strings[key] = bundle.GetStringFromName(key);
- } catch (e) {}
- }
- } catch (e) {
- console.warn("Could not load localized New Identity strings");
- }
- for (let key of brandedStrings) {
- strings[key] = strings[key].replaceAll("%S", brandShortName);
- }
- return strings;
-});
+/* eslint-env mozilla/browser-window */
// Use a lazy getter because NewIdentityButton is declared more than once
// otherwise.
@@ -471,11 +437,6 @@ XPCOMUtils.defineLazyGetter(this, "NewIdentityButton", () => {
// malformed URL, bail out
return;
}
- const label =
- NewIdentityStrings.new_identity_home_notification.replace(
- "%S",
- displayAddress
- );
const callback = () => {
Services.prefs.setStringPref(trustedHomePref, homeURL);
win.BrowserHome();
@@ -484,12 +445,15 @@ XPCOMUtils.defineLazyGetter(this, "NewIdentityButton", () => {
notificationBox.appendNotification(
"new-identity-safe-home",
{
- label,
+ label: {
+ "l10n-id": "new-identity-blocked-home-notification",
+ "l10n-args": { url: displayAddress },
+ },
priority: notificationBox.PRIORITY_INFO_MEDIUM,
},
[
{
- label: NewIdentityStrings.new_identity_home_load_button,
+ "l10n-id": "new-identity-blocked-home-ignore-button",
callback,
},
]
@@ -550,37 +514,20 @@ XPCOMUtils.defineLazyGetter(this, "NewIdentityButton", () => {
const button =
document.getElementById("new-identity-button") ||
window.gNavToolbox.palette.querySelector("#new-identity-button");
- if (button) {
- button.setAttribute("tooltiptext", NewIdentityStrings.new_identity);
- // Include an equal label, shown in the overflow menu or during
- // customization.
- button.setAttribute("label", NewIdentityStrings.new_identity);
- button.addEventListener("command", () => {
- this.onCommand();
- });
- }
- const viewCache = document.getElementById("appMenu-viewCache").content;
- const appButton = viewCache.querySelector("#appMenu-new-identity");
- if (appButton) {
- appButton.setAttribute(
- "label",
- NewIdentityStrings.new_identity_sentence_case
- );
- appButton.addEventListener("command", () => {
+ button?.addEventListener("command", () => {
+ this.onCommand();
+ });
+ document
+ .getElementById("appMenu-viewCache")
+ .content.querySelector("#appMenu-new-identity")
+ ?.addEventListener("command", () => {
this.onCommand();
});
- }
- const menu = document.querySelector("#menu_newIdentity");
- if (menu) {
- menu.setAttribute("label", NewIdentityStrings.new_identity);
- menu.setAttribute(
- "accesskey",
- NewIdentityStrings.new_identity_menu_accesskey
- );
- menu.addEventListener("command", () => {
+ document
+ .getElementById("menu_newIdentity")
+ ?.addEventListener("command", () => {
this.onCommand();
});
- }
},
uninit() {},
@@ -598,7 +545,6 @@ XPCOMUtils.defineLazyGetter(this, "NewIdentityButton", () => {
const shouldConfirm = Services.prefs.getBoolPref(prefConfirm, true);
if (shouldConfirm) {
const params = {
- NewIdentityStrings,
confirmed: false,
neverAskAgain: false,
};
=====================================
browser/locales/en-US/browser/base-browser.ftl
=====================================
@@ -11,20 +11,19 @@ language-notification-label-system = { -brand-short-name } has set your display
language-notification-label = { -brand-short-name } has set your display language to { $language }.
language-notification-button = Change Language…
-
## Fullscreen/maximization notification shown when letterboxing is disabled
basebrowser-rfp-maximize-warning-message = Maximizing the browser window can allow websites to determine your monitor size, which can be used to track you. We recommend that you leave browser windows in their original default size.
basebrowser-rfp-restore-window-size-button-label = Restore
basebrowser-rfp-restore-window-size-button-ak = R
-
## Tooltip for the about:addons recommended badge
basebrowser-addon-badge-recommended = Mozilla only recommends extensions that meet their standards for security and performance
basebrowser-addon-badge-verified = Mozilla has reviewed this extension to meet their standards for security and performance
## Option to show or hide the NoScript extension button/item.
+
basebrowser-addon-noscript-visibility-label = Toolbar button
basebrowser-addon-noscript-visibility-show = Show
basebrowser-addon-noscript-visibility-hide = Hide
@@ -35,3 +34,39 @@ basebrowser-addon-noscript-visibility-hide = Hide
# $version (String) - The current browser version. E.g. "12.5.3".
# $firefoxVersion (String) - The version number of Firefox the current browser is based on. E.g. "102.15.0esr".
basebrowser-about-dialog-version = { $version } (based on Mozilla Firefox { $firefoxVersion })
+
+## New identity.
+
+# File menu items use title case for English (US).
+menu-new-identity =
+ .label = New Identity
+ .accesskey = I
+
+# App menu (hamburger menu) items use sentence case for English (US).
+appmenuitem-new-identity =
+ .label = New identity
+
+# Uses sentence case for English (US).
+# ".label" is the accessible name, and is visible in the overflow menu and when
+# customizing the toolbar.
+# ".tooltiptext" will be identical to the label.
+toolbar-new-identity =
+ .label = New identity
+ .tooltiptext = { toolbar-new-identity.label }
+
+## New identity dialog.
+
+new-identity-dialog-title = Reset your identity?
+new-identity-dialog-description = { -brand-short-name } will close all windows and tabs. All website sessions will be lost.
+new-identity-dialog-never-ask-checkbox =
+ .label = Never ask me again
+new-identity-dialog-confirm =
+ .label = Restart { -brand-short-name }
+
+## New identity: blocked home page notification.
+
+# '-brand-short-name' is the localized browser name, like "Tor Browser".
+# $url (String) - The URL of the home page, possibly shortened.
+new-identity-blocked-home-notification = { -brand-short-name } blocked your homepage ({ $url }) from loading because it might recognize your previous session.
+# Button to continue loading the home page, despite the warning message.
+new-identity-blocked-home-ignore-button = Load it anyway
=====================================
browser/locales/en-US/chrome/browser/newIdentity.properties deleted
=====================================
@@ -1,13 +0,0 @@
-new_identity = New Identity
-# This is the string for the hamburger menu
-new_identity_sentence_case = New identity
-# %S is the application name. Keep it as a placeholder
-new_identity_prompt_title = Reset your identity?
-new_identity_prompt = %S will close all windows and tabs. All website sessions will be lost. \nRestart %S now to reset your identity?
-new_identity_restart = Restart %S
-new_identity_ask_again = Never ask me again
-# Shown in the File menu (use Alt to show File, if you do not see)
-new_identity_menu_accesskey = I
-new_identity_home_notification = Tor Browser blocked your homepage (%S) from loading because it might recognize your previous session.
-# %S is replaced with the custom homepage URL's domain if applicable, or some short-hand of it otherwise
-new_identity_home_load_button = Load it anyway
=====================================
browser/locales/jar.mn
=====================================
@@ -33,5 +33,4 @@
locale/browser/feeds/subscribe.properties (%chrome/browser/feeds/subscribe.properties)
locale/browser/syncSetup.properties (%chrome/browser/syncSetup.properties)
locale/browser/securityLevel.properties (%chrome/browser/securityLevel.properties)
- locale/browser/newIdentity.properties (%chrome/browser/newIdentity.properties)
% locale browser-region @AB_CD@ %locale/browser-region/
=====================================
tools/torbrowser/l10n/migrations/bug-42211-new-identity.py
=====================================
@@ -0,0 +1,48 @@
+import fluent.syntax.ast as FTL
+from fluent.migrate.helpers import TERM_REFERENCE, transforms_from
+from fluent.migrate.transforms import REPLACE
+
+
+def migrate(ctx):
+ legacy_path = "newIdentity.properties"
+
+ ctx.add_transforms(
+ "base-browser.ftl",
+ "base-browser.ftl",
+ transforms_from(
+ """
+menu-new-identity =
+ .label = { COPY(path, "new_identity") }
+ .accesskey = { COPY(path, "new_identity_menu_accesskey") }
+appmenuitem-new-identity =
+ .label = { COPY(path, "new_identity_sentence_case") }
+toolbar-new-identity =
+ .label = { COPY(path, "new_identity_sentence_case") }
+ .tooltiptext = { toolbar-new-identity.label }
+
+new-identity-dialog-title = { COPY(path, "new_identity_prompt_title") }
+new-identity-dialog-never-ask-checkbox =
+ .label = { COPY(path, "new_identity_ask_again") }
+
+new-identity-blocked-home-ignore-button = { COPY(path, "new_identity_home_load_button") }
+""",
+ path=legacy_path,
+ )
+ + [
+ # Replace "%S" with "{ -brand-short-name }" in confirm button.
+ FTL.Message(
+ id=FTL.Identifier("new-identity-dialog-confirm"),
+ value=None,
+ attributes=[
+ FTL.Attribute(
+ id=FTL.Identifier("label"),
+ value=REPLACE(
+ legacy_path,
+ "new_identity_restart",
+ {"%1$S": TERM_REFERENCE("brand-short-name")},
+ ),
+ ),
+ ],
+ ),
+ ],
+ )
View it on GitLab: https://gitlab.torproject.org/tpo/applications/mullvad-browser/-/compare/96ab6401af562a726620e438435bbd0790d6b98e...a8282d9ca507994cf21025f22c6ba3e13d5e3973
--
View it on GitLab: https://gitlab.torproject.org/tpo/applications/mullvad-browser/-/compare/96ab6401af562a726620e438435bbd0790d6b98e...a8282d9ca507994cf21025f22c6ba3e13d5e3973
You're receiving this email because of your account on gitlab.torproject.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.torproject.org/pipermail/tbb-commits/attachments/20240320/a5fe477f/attachment-0001.htm>
More information about the tbb-commits
mailing list