-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
68 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,41 @@ | ||
using System.Threading; | ||
using System; | ||
using System.Globalization; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
using System.Windows.Forms; | ||
|
||
namespace sethc | ||
{ | ||
public class Localization | ||
{ | ||
public static void SetLanguage(Main mainForm) | ||
{ | ||
// English (Default language) | ||
string sktitle = "Sticky Keys"; | ||
string turnsktext = "Do you want to turn on Sticky Keys?"; | ||
string skcontenttext = "Sticky Keys lets you use the SHIFT, CTRL, ALT, or Windows Logo keys by pressing one key at a time. The keyboard shortcut to turn on Sticky Keys is to press the SHIFT key 5 times."; | ||
string deactivatesktext = "Go to the Ease of Access Center to disable the keyboard shortcut"; | ||
string skyes = "&Yes"; | ||
string skno = "&No"; | ||
public class Localization | ||
{ | ||
[DllImport("kernel32.dll")] | ||
private static extern IntPtr LoadLibraryA(string lpLibFileName); | ||
[DllImport("user32.dll")] | ||
private static extern int LoadStringA(IntPtr hInstance, uint uID, StringBuilder lpBuffer, int nBufferMax); | ||
|
||
switch (Thread.CurrentThread.CurrentCulture.Name) | ||
{ | ||
case "it-IT": // Italian | ||
sktitle = "Tasti permanenti"; | ||
turnsktext = "Attivare Tasti permanenti?"; | ||
skcontenttext = "Tasti permanenti consente di utilizzare combinazioni di tasti con MAIUSC, CTRL, ALT o il tasto logo Windows premendo un tasto alla volta. Per attivare Tasti permanenti, premere MAIUSC cinque volte."; | ||
deactivatesktext = "Disabilita questa scelta rapida da tastiera nelle impostazioni della tastiera di Accesso Rapido"; | ||
skyes = "&Sì"; | ||
// Italian "No" and English "No" are the same. | ||
break; | ||
case "zh-CN": // Chinese PRC | ||
sktitle = "粘滞键"; | ||
turnsktext = "你想启用粘滞键吗?"; | ||
skcontenttext = "通过一次按一个键,粘滞键允许使用 Shift、Ctrl、Alt 或 Windows徽标键。启用粘滞键的键盘快捷方式是按 5 次 Shift 键。"; | ||
deactivatesktext = "在“轻松使用”键盘设置中禁用此键盘快捷方式"; | ||
skyes = "&是(Y)"; | ||
skno = "&否(N)"; | ||
break; | ||
} | ||
public static string getMUIstring(IntPtr resContainer, uint msgId) | ||
{ | ||
StringBuilder pBuffer = new StringBuilder(512); | ||
if (LoadStringA(resContainer, msgId, pBuffer, 512) == 0) { | ||
MessageBox.Show($"Cannot find resource {msgId}.", AppDomain.CurrentDomain.FriendlyName + " - Error interpreting mui file", MessageBoxButtons.OK, MessageBoxIcon.Error); | ||
} | ||
return pBuffer.ToString(); | ||
} | ||
|
||
mainForm.Text = sktitle; | ||
mainForm.labelturnsk.Text = turnsktext; | ||
mainForm.labelskcontent.Text = skcontenttext; | ||
mainForm.labeldeactivatedialog.Text = deactivatesktext; | ||
mainForm.buttonYes.Text = skyes; | ||
mainForm.buttonNo.Text = skno; | ||
mainForm.Refresh(); | ||
} | ||
} | ||
public static void SetLanguage(Main mainForm, int windowMode) | ||
{ | ||
IntPtr resContainer = LoadLibraryA($"{Environment.GetFolderPath(Environment.SpecialFolder.Windows)}\\System32\\{CultureInfo.InstalledUICulture.Name}\\EaseOfAccessDialog.exe.mui"); | ||
if (resContainer == null) { | ||
MessageBox.Show("Cannot read mui file.", AppDomain.CurrentDomain.FriendlyName + " - Error loading mui file", MessageBoxButtons.OK, MessageBoxIcon.Error); | ||
} | ||
|
||
mainForm.Text = getMUIstring(resContainer, 512); | ||
mainForm.labelturnsk.Text = getMUIstring(resContainer, 1138); | ||
mainForm.labelskcontent.Text = getMUIstring(resContainer, 1117); | ||
mainForm.labeldeactivatedialog.Text = getMUIstring(resContainer, 1143); | ||
mainForm.buttonYes.Text = getMUIstring(resContainer, 1135); | ||
mainForm.buttonNo.Text = getMUIstring(resContainer, 1134); | ||
mainForm.Refresh(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters