Bug 1955747 - Migrate strings in shellservice.properties to Fluent, r=nrishel,eemeli

Differential Revision: https://phabricator.services.mozilla.com/D242977
This commit is contained in:
Francesco Lodolo (:flod)
2025-04-02 05:42:44 +00:00
parent 8ff36ffa3d
commit 88fdda4cc7
9 changed files with 74 additions and 35 deletions

View File

@@ -11,7 +11,6 @@
<stringbundleset id="stringbundleset">
<stringbundle id="bundle_brand" src="chrome://branding/locale/brand.properties"/>
<stringbundle id="bundle_shell" src="chrome://browser/locale/shellservice.properties"/>
</stringbundleset>
<!-- The event listeners are defined by _initCommandSet in browser-init.js -->

View File

@@ -109,8 +109,10 @@ var gSetBackground = {
"setDesktopBackground"
);
setDesktopBackground.hidden = false;
var bundle = document.getElementById("backgroundBundle");
setDesktopBackground.label = bundle.getString("DesktopBackgroundSet");
document.l10n.setAttributes(
setDesktopBackground,
"set-desktop-background-accept"
);
setDesktopBackground.disabled = false;
document.getElementById("showDesktopPreferences").hidden = true;
@@ -130,13 +132,13 @@ var gSetBackground = {
} else {
Services.obs.addObserver(this, "shell:desktop-background-changed");
var bundle = document.getElementById("backgroundBundle");
var setDesktopBackground = document.getElementById(
"setDesktopBackground"
);
setDesktopBackground.disabled = true;
setDesktopBackground.label = bundle.getString(
"DesktopBackgroundDownloading"
document.l10n.setAttributes(
setDesktopBackground,
"set-desktop-background-downloading"
);
}
this._shell.setDesktopBackground(

View File

@@ -36,8 +36,6 @@
<script src="chrome://browser/content/utilityOverlay.js"/>
#endif
<stringbundle id="backgroundBundle"
src="chrome://browser/locale/shellservice.properties"/>
<script src="chrome://browser/content/setDesktopBackground.js"/>
<script src="chrome://global/content/contentAreaUtils.js"/>

View File

@@ -6,6 +6,4 @@
#define PREF_CHECKDEFAULTBROWSER "browser.shell.checkDefaultBrowser"
#define PREF_DEFAULTBROWSERCHECKCOUNT "browser.shell.defaultBrowserCheckCount"
#define SHELLSERVICE_PROPERTIES \
"chrome://browser/locale/shellservice.properties"
#define BRAND_PROPERTIES "chrome://branding/locale/brand.properties"

View File

@@ -456,7 +456,7 @@ nsWindowsShellService::SetDefaultBrowser(bool aForAllUsers) {
}
/*
* Asynchronious function to Write an ico file to the disk / in a nsIFile.
* Asynchronous function to Write an ico file to the disk / in a nsIFile.
* Limitation: Only square images are supported as of now.
*/
NS_IMETHODIMP
@@ -677,21 +677,18 @@ nsWindowsShellService::SetDesktopBackground(dom::Element* aElement,
rv = request->GetImage(getter_AddRefs(container));
if (!container) return NS_ERROR_FAILURE;
// get the file name from localized strings
nsCOMPtr<nsIStringBundleService> bundleService(
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIStringBundle> shellBundle;
rv = bundleService->CreateBundle(SHELLSERVICE_PROPERTIES,
getter_AddRefs(shellBundle));
NS_ENSURE_SUCCESS(rv, rv);
// e.g. "Desktop Background.bmp"
nsAutoString fileLeafName;
rv = shellBundle->GetStringFromName("desktopBackgroundLeafNameWin",
fileLeafName);
NS_ENSURE_SUCCESS(rv, rv);
// get the file name from localized strings, e.g. "Desktop Background", then
// append the extension (".bmp").
nsTArray<nsCString> resIds = {
"browser/browser/setDesktopBackground.ftl"_ns,
};
RefPtr<Localization> l10n = Localization::Create(resIds, true);
nsAutoCString fileLeafNameUtf8;
IgnoredErrorResult locRv;
l10n->FormatValueSync("set-desktop-background-filename"_ns, {},
fileLeafNameUtf8, locRv);
nsAutoString fileLeafName = NS_ConvertUTF8toUTF16(fileLeafNameUtf8);
fileLeafName.AppendLiteral(".bmp");
// get the profile root directory
nsCOMPtr<nsIFile> file;
@@ -708,7 +705,7 @@ nsWindowsShellService::SetDesktopBackground(dom::Element* aElement,
NS_ENSURE_SUCCESS(rv, rv);
// write the bitmap to a file in the profile directory.
// We have to write old bitmap format for Windows 7 wallpapar support.
// We have to write old bitmap format for Windows 7 wallpaper support.
rv = WriteBitmap(file, container);
// if the file was written successfully, set it as the system wallpaper

View File

@@ -11,8 +11,15 @@ set-desktop-background-accept =
open-desktop-prefs =
.label = Open Desktop Preferences
set-desktop-background-downloading =
.label = Saving Picture…
set-background-preview-unavailable = Preview unavailable
# Name of the file that will be used as the desktop background. The
# extension ".bmp" is added by the system.
set-desktop-background-filename = Desktop Background
# This refers to the wallpaper "spanning" multiple monitors when the
# user has more than one. Only some of the entire image will be on
# each monitor. This should ideally match the wording in Windows' own

View File

@@ -1,7 +0,0 @@
# 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/.
desktopBackgroundLeafNameWin=Desktop Background.bmp
DesktopBackgroundDownloading=Saving Picture…
DesktopBackgroundSet=Set Desktop Background

View File

@@ -30,7 +30,6 @@
locale/browser/search.properties (%chrome/browser/search.properties)
locale/browser/siteData.properties (%chrome/browser/siteData.properties)
locale/browser/sitePermissions.properties (%chrome/browser/sitePermissions.properties)
locale/browser/shellservice.properties (%chrome/browser/shellservice.properties)
locale/browser/taskbar.properties (%chrome/browser/taskbar.properties)
locale/browser/downloads/downloads.properties (%chrome/browser/downloads/downloads.properties)
locale/browser/places/bookmarkProperties.properties (%chrome/browser/places/bookmarkProperties.properties)

View File

@@ -0,0 +1,46 @@
# 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 transforms_from
from fluent.migrate.transforms import COPY, LegacySource, Transform
class REMOVE_EXTENSION(LegacySource):
def __call__(self, ctx):
element: FTL.TextElement = super(REMOVE_EXTENSION, self).__call__(ctx)
element.value = element.value.removesuffix(".bmp")
return Transform.pattern_of(element)
def migrate(ctx):
"""Bug 1955747 - Migrate shellservice.properties to fluent, part {index}."""
source = "browser/chrome/browser/shellservice.properties"
target = "browser/browser/setDesktopBackground.ftl"
ctx.add_transforms(
target,
target,
transforms_from(
"""
set-desktop-background-downloading =
.label = { COPY(from_path, "DesktopBackgroundDownloading") }
""",
from_path=source,
),
)
ctx.add_transforms(
target,
target,
[
FTL.Message(
id=FTL.Identifier("set-desktop-background-filename"),
value=REMOVE_EXTENSION(
source,
"desktopBackgroundLeafNameWin",
),
),
],
)