tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 5af29351cb08c756c24bf6cc4c7f436fc77ed8f8
parent 08a5db0db3aa4a60069d0af5b2f8f787c1368cd3
Author: stransky <stransky@redhat.com>
Date:   Tue, 14 Oct 2025 08:11:30 +0000

Bug 1744641 [Linux] Add wake lock strings localization r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D266646

Diffstat:
Mdom/locales/en-US/chrome/dom/dom.properties | 4++++
Mwidget/gtk/WakeLockListener.cpp | 32++++++++++++++++++++++++++++++--
2 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/dom/locales/en-US/chrome/dom/dom.properties b/dom/locales/en-US/chrome/dom/dom.properties @@ -479,3 +479,7 @@ PreviousInterceptCallOptionOverriddenWarning=The ’%1$S’ option for a previou # LOCALIZATION NOTE: Do not translate "Window.fullScreen". FullscreenAttributeWarning=Window.fullScreen attribute is deprecated and will be removed in the future. + +# LOCALIZATION NOTE: Wake lock related strings for system notifications +WakeLockVideoPlaying=Playing video +WakeLockAudioPlaying=Playing audio diff --git a/widget/gtk/WakeLockListener.cpp b/widget/gtk/WakeLockListener.cpp @@ -10,6 +10,10 @@ #include "WakeLockListener.h" #include "WidgetUtilsGtk.h" #include "mozilla/ScopeExit.h" +#include "mozilla/Services.h" +#include "nsIStringBundle.h" +#include "nsReadableUtils.h" +#include "nsContentUtils.h" #ifdef MOZ_ENABLE_DBUS # include <gio/gio.h> @@ -54,6 +58,16 @@ using namespace mozilla::widget; NS_IMPL_ISUPPORTS(WakeLockListener, nsIDOMMozWakeLockListener) +static nsCString GetLocalizedWakeLockString(const char* aStringName) { + nsAutoString localizedString; + nsresult rv = nsContentUtils::GetLocalizedString( + nsContentUtils::eDOM_PROPERTIES, aStringName, localizedString); + if (NS_FAILED(rv)) { + return nsCString(); + } + return NS_ConvertUTF16toUTF8(localizedString); +} + #define WAKE_LOCK_LOG(str, ...) \ MOZ_LOG(gLinuxWakeLockLog, mozilla::LogLevel::Debug, \ ("[%p] " str, this, ##__VA_ARGS__)) @@ -146,9 +160,23 @@ class WakeLockTopic { CopyUTF16toUTF8(aTopic, mTopic); WAKE_LOCK_LOG("WakeLockTopic::WakeLockTopic() created %s", mTopic.get()); if (mTopic.Equals("video-playing")) { - mNiceTopic = "Playing video"; + nsCString videoPlayingString = []() -> nsCString { + auto string = GetLocalizedWakeLockString("WakeLockVideoPlaying"); + if (string.IsEmpty()) { + string = "Playing video"; + } + return string; + }(); + mNiceTopic = videoPlayingString; } else if (mTopic.Equals("audio-playing")) { - mNiceTopic = "Playing audio"; + nsCString audioPlayingString = []() -> nsCString { + auto string = GetLocalizedWakeLockString("WakeLockAudioPlaying"); + if (string.IsEmpty()) { + string = "Playing audio"; + } + return string; + }(); + mNiceTopic = audioPlayingString; } if (sWakeLockType == Initial) { InitializeWakeLockType();