mirror of
https://github.com/JuniorDark/RustyHearts-Launcher.git
synced 2026-05-07 05:21:44 -04:00
Version 1.2.0
This commit is contained in:
parent
9b3a0e00a2
commit
e74d93fab9
83 changed files with 110087 additions and 47507 deletions
44
RHLauncher.i8n/LocalizationHelper.cs
Normal file
44
RHLauncher.i8n/LocalizationHelper.cs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
using System.Globalization;
|
||||
using System.Resources;
|
||||
|
||||
namespace RHLauncher.RHLauncher.i8n
|
||||
{
|
||||
public class LocalizationHelper
|
||||
{
|
||||
public static void LoadLocalizedStrings(
|
||||
string lang,
|
||||
List<Button> buttons,
|
||||
List<ImageList> imageLists,
|
||||
Dictionary<string, List<ImageList>> languageImageLists)
|
||||
{
|
||||
CultureInfo cultureInfo;
|
||||
if (languageImageLists.TryGetValue(lang, out List<ImageList>? value))
|
||||
{
|
||||
// If the language is supported, get the corresponding image lists
|
||||
List<ImageList> langSpecificImageLists = value;
|
||||
for (int i = 0; i < buttons.Count && i < langSpecificImageLists.Count; i++)
|
||||
{
|
||||
buttons[i].ImageList = langSpecificImageLists[i];
|
||||
}
|
||||
|
||||
cultureInfo = new CultureInfo(lang);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Default to English if the language is not supported
|
||||
cultureInfo = new CultureInfo("en-US"); // English culture
|
||||
for (int i = 0; i < buttons.Count && i < imageLists.Count; i++)
|
||||
{
|
||||
buttons[i].ImageList = imageLists[i];
|
||||
}
|
||||
}
|
||||
|
||||
Thread.CurrentThread.CurrentUICulture = cultureInfo;
|
||||
|
||||
// Load the appropriate resource file based on the selected language
|
||||
_ = new
|
||||
ResourceManager(typeof(LocalizedStrings));
|
||||
LocalizedStrings.Culture = cultureInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue