mirror of
https://github.com/JuniorDark/RustyHearts-Launcher.git
synced 2026-05-07 05:21:44 -04:00
Extended the localization system to easily include additional languages in the future
This commit is contained in:
parent
d5ec712d0f
commit
ae34584021
50 changed files with 45079 additions and 24129 deletions
44
RHLauncher/LocalizationHelper.cs
Normal file
44
RHLauncher/LocalizationHelper.cs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
using System.Globalization;
|
||||
using System.Resources;
|
||||
|
||||
namespace RHLauncher.RHLauncher
|
||||
{
|
||||
public class LocalizationHelper
|
||||
{
|
||||
public static void LoadLocalizedStrings(
|
||||
string lang,
|
||||
List<Button> buttons,
|
||||
List<ImageList> imageLists,
|
||||
Dictionary<string, List<ImageList>> languageImageLists)
|
||||
{
|
||||
CultureInfo cultureInfo;
|
||||
if (languageImageLists.ContainsKey(lang))
|
||||
{
|
||||
// If the language is supported, get the corresponding image lists
|
||||
List<ImageList> langSpecificImageLists = languageImageLists[lang];
|
||||
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