[tbb-commits] [torbutton] branch main updated: Bug 41451: Use app locale rather than requested locale
gitolite role
git at cupani.torproject.org
Mon Nov 14 18:43:06 UTC 2022
This is an automated email from the git hooks/post-receive script.
pierov pushed a commit to branch main
in repository torbutton.
The following commit(s) were added to refs/heads/main by this push:
new f5cbb382 Bug 41451: Use app locale rather than requested locale
f5cbb382 is described below
commit f5cbb38236e1dd0c1debc8c625833c2b08fd2b9d
Author: Henry Wilkes <henry at torproject.org>
AuthorDate: Mon Nov 14 18:38:53 2022 +0000
Bug 41451: Use app locale rather than requested locale
---
chrome/content/aboutTor/aboutTor-content.js | 11 ++++-------
modules/utils.js | 9 +++++++--
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/chrome/content/aboutTor/aboutTor-content.js b/chrome/content/aboutTor/aboutTor-content.js
index a35d95b5..6c53dff8 100644
--- a/chrome/content/aboutTor/aboutTor-content.js
+++ b/chrome/content/aboutTor/aboutTor-content.js
@@ -19,7 +19,7 @@
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-const { bindPrefAndInit } = ChromeUtils.import(
+const { bindPrefAndInit, getLocale } = ChromeUtils.import(
"resource://torbutton/modules/utils.js"
);
@@ -65,10 +65,7 @@ var AboutTorListener = {
onPageLoad() {
// Arrange to update localized text and links.
bindPrefAndInit("intl.locale.requested", () => {
- const aNewVal = Services.locale.requestedLocale;
- if (aNewVal !== null) {
- this.onLocaleChange(aNewVal);
- }
+ this.onLocaleChange();
});
// Add message and event listeners.
@@ -116,10 +113,10 @@ var AboutTorListener = {
body.setAttribute("initialized", "yes");
},
- onLocaleChange(aLocale) {
+ onLocaleChange() {
// Set localized "Get Involved" link.
content.document.getElementById("getInvolvedLink").href =
- "https://community.torproject.org/" + aLocale;
+ `https://community.torproject.org/${getLocale()}`;
// Display the Tor Browser product name and version.
try {
diff --git a/modules/utils.js b/modules/utils.js
index 49f7c0dc..30947a73 100644
--- a/modules/utils.js
+++ b/modules/utils.js
@@ -88,9 +88,14 @@ var getEnv = function(name) {
};
// __getLocale
-// Reads the browser locale, the default locale is en-US.
+// Returns the app locale to be used in tor-related urls.
var getLocale = function() {
- return Services.locale.requestedLocale || "en-US";
+ const locale = Services.locale.appLocaleAsBCP47;
+ if (locale === "ja-JP-macos") {
+ // We don't want to distinguish the mac locale.
+ return "ja";
+ }
+ return locale;
};
// ## Windows
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the tbb-commits
mailing list