henry pushed to branch tor-browser-115.22.0esr-13.5-1 at The Tor Project / Applications / Tor Browser
Commits: ac79324b by henry at 2025-04-15T10:00:33+00:00 fixup! TB 7494: Create local home page for TBB.
TB 43647: Use the app locale directly from the parent actor for setting the survey banner's language.
(cherry picked from commit bc19a47cb9a1fe45e7cd9ecbb7b4a25063aa3891)
Co-authored-by: Henry Wilkes henry@torproject.org - - - - -
2 changed files:
- browser/components/abouttor/AboutTorParent.sys.mjs - browser/components/abouttor/content/aboutTor.js
Changes:
===================================== browser/components/abouttor/AboutTorParent.sys.mjs ===================================== @@ -23,6 +23,7 @@ export class AboutTorParent extends JSWindowActorParent { surveyDismissVersionPref, 0 ), + appLocale: Services.locale.appLocaleAsBCP47, }); case "AboutTor:SetSearchOnionize": Services.prefs.setBoolPref(onionizePref, message.data);
===================================== browser/components/abouttor/content/aboutTor.js ===================================== @@ -342,8 +342,9 @@ const SurveyArea = { * user has already dismissed. * @param {boolean} isStable - Whether this is the stable release of Tor * Browser. + * @param {string} appLocale - The app locale currently in use. */ - potentiallyShow(dismissVersion, isStable) { + potentiallyShow(dismissVersion, isStable, appLocale) { const now = Date.now(); if ( now < this._startDate || @@ -356,14 +357,13 @@ const SurveyArea = { return; }
- // Determine the survey locale based on the about:tor locale. + // Determine the survey locale based on the app locale. // NOTE: We do not user document.l10n to translate the survey banner. // Instead we only translate the banner into a limited set of locales that // match the languages that the survey itself supports. This should match // the language of the survey when it is opened by the user. - const pageLocale = document.documentElement.getAttribute("lang"); for (const localeData of this._localeDataSet) { - if (localeData.browserLocales.includes(pageLocale)) { + if (localeData.browserLocales.includes(appLocale)) { this._localeData = localeData; break; } @@ -403,8 +403,9 @@ window.addEventListener("InitialData", event => { searchOnionize, messageData, surveyDismissVersion, + appLocale, } = event.detail; SearchWidget.setOnionizeState(!!searchOnionize); MessageArea.setMessageData(messageData, !!isStable, !!torConnectEnabled); - SurveyArea.potentiallyShow(surveyDismissVersion, isStable); + SurveyArea.potentiallyShow(surveyDismissVersion, isStable, appLocale); });
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/ac79324b...