From ce4209dd224a6b216fb9faede6e63f12ff81b59b Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Wed, 5 Feb 2025 10:53:30 +0000 Subject: [PATCH] Bug 1936528 - Rename generated update.locale as default.locale, always include it r=nalexander,geckoview-reviewers,browser-installer-reviewers,valentin,ohall Differential Revision: https://phabricator.services.mozilla.com/D232605 --- browser/installer/allowed-dupes.mn | 2 +- browser/installer/package-manifest.in | 2 +- intl/docs/locale_startup.rst | 4 ++-- intl/locale/LocaleService.cpp | 8 ++++---- mobile/android/installer/allowed-dupes.mn | 2 +- mobile/android/installer/package-manifest.in | 2 +- mobile/android/installer/removed-files.in | 1 - mobile/ios/installer/allowed-dupes.mn | 2 +- modules/libjar/nsJARChannel.cpp | 7 ------- pyproject.toml | 1 - .../mozbuild/mozbuild/action/test_archive.py | 2 +- python/mozbuild/mozpack/packager/formats.py | 2 +- .../mozpack/test/test_packager_formats.py | 2 +- ...te_locale.py => generate_default_locale.py} | 4 ++-- toolkit/locales/moz.build | 8 ++++---- toolkit/modules/UpdateUtils.sys.mjs | 18 ++++++++---------- .../tests/xpcshell/test_UpdateUtils_url.js | 1 + toolkit/mozapps/installer/l10n-repack.py | 2 +- 18 files changed, 30 insertions(+), 40 deletions(-) rename toolkit/locales/{generate_update_locale.py => generate_default_locale.py} (65%) diff --git a/browser/installer/allowed-dupes.mn b/browser/installer/allowed-dupes.mn index 213a99ed433d52..c4802f99f50cf2 100644 --- a/browser/installer/allowed-dupes.mn +++ b/browser/installer/allowed-dupes.mn @@ -51,7 +51,7 @@ res/table-remove-column.gif res/table-remove-row.gif res/multilocale.txt -update.locale +default.locale # Bug 1451016 - Nightly-only PaymentRequest & Form Autofill code sharing. browser/features/formautofill@mozilla.org/chrome/content/editAddress.xhtml diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in index 90cbbc891f44e7..a95cd98c450dc6 100644 --- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -57,8 +57,8 @@ #ifdef HAVE_MAKENSISU @BINPATH@/uninstall/helper.exe #endif +@RESPATH@/default.locale #ifdef MOZ_UPDATER -@RESPATH@/update.locale @RESPATH@/updater.ini #endif #if defined(MOZ_UPDATE_AGENT) diff --git a/intl/docs/locale_startup.rst b/intl/docs/locale_startup.rst index ea6849b11765ed..f12963049b8bba 100644 --- a/intl/docs/locale_startup.rst +++ b/intl/docs/locale_startup.rst @@ -22,7 +22,7 @@ Data Sources There are three primary sources that become available during the bootstrap. -1) Packaged locale lists stored in files :js:`update.locale` and :js:`multilocale.txt`. +1) Packaged locale lists stored in files :js:`default.locale` and :js:`multilocale.txt`. 2) User preferences read from the profile. @@ -60,7 +60,7 @@ are being read, so the data is being fetched using packaged preferences. In case of Desktop Firefox the :js:`intl.locale.requested` pref will be not set, which means Gecko will use the default locale which is retrieved from -:js:`update.locale` file (also packaged). +:js:`default.locale` file (also packaged). This means that the initial result of language negotiation is between packaged locales as available and the default requested locale. diff --git a/intl/locale/LocaleService.cpp b/intl/locale/LocaleService.cpp index 7cb42fbb11ca3f..a56a1575da879e 100644 --- a/intl/locale/LocaleService.cpp +++ b/intl/locale/LocaleService.cpp @@ -408,10 +408,10 @@ LocaleService::GetDefaultLocale(nsACString& aRetVal) { // time), so we cache the result the first time we're called. if (mDefaultLocale.IsEmpty()) { nsAutoCString locale; - // Try to get the package locale from update.locale in omnijar. If the - // update.locale file is not found, item.len will remain 0 and we'll + // Try to get the package locale from default.locale in omnijar. If the + // default.locale file is not found, item.len will remain 0 and we'll // just use our hard-coded default below. - GetGREFileContents("update.locale", &locale); + GetGREFileContents("default.locale", &locale); locale.Trim(" \t\n\r"); #ifdef MOZ_UPDATER // This should never be empty. @@ -421,7 +421,7 @@ LocaleService::GetDefaultLocale(nsACString& aRetVal) { mDefaultLocale.Assign(locale); } - // Hard-coded fallback to allow us to survive even if update.locale was + // Hard-coded fallback to allow us to survive even if default.locale was // missing/broken in some way. if (mDefaultLocale.IsEmpty()) { GetLastFallbackLocale(mDefaultLocale); diff --git a/mobile/android/installer/allowed-dupes.mn b/mobile/android/installer/allowed-dupes.mn index 1b9a92e058b1a9..8c3fbe55459ab4 100644 --- a/mobile/android/installer/allowed-dupes.mn +++ b/mobile/android/installer/allowed-dupes.mn @@ -14,7 +14,7 @@ res/table-remove-column.gif res/table-remove-row.gif res/multilocale.txt -update.locale +default.locale #ifdef MOZ_ANDROID_FAT_AAR_ARCHITECTURES defaults/pref/arm64-v8a/geckoview-prefs.js diff --git a/mobile/android/installer/package-manifest.in b/mobile/android/installer/package-manifest.in index 37f29152454f8e..e91dce96119dc0 100644 --- a/mobile/android/installer/package-manifest.in +++ b/mobile/android/installer/package-manifest.in @@ -16,7 +16,7 @@ [@AB_CD@] @BINPATH@/@PREF_DIR@/mobile-l10n.js -@BINPATH@/update.locale +@BINPATH@/default.locale #ifdef MOZ_UPDATER @BINPATH@/updater.ini #endif diff --git a/mobile/android/installer/removed-files.in b/mobile/android/installer/removed-files.in index 125c8eb2e12667..8b4ec8c14e2f67 100644 --- a/mobile/android/installer/removed-files.in +++ b/mobile/android/installer/removed-files.in @@ -1,3 +1,2 @@ -update.locale README.txt components/dom_webspeech.xpt diff --git a/mobile/ios/installer/allowed-dupes.mn b/mobile/ios/installer/allowed-dupes.mn index ea78f4e303be0c..2b91660ca5c781 100644 --- a/mobile/ios/installer/allowed-dupes.mn +++ b/mobile/ios/installer/allowed-dupes.mn @@ -14,7 +14,7 @@ res/table-remove-column.gif res/table-remove-row.gif res/multilocale.txt -update.locale +default.locale components/httpd.sys.mjs chrome/remote/content/server/httpd.sys.mjs diff --git a/modules/libjar/nsJARChannel.cpp b/modules/libjar/nsJARChannel.cpp index 67bd2852f98631..9cf0a26786b032 100644 --- a/modules/libjar/nsJARChannel.cpp +++ b/modules/libjar/nsJARChannel.cpp @@ -1068,13 +1068,6 @@ static void RecordZeroLengthEvent(bool aIsSync, const nsCString& aSpec, return; } - // See bug 1695560. "update.locale" with - // NS_ERROR_FILE_NOT_FOUND is filtered out. - if (fileName.EqualsLiteral("omni.ja!/update.locale") && - aStatus == NS_ERROR_FILE_NOT_FOUND) { - return; - } - glean::zero_byte_load::LoadOthersExtra extra = { .cancelReason = Some(aCanceledReason), .cancelled = Some(aCanceled), diff --git a/pyproject.toml b/pyproject.toml index d922177f79be00..3f4ce79fb0c954 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,7 +66,6 @@ exclude = [ "toolkit/components/featuregates", "toolkit/content/tests/chrome/file_about_networking_wsh.py", "toolkit/library/build/dependentlibs.py", - "toolkit/locales/generate_update_locale.py", "toolkit/mozapps", "toolkit/moz.configure", "toolkit/nss.configure", diff --git a/python/mozbuild/mozbuild/action/test_archive.py b/python/mozbuild/mozbuild/action/test_archive.py index d64febcc1fbc07..08e596f85ed59d 100644 --- a/python/mozbuild/mozbuild/action/test_archive.py +++ b/python/mozbuild/mozbuild/action/test_archive.py @@ -471,7 +471,7 @@ "*.toml", "localization/**", "modules/**", - "update.locale", + "default.locale", "greprefs.js", ], "dest": "bin", diff --git a/python/mozbuild/mozpack/packager/formats.py b/python/mozbuild/mozpack/packager/formats.py index 95a6dee2f69916..49aa9eff8884b2 100644 --- a/python/mozbuild/mozpack/packager/formats.py +++ b/python/mozbuild/mozpack/packager/formats.py @@ -349,6 +349,6 @@ def is_resource(self, path): "dictionaries", "hyphenation", "localization", - "update.locale", + "default.locale", "contentaccessible", ] diff --git a/python/mozbuild/mozpack/test/test_packager_formats.py b/python/mozbuild/mozpack/test/test_packager_formats.py index b09971a1028e35..a0d7826acd4194 100644 --- a/python/mozbuild/mozpack/test/test_packager_formats.py +++ b/python/mozbuild/mozpack/test/test_packager_formats.py @@ -431,7 +431,7 @@ def is_resource(base, path): self.assertTrue(is_resource(base, "modules/foo.jsm")) self.assertTrue(is_resource(base, "greprefs.js")) self.assertTrue(is_resource(base, "hyphenation/foo")) - self.assertTrue(is_resource(base, "update.locale")) + self.assertTrue(is_resource(base, "default.locale")) self.assertFalse(is_resource(base, "foo")) self.assertFalse(is_resource(base, "foo/bar/greprefs.js")) self.assertTrue(is_resource(base, "defaults/messenger/foo.dat")) diff --git a/toolkit/locales/generate_update_locale.py b/toolkit/locales/generate_default_locale.py similarity index 65% rename from toolkit/locales/generate_update_locale.py rename to toolkit/locales/generate_default_locale.py index 30d492a27297d3..dc01af0bf1979c 100644 --- a/toolkit/locales/generate_update_locale.py +++ b/toolkit/locales/generate_default_locale.py @@ -2,10 +2,10 @@ # 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/. -# Generate update.locale, which simply contains the name of the current locale. +# Generate default.locale, which simply contains the name of the current locale. def main(output, locale=None): assert locale is not None - # update.locale is a trivial file but let's be unicode aware anyway. + # default.locale is a trivial file but let's be unicode aware anyway. print(locale, file=output) diff --git a/toolkit/locales/moz.build b/toolkit/locales/moz.build index 7a9cc3b2e50bb4..21eaa4f4a190fe 100644 --- a/toolkit/locales/moz.build +++ b/toolkit/locales/moz.build @@ -20,10 +20,10 @@ FINAL_TARGET_FILES.res += [ "!multilocale.txt", ] -LOCALIZED_GENERATED_FILES += ["update.locale"] -update_locale = LOCALIZED_GENERATED_FILES["update.locale"] -update_locale.script = "generate_update_locale.py" -LOCALIZED_FILES += ["!update.locale"] +LOCALIZED_GENERATED_FILES += ["default.locale"] +default_locale = LOCALIZED_GENERATED_FILES["default.locale"] +default_locale.script = "generate_default_locale.py" +LOCALIZED_FILES += ["!default.locale"] LOCALIZED_GENERATED_FILES += ["locale.ini"] LOCALIZED_GENERATED_FILES["locale.ini"].script = "generate_locale_ini.py" diff --git a/toolkit/modules/UpdateUtils.sys.mjs b/toolkit/modules/UpdateUtils.sys.mjs index 0268c11a9a46e7..2c8a093013d406 100644 --- a/toolkit/modules/UpdateUtils.sys.mjs +++ b/toolkit/modules/UpdateUtils.sys.mjs @@ -19,7 +19,7 @@ const PER_INSTALLATION_PREFS_PLATFORMS = ["win"]; // located in the update directory which makes it a common setting across all // application profiles and allows the Background Update Agent to read it. const FILE_UPDATE_CONFIG_JSON = "update-config.json"; -const FILE_UPDATE_LOCALE = "update.locale"; +const FILE_DEFAULT_LOCALE = "default.locale"; const PREF_APP_DISTRIBUTION = "distribution.id"; const PREF_APP_DISTRIBUTION_VERSION = "distribution.version"; @@ -116,8 +116,8 @@ export var UpdateUtils = { }, /** - * Gets the locale from the update.locale file for replacing %LOCALE% in the - * update url. The update.locale file can be located in the application + * Gets the locale from the default.locale file for replacing %LOCALE% in the + * update url. The default.locale file can be located in the application * directory or the GRE directory with preference given to it being located in * the application directory. */ @@ -127,7 +127,7 @@ export var UpdateUtils = { } for (let res of ["app", "gre"]) { - const url = "resource://" + res + "/" + FILE_UPDATE_LOCALE; + const url = `resource://${res}/${FILE_DEFAULT_LOCALE}`; let data; try { data = await fetch(url); @@ -139,12 +139,10 @@ export var UpdateUtils = { return (this._locale = locale.trim()); } } - if (AppConstants.MOZ_UPDATER) { - console.error( - FILE_UPDATE_LOCALE, - " file doesn't exist in either the application or GRE directories" - ); - } + console.error( + FILE_DEFAULT_LOCALE, + " file doesn't exist in either the application or GRE directories" + ); return (this._locale = null); }, diff --git a/toolkit/modules/tests/xpcshell/test_UpdateUtils_url.js b/toolkit/modules/tests/xpcshell/test_UpdateUtils_url.js index b8618291f8b586..b63d05e2fb23bc 100644 --- a/toolkit/modules/tests/xpcshell/test_UpdateUtils_url.js +++ b/toolkit/modules/tests/xpcshell/test_UpdateUtils_url.js @@ -271,6 +271,7 @@ add_task(async function test_build_target() { // url constructed with %LOCALE% // Bug 488936 added the update.locale file that stores the update locale +// Bug 1936528 renamed it as default.locale add_task(async function test_locale() { // The code that gets the locale accesses the profile which is only available // after calling do_get_profile in xpcshell tests. This prevents an error from diff --git a/toolkit/mozapps/installer/l10n-repack.py b/toolkit/mozapps/installer/l10n-repack.py index a6f7ebb4ddf022..e9dc0fe6c9078a 100644 --- a/toolkit/mozapps/installer/l10n-repack.py +++ b/toolkit/mozapps/installer/l10n-repack.py @@ -21,7 +21,7 @@ "defaults/profile", "defaults/pref*/*-l10n.js", "locale.ini", - "update.locale", + "default.locale", "updater.ini", "extensions/langpack-*@*", "distribution/extensions/langpack-*@*",