Add localization support to launcher
Adds localization across the launcher and includes English, German, Spanish, French, Italian, Japanese, Korean, Dutch, Portuguese, Ukranian, and Chinese. These localizations were generated by Claude 3.5 and need to be reviewed by a human for accuracy.
2025-08-18 21:29:38 -05:00
|
|
|
using System.Globalization;
|
|
|
|
|
using System.Resources;
|
|
|
|
|
using LANCommander.Launcher.Models;
|
2025-09-29 19:49:09 -05:00
|
|
|
using Microsoft.Extensions.Options;
|
Add localization support to launcher
Adds localization across the launcher and includes English, German, Spanish, French, Italian, Japanese, Korean, Dutch, Portuguese, Ukranian, and Chinese. These localizations were generated by Claude 3.5 and need to be reviewed by a human for accuracy.
2025-08-18 21:29:38 -05:00
|
|
|
|
|
|
|
|
namespace LANCommander.Launcher.Services
|
|
|
|
|
{
|
|
|
|
|
public class LocalizationService
|
|
|
|
|
{
|
|
|
|
|
private readonly ResourceManager _resourceManager;
|
|
|
|
|
|
2025-11-23 20:53:45 -06:00
|
|
|
public LocalizationService(IOptions<Settings.Settings> settings)
|
2025-10-06 19:25:24 -05:00
|
|
|
{
|
Add localization support to launcher
Adds localization across the launcher and includes English, German, Spanish, French, Italian, Japanese, Korean, Dutch, Portuguese, Ukranian, and Chinese. These localizations were generated by Claude 3.5 and need to be reviewed by a human for accuracy.
2025-08-18 21:29:38 -05:00
|
|
|
_resourceManager = new ResourceManager("LANCommander.Launcher.Resources.SharedResources", typeof(LocalizationService).Assembly);
|
|
|
|
|
|
2025-09-29 19:49:09 -05:00
|
|
|
var cultureInfo = new CultureInfo(settings.Value.Culture);
|
Add localization support to launcher
Adds localization across the launcher and includes English, German, Spanish, French, Italian, Japanese, Korean, Dutch, Portuguese, Ukranian, and Chinese. These localizations were generated by Claude 3.5 and need to be reviewed by a human for accuracy.
2025-08-18 21:29:38 -05:00
|
|
|
|
2025-09-29 19:49:09 -05:00
|
|
|
Thread.CurrentThread.CurrentCulture = cultureInfo;
|
|
|
|
|
Thread.CurrentThread.CurrentUICulture = cultureInfo;
|
Add localization support to launcher
Adds localization across the launcher and includes English, German, Spanish, French, Italian, Japanese, Korean, Dutch, Portuguese, Ukranian, and Chinese. These localizations were generated by Claude 3.5 and need to be reviewed by a human for accuracy.
2025-08-18 21:29:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetString(string key)
|
|
|
|
|
{
|
|
|
|
|
return _resourceManager.GetString(key) ?? key;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetString(string key, params object[] args)
|
|
|
|
|
{
|
|
|
|
|
var format = _resourceManager.GetString(key) ?? key;
|
|
|
|
|
return string.Format(CultureInfo.CurrentCulture, format, args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetString(string key, CultureInfo culture)
|
|
|
|
|
{
|
|
|
|
|
return _resourceManager.GetString(key, culture) ?? key;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetString(string key, CultureInfo culture, params object[] args)
|
|
|
|
|
{
|
|
|
|
|
var format = _resourceManager.GetString(key, culture) ?? key;
|
|
|
|
|
return string.Format(culture, format, args);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|