|
|
@@ -1,12 +1,13 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Globalization; |
|
|
|
using System.IO; |
|
|
|
using System.Linq; |
|
|
|
using System.Reflection; |
|
|
|
using GamecraftModdingAPI; |
|
|
|
using GamecraftModdingAPI.App; |
|
|
|
using GamecraftModdingAPI.Commands; |
|
|
|
using GamecraftModdingAPI.Utility; |
|
|
|
using TechbloxModdingAPI; |
|
|
|
using TechbloxModdingAPI.App; |
|
|
|
using TechbloxModdingAPI.Commands; |
|
|
|
using TechbloxModdingAPI.Utility; |
|
|
|
using HarmonyLib; |
|
|
|
using IllusionPlugin; |
|
|
|
using Newtonsoft.Json; |
|
|
@@ -84,7 +85,7 @@ namespace Localization |
|
|
|
} |
|
|
|
|
|
|
|
if ((bool) settings["autoload"]) |
|
|
|
Client.EnterMenu += TryLoadSteamLanguageMenuEnterEvent; |
|
|
|
Client.EnterMenu += TryLoadSystemLanguageMenuEnterEvent; |
|
|
|
} |
|
|
|
|
|
|
|
public override void OnApplicationQuit() |
|
|
@@ -151,38 +152,38 @@ namespace Localization |
|
|
|
.GetValue(null); |
|
|
|
} |
|
|
|
|
|
|
|
private void TryLoadSteamLanguageMenuEnterEvent(object sender, MenuEventArgs args) |
|
|
|
private void TryLoadSystemLanguageMenuEnterEvent(object sender, MenuEventArgs args) |
|
|
|
{ |
|
|
|
TryLoadSteamLanguage(); |
|
|
|
Client.EnterMenu -= TryLoadSteamLanguageMenuEnterEvent; |
|
|
|
TryLoadSystemLanguage(); |
|
|
|
Client.EnterMenu -= TryLoadSystemLanguageMenuEnterEvent; |
|
|
|
} |
|
|
|
|
|
|
|
private void TryLoadSteamLanguage() |
|
|
|
private void TryLoadSystemLanguage() |
|
|
|
{ |
|
|
|
string lang = Steamworks.SteamUtils.SteamUILanguage; |
|
|
|
string lang = CultureInfo.InstalledUICulture.EnglishName.Split(' ')[0].ToLower(); |
|
|
|
string first2 = lang.Substring(0, 2); |
|
|
|
// try some possibly valid language codes |
|
|
|
if (File.Exists(Path.Combine(_pluginFolder.FullName, lang + ".json"))) |
|
|
|
{ |
|
|
|
Logging.MetaLog($"Automatically detected Steam UI language {lang}, loading translations..."); |
|
|
|
Logging.MetaLog($"Automatically detected system UI language {lang}, loading translations..."); |
|
|
|
LoadTranslation(lang); |
|
|
|
} |
|
|
|
else if (File.Exists(Path.Combine(_pluginFolder.FullName, first2 + ".json"))) |
|
|
|
{ |
|
|
|
lang = first2; |
|
|
|
Logging.MetaLog($"Automatically detected Steam UI language {lang}, loading translations..."); |
|
|
|
Logging.MetaLog($"Automatically detected system UI language {lang}, loading translations..."); |
|
|
|
LoadTranslation(lang); |
|
|
|
} |
|
|
|
else if (File.Exists(Path.Combine(_pluginFolder.FullName, first2 + "-" + first2 + ".json"))) |
|
|
|
{ |
|
|
|
// a lot of standard languages codes are like fr-fr (French from France), but this won't work for English (nor fr-CA French from Canada) |
|
|
|
lang = first2 + "-" + first2; |
|
|
|
Logging.MetaLog($"Automatically detected Steam UI language {lang}, loading translations..."); |
|
|
|
Logging.MetaLog($"Automatically detected system UI language {lang}, loading translations..."); |
|
|
|
LoadTranslation(lang); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
Logging.MetaLog($"Translations for Steam UI language {lang} are not available, skipping..."); |
|
|
|
Logging.MetaLog($"Translations for system UI language {lang} are not available, skipping..."); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|