From 106f90dc015de906b4c83da76603e4f57ba00da4 Mon Sep 17 00:00:00 2001
From: Laszlo Nemeth <57342539+donlaci@users.noreply.github.com>
Date: Mon, 20 Nov 2023 19:40:54 +0100
Subject: [PATCH] [Awake]Add localization (#29751)
* [Awake] First steps for localization.
* Localizing all strings.
* Fix Spell Checker
* Spell checker
* Minor fixes, adding comments to resource strings.
* Cleaning up project file.
* adding resource comments
---
src/modules/awake/Awake/Awake.csproj | 13 +-
src/modules/awake/Awake/Core/Manager.cs | 8 +-
src/modules/awake/Awake/Core/TrayHelper.cs | 16 +-
.../Awake/Properties/Resources.Designer.cs | 171 ++++++++++++++++++
.../awake/Awake/Properties/Resources.resx | 162 +++++++++++++++++
.../SettingsXAML/Views/AwakePage.xaml | 2 +-
.../Settings.UI/Strings/en-us/Resources.resw | 4 +
7 files changed, 364 insertions(+), 12 deletions(-)
create mode 100644 src/modules/awake/Awake/Properties/Resources.Designer.cs
create mode 100644 src/modules/awake/Awake/Properties/Resources.resx
diff --git a/src/modules/awake/Awake/Awake.csproj b/src/modules/awake/Awake/Awake.csproj
index f31c22e62f..58576db33c 100644
--- a/src/modules/awake/Awake/Awake.csproj
+++ b/src/modules/awake/Awake/Awake.csproj
@@ -79,6 +79,11 @@
Never
+
+ True
+ True
+ Resources.resx
+
@@ -87,11 +92,17 @@
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
diff --git a/src/modules/awake/Awake/Core/Manager.cs b/src/modules/awake/Awake/Core/Manager.cs
index d46843226a..6016a4551e 100644
--- a/src/modules/awake/Awake/Core/Manager.cs
+++ b/src/modules/awake/Awake/Core/Manager.cs
@@ -6,12 +6,14 @@ using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
+using System.Globalization;
using System.IO;
using System.Reactive.Linq;
using System.Text;
using System.Threading;
using Awake.Core.Models;
using Awake.Core.Native;
+using Awake.Properties;
using ManagedCommon;
using Microsoft.PowerToys.Telemetry;
using Microsoft.Win32;
@@ -274,9 +276,9 @@ namespace Awake.Core
{
Dictionary optionsList = new Dictionary
{
- { "30 minutes", 1800 },
- { "1 hour", 3600 },
- { "2 hours", 7200 },
+ { string.Format(CultureInfo.InvariantCulture, Resources.AWAKE_MINUTES, 30), 1800 },
+ { Resources.AWAKE_1_HOUR, 3600 },
+ { string.Format(CultureInfo.InvariantCulture, Resources.AWAKE_HOURS, 2), 7200 },
};
return optionsList;
}
diff --git a/src/modules/awake/Awake/Core/TrayHelper.cs b/src/modules/awake/Awake/Core/TrayHelper.cs
index 110d623d75..ef6794ecfb 100644
--- a/src/modules/awake/Awake/Core/TrayHelper.cs
+++ b/src/modules/awake/Awake/Core/TrayHelper.cs
@@ -6,11 +6,13 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
+using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Awake.Core.Models;
using Awake.Core.Native;
+using Awake.Properties;
using ManagedCommon;
using Microsoft.PowerToys.Settings.UI.Library;
@@ -115,11 +117,11 @@ namespace Awake.Core
if (!startedFromPowerToys)
{
// If Awake is started from PowerToys, the correct way to exit it is disabling it from Settings.
- Bridge.InsertMenu(TrayMenu, 0, Native.Constants.MF_BYPOSITION | Native.Constants.MF_STRING, (uint)TrayCommands.TC_EXIT, "Exit");
+ Bridge.InsertMenu(TrayMenu, 0, Native.Constants.MF_BYPOSITION | Native.Constants.MF_STRING, (uint)TrayCommands.TC_EXIT, Resources.AWAKE_EXIT);
Bridge.InsertMenu(TrayMenu, 0, Native.Constants.MF_BYPOSITION | Native.Constants.MF_SEPARATOR, 0, string.Empty);
}
- Bridge.InsertMenu(TrayMenu, 0, Native.Constants.MF_BYPOSITION | Native.Constants.MF_STRING | (keepDisplayOn ? Native.Constants.MF_CHECKED : Native.Constants.MF_UNCHECKED) | (mode == AwakeMode.PASSIVE ? Native.Constants.MF_DISABLED : Native.Constants.MF_ENABLED), (uint)TrayCommands.TC_DISPLAY_SETTING, "Keep screen on");
+ Bridge.InsertMenu(TrayMenu, 0, Native.Constants.MF_BYPOSITION | Native.Constants.MF_STRING | (keepDisplayOn ? Native.Constants.MF_CHECKED : Native.Constants.MF_UNCHECKED) | (mode == AwakeMode.PASSIVE ? Native.Constants.MF_DISABLED : Native.Constants.MF_ENABLED), (uint)TrayCommands.TC_DISPLAY_SETTING, Resources.AWAKE_KEEP_SCREEN_ON);
}
// In case there are no tray shortcuts defined for the application default to a
@@ -137,10 +139,10 @@ namespace Awake.Core
Bridge.InsertMenu(TrayMenu, 0, Native.Constants.MF_BYPOSITION | Native.Constants.MF_SEPARATOR, 0, string.Empty);
- Bridge.InsertMenu(TrayMenu, 0, Native.Constants.MF_BYPOSITION | Native.Constants.MF_STRING | (mode == AwakeMode.PASSIVE ? Native.Constants.MF_CHECKED : Native.Constants.MF_UNCHECKED), (uint)TrayCommands.TC_MODE_PASSIVE, "Off (keep using the selected power plan)");
- Bridge.InsertMenu(TrayMenu, 0, Native.Constants.MF_BYPOSITION | Native.Constants.MF_STRING | (mode == AwakeMode.INDEFINITE ? Native.Constants.MF_CHECKED : Native.Constants.MF_UNCHECKED), (uint)TrayCommands.TC_MODE_INDEFINITE, "Keep awake indefinitely");
- Bridge.InsertMenu(TrayMenu, 0, Native.Constants.MF_BYPOSITION | Native.Constants.MF_POPUP | (mode == AwakeMode.TIMED ? Native.Constants.MF_CHECKED : Native.Constants.MF_UNCHECKED), (uint)awakeTimeMenu, "Keep awake on interval");
- Bridge.InsertMenu(TrayMenu, 0, Native.Constants.MF_BYPOSITION | Native.Constants.MF_STRING | Native.Constants.MF_DISABLED | (mode == AwakeMode.EXPIRABLE ? Native.Constants.MF_CHECKED : Native.Constants.MF_UNCHECKED), (uint)TrayCommands.TC_MODE_EXPIRABLE, "Keep awake until expiration date and time");
+ Bridge.InsertMenu(TrayMenu, 0, Native.Constants.MF_BYPOSITION | Native.Constants.MF_STRING | (mode == AwakeMode.PASSIVE ? Native.Constants.MF_CHECKED : Native.Constants.MF_UNCHECKED), (uint)TrayCommands.TC_MODE_PASSIVE, Resources.AWAKE_OFF);
+ Bridge.InsertMenu(TrayMenu, 0, Native.Constants.MF_BYPOSITION | Native.Constants.MF_STRING | (mode == AwakeMode.INDEFINITE ? Native.Constants.MF_CHECKED : Native.Constants.MF_UNCHECKED), (uint)TrayCommands.TC_MODE_INDEFINITE, Resources.AWAKE_KEEP_INDEFINITELY);
+ Bridge.InsertMenu(TrayMenu, 0, Native.Constants.MF_BYPOSITION | Native.Constants.MF_POPUP | (mode == AwakeMode.TIMED ? Native.Constants.MF_CHECKED : Native.Constants.MF_UNCHECKED), (uint)awakeTimeMenu, Resources.AWAKE_KEEP_ON_INTERVAL);
+ Bridge.InsertMenu(TrayMenu, 0, Native.Constants.MF_BYPOSITION | Native.Constants.MF_STRING | Native.Constants.MF_DISABLED | (mode == AwakeMode.EXPIRABLE ? Native.Constants.MF_CHECKED : Native.Constants.MF_UNCHECKED), (uint)TrayCommands.TC_MODE_EXPIRABLE, Resources.AWAKE_KEEP_UNTIL_EXPIRATION);
TrayIcon.Text = text;
}
@@ -157,7 +159,7 @@ namespace Awake.Core
public override AccessibleRole Role => AccessibleRole.CheckButton;
- public override string Name => _menuItem.Text + ", " + Role + ", " + (_menuItem.Checked ? "Checked" : "Unchecked");
+ public override string Name => _menuItem.Text + ", " + Role + ", " + (_menuItem.Checked ? Resources.AWAKE_CHECKED : Resources.AWAKE_UNCHECKED);
}
private sealed class CheckButtonToolStripMenuItem : ToolStripMenuItem
diff --git a/src/modules/awake/Awake/Properties/Resources.Designer.cs b/src/modules/awake/Awake/Properties/Resources.Designer.cs
new file mode 100644
index 0000000000..dab74f79fa
--- /dev/null
+++ b/src/modules/awake/Awake/Properties/Resources.Designer.cs
@@ -0,0 +1,171 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace Awake.Properties {
+ using System;
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Awake.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to 1 hour.
+ ///
+ internal static string AWAKE_1_HOUR {
+ get {
+ return ResourceManager.GetString("AWAKE_1_HOUR", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to 1 minute.
+ ///
+ internal static string AWAKE_1_MINUTE {
+ get {
+ return ResourceManager.GetString("AWAKE_1_MINUTE", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Checked.
+ ///
+ internal static string AWAKE_CHECKED {
+ get {
+ return ResourceManager.GetString("AWAKE_CHECKED", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Exit.
+ ///
+ internal static string AWAKE_EXIT {
+ get {
+ return ResourceManager.GetString("AWAKE_EXIT", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to {0} hours.
+ ///
+ internal static string AWAKE_HOURS {
+ get {
+ return ResourceManager.GetString("AWAKE_HOURS", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Keep awake indefinitely.
+ ///
+ internal static string AWAKE_KEEP_INDEFINITELY {
+ get {
+ return ResourceManager.GetString("AWAKE_KEEP_INDEFINITELY", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Keep awake on interval.
+ ///
+ internal static string AWAKE_KEEP_ON_INTERVAL {
+ get {
+ return ResourceManager.GetString("AWAKE_KEEP_ON_INTERVAL", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Keep screen on.
+ ///
+ internal static string AWAKE_KEEP_SCREEN_ON {
+ get {
+ return ResourceManager.GetString("AWAKE_KEEP_SCREEN_ON", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Keep awake until expiration date and time.
+ ///
+ internal static string AWAKE_KEEP_UNTIL_EXPIRATION {
+ get {
+ return ResourceManager.GetString("AWAKE_KEEP_UNTIL_EXPIRATION", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to {0} minutes.
+ ///
+ internal static string AWAKE_MINUTES {
+ get {
+ return ResourceManager.GetString("AWAKE_MINUTES", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Off (keep using the selected power plan).
+ ///
+ internal static string AWAKE_OFF {
+ get {
+ return ResourceManager.GetString("AWAKE_OFF", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Unchecked.
+ ///
+ internal static string AWAKE_UNCHECKED {
+ get {
+ return ResourceManager.GetString("AWAKE_UNCHECKED", resourceCulture);
+ }
+ }
+ }
+}
diff --git a/src/modules/awake/Awake/Properties/Resources.resx b/src/modules/awake/Awake/Properties/Resources.resx
new file mode 100644
index 0000000000..7ce0a1652d
--- /dev/null
+++ b/src/modules/awake/Awake/Properties/Resources.resx
@@ -0,0 +1,162 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ Checked
+
+
+ Exit
+
+
+ 1 hour
+
+
+ {0} hours
+ {0} shouldn't be removed. It will be replaced by a number greater than 1 at runtime by the application. Used for defining a period to keep the PC awake.
+
+
+ Keep awake indefinitely
+ Keep the system awake forever
+
+
+ Keep awake on interval
+ Keep the system awake for a given time
+
+
+ Keep screen on
+
+
+ Keep awake until expiration date and time
+ Keep the system awake until expiration date and time
+
+
+ 1 minute
+
+
+ {0} minutes
+ {0} shouldn't be removed. It will be replaced by a number greater than 1 at runtime by the application. Used for defining a period to keep the PC awake.
+
+
+ Off (keep using the selected power plan)
+ Don't keep the system awake, use the selected system power plan
+
+
+ Unchecked
+
+
\ No newline at end of file
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/AwakePage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/AwakePage.xaml
index b5ab0ed3b8..b514fb1807 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/Views/AwakePage.xaml
+++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/AwakePage.xaml
@@ -105,7 +105,7 @@
-
+
diff --git a/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw b/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw
index db02b00553..edd59e13e7 100644
--- a/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw
+++ b/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw
@@ -2355,6 +2355,10 @@ From there, simply click on one of the supported files in the File Explorer and
Learn more about Awake
Awake is a product name, do not loc
+
+ Den Delimarsky's work on creating Awake
+ Awake is a product name, do not loc
+
Learn more about Color Picker
Color Picker is a product name, do not loc