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:
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
<stringbundleset id="stringbundleset">
|
<stringbundleset id="stringbundleset">
|
||||||
<stringbundle id="bundle_brand" src="chrome://branding/locale/brand.properties"/>
|
<stringbundle id="bundle_brand" src="chrome://branding/locale/brand.properties"/>
|
||||||
<stringbundle id="bundle_shell" src="chrome://browser/locale/shellservice.properties"/>
|
|
||||||
</stringbundleset>
|
</stringbundleset>
|
||||||
|
|
||||||
<!-- The event listeners are defined by _initCommandSet in browser-init.js -->
|
<!-- The event listeners are defined by _initCommandSet in browser-init.js -->
|
||||||
|
|||||||
@@ -109,8 +109,10 @@ var gSetBackground = {
|
|||||||
"setDesktopBackground"
|
"setDesktopBackground"
|
||||||
);
|
);
|
||||||
setDesktopBackground.hidden = false;
|
setDesktopBackground.hidden = false;
|
||||||
var bundle = document.getElementById("backgroundBundle");
|
document.l10n.setAttributes(
|
||||||
setDesktopBackground.label = bundle.getString("DesktopBackgroundSet");
|
setDesktopBackground,
|
||||||
|
"set-desktop-background-accept"
|
||||||
|
);
|
||||||
setDesktopBackground.disabled = false;
|
setDesktopBackground.disabled = false;
|
||||||
|
|
||||||
document.getElementById("showDesktopPreferences").hidden = true;
|
document.getElementById("showDesktopPreferences").hidden = true;
|
||||||
@@ -130,13 +132,13 @@ var gSetBackground = {
|
|||||||
} else {
|
} else {
|
||||||
Services.obs.addObserver(this, "shell:desktop-background-changed");
|
Services.obs.addObserver(this, "shell:desktop-background-changed");
|
||||||
|
|
||||||
var bundle = document.getElementById("backgroundBundle");
|
|
||||||
var setDesktopBackground = document.getElementById(
|
var setDesktopBackground = document.getElementById(
|
||||||
"setDesktopBackground"
|
"setDesktopBackground"
|
||||||
);
|
);
|
||||||
setDesktopBackground.disabled = true;
|
setDesktopBackground.disabled = true;
|
||||||
setDesktopBackground.label = bundle.getString(
|
document.l10n.setAttributes(
|
||||||
"DesktopBackgroundDownloading"
|
setDesktopBackground,
|
||||||
|
"set-desktop-background-downloading"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
this._shell.setDesktopBackground(
|
this._shell.setDesktopBackground(
|
||||||
|
|||||||
@@ -36,8 +36,6 @@
|
|||||||
<script src="chrome://browser/content/utilityOverlay.js"/>
|
<script src="chrome://browser/content/utilityOverlay.js"/>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
<stringbundle id="backgroundBundle"
|
|
||||||
src="chrome://browser/locale/shellservice.properties"/>
|
|
||||||
<script src="chrome://browser/content/setDesktopBackground.js"/>
|
<script src="chrome://browser/content/setDesktopBackground.js"/>
|
||||||
<script src="chrome://global/content/contentAreaUtils.js"/>
|
<script src="chrome://global/content/contentAreaUtils.js"/>
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,4 @@
|
|||||||
#define PREF_CHECKDEFAULTBROWSER "browser.shell.checkDefaultBrowser"
|
#define PREF_CHECKDEFAULTBROWSER "browser.shell.checkDefaultBrowser"
|
||||||
#define PREF_DEFAULTBROWSERCHECKCOUNT "browser.shell.defaultBrowserCheckCount"
|
#define PREF_DEFAULTBROWSERCHECKCOUNT "browser.shell.defaultBrowserCheckCount"
|
||||||
|
|
||||||
#define SHELLSERVICE_PROPERTIES \
|
|
||||||
"chrome://browser/locale/shellservice.properties"
|
|
||||||
#define BRAND_PROPERTIES "chrome://branding/locale/brand.properties"
|
#define BRAND_PROPERTIES "chrome://branding/locale/brand.properties"
|
||||||
|
|||||||
@@ -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.
|
* Limitation: Only square images are supported as of now.
|
||||||
*/
|
*/
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
@@ -677,21 +677,18 @@ nsWindowsShellService::SetDesktopBackground(dom::Element* aElement,
|
|||||||
rv = request->GetImage(getter_AddRefs(container));
|
rv = request->GetImage(getter_AddRefs(container));
|
||||||
if (!container) return NS_ERROR_FAILURE;
|
if (!container) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
// get the file name from localized strings
|
// get the file name from localized strings, e.g. "Desktop Background", then
|
||||||
nsCOMPtr<nsIStringBundleService> bundleService(
|
// append the extension (".bmp").
|
||||||
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv));
|
nsTArray<nsCString> resIds = {
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
"browser/browser/setDesktopBackground.ftl"_ns,
|
||||||
|
};
|
||||||
nsCOMPtr<nsIStringBundle> shellBundle;
|
RefPtr<Localization> l10n = Localization::Create(resIds, true);
|
||||||
rv = bundleService->CreateBundle(SHELLSERVICE_PROPERTIES,
|
nsAutoCString fileLeafNameUtf8;
|
||||||
getter_AddRefs(shellBundle));
|
IgnoredErrorResult locRv;
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
l10n->FormatValueSync("set-desktop-background-filename"_ns, {},
|
||||||
|
fileLeafNameUtf8, locRv);
|
||||||
// e.g. "Desktop Background.bmp"
|
nsAutoString fileLeafName = NS_ConvertUTF8toUTF16(fileLeafNameUtf8);
|
||||||
nsAutoString fileLeafName;
|
fileLeafName.AppendLiteral(".bmp");
|
||||||
rv = shellBundle->GetStringFromName("desktopBackgroundLeafNameWin",
|
|
||||||
fileLeafName);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
// get the profile root directory
|
// get the profile root directory
|
||||||
nsCOMPtr<nsIFile> file;
|
nsCOMPtr<nsIFile> file;
|
||||||
@@ -708,7 +705,7 @@ nsWindowsShellService::SetDesktopBackground(dom::Element* aElement,
|
|||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// write the bitmap to a file in the profile directory.
|
// 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);
|
rv = WriteBitmap(file, container);
|
||||||
|
|
||||||
// if the file was written successfully, set it as the system wallpaper
|
// if the file was written successfully, set it as the system wallpaper
|
||||||
|
|||||||
@@ -11,8 +11,15 @@ set-desktop-background-accept =
|
|||||||
open-desktop-prefs =
|
open-desktop-prefs =
|
||||||
.label = Open Desktop Preferences
|
.label = Open Desktop Preferences
|
||||||
|
|
||||||
|
set-desktop-background-downloading =
|
||||||
|
.label = Saving Picture…
|
||||||
|
|
||||||
set-background-preview-unavailable = Preview unavailable
|
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
|
# This refers to the wallpaper "spanning" multiple monitors when the
|
||||||
# user has more than one. Only some of the entire image will be on
|
# 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
|
# each monitor. This should ideally match the wording in Windows' own
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -30,7 +30,6 @@
|
|||||||
locale/browser/search.properties (%chrome/browser/search.properties)
|
locale/browser/search.properties (%chrome/browser/search.properties)
|
||||||
locale/browser/siteData.properties (%chrome/browser/siteData.properties)
|
locale/browser/siteData.properties (%chrome/browser/siteData.properties)
|
||||||
locale/browser/sitePermissions.properties (%chrome/browser/sitePermissions.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/taskbar.properties (%chrome/browser/taskbar.properties)
|
||||||
locale/browser/downloads/downloads.properties (%chrome/browser/downloads/downloads.properties)
|
locale/browser/downloads/downloads.properties (%chrome/browser/downloads/downloads.properties)
|
||||||
locale/browser/places/bookmarkProperties.properties (%chrome/browser/places/bookmarkProperties.properties)
|
locale/browser/places/bookmarkProperties.properties (%chrome/browser/places/bookmarkProperties.properties)
|
||||||
|
|||||||
@@ -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",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user