Update API reference and use system language
Steam isn't used anymore
This commit is contained in:
parent
ae8fd9f7d5
commit
1ef1625b92
2 changed files with 21 additions and 23 deletions
|
@ -36,20 +36,17 @@
|
||||||
<HintPath>..\packages\Lib.Harmony.2.0.2\lib\net48\0Harmony.dll</HintPath>
|
<HintPath>..\packages\Lib.Harmony.2.0.2\lib\net48\0Harmony.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="GamecraftModdingAPI, Version=1.6.0.0, Culture=neutral, PublicKeyToken=null">
|
<Reference Include="TechbloxModdingAPI">
|
||||||
<HintPath>..\..\GamecraftModdingAPI\GamecraftModdingAPI\bin\Debug\net472\GamecraftModdingAPI.dll</HintPath>
|
<HintPath>..\..\GamecraftModdingAPI\TechbloxModdingAPI\bin\Debug\net472\TechbloxModdingAPI.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="IllusionPlugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
|
<Reference Include="IllusionPlugin">
|
||||||
<HintPath>..\..\GamecraftModdingAPI\GamecraftModdingAPI\bin\Debug\net472\IllusionPlugin.dll</HintPath>
|
<HintPath>..\..\GamecraftModdingAPI\TechbloxModdingAPI\bin\Debug\net472\IllusionPlugin.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
|
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
|
||||||
<HintPath>..\..\ref\Gamecraft_Data\Managed\Newtonsoft.Json.dll</HintPath>
|
<HintPath>..\..\ref\TechbloxPreview_Data\Managed\Newtonsoft.Json.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="RobocraftX.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
|
<Reference Include="RobocraftX.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||||
<HintPath>..\..\ref\Gamecraft_Data\Managed\RobocraftX.Common.dll</HintPath>
|
<HintPath>..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Common.dll</HintPath>
|
||||||
</Reference>
|
|
||||||
<Reference Include="Facepunch.Steamworks.Win64">
|
|
||||||
<HintPath>..\..\ref\Gamecraft_Data\Managed\Facepunch.Steamworks.Win64.dll</HintPath>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using GamecraftModdingAPI;
|
using TechbloxModdingAPI;
|
||||||
using GamecraftModdingAPI.App;
|
using TechbloxModdingAPI.App;
|
||||||
using GamecraftModdingAPI.Commands;
|
using TechbloxModdingAPI.Commands;
|
||||||
using GamecraftModdingAPI.Utility;
|
using TechbloxModdingAPI.Utility;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using IllusionPlugin;
|
using IllusionPlugin;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
@ -84,7 +85,7 @@ namespace Localization
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((bool) settings["autoload"])
|
if ((bool) settings["autoload"])
|
||||||
Client.EnterMenu += TryLoadSteamLanguageMenuEnterEvent;
|
Client.EnterMenu += TryLoadSystemLanguageMenuEnterEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnApplicationQuit()
|
public override void OnApplicationQuit()
|
||||||
|
@ -151,38 +152,38 @@ namespace Localization
|
||||||
.GetValue(null);
|
.GetValue(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TryLoadSteamLanguageMenuEnterEvent(object sender, MenuEventArgs args)
|
private void TryLoadSystemLanguageMenuEnterEvent(object sender, MenuEventArgs args)
|
||||||
{
|
{
|
||||||
TryLoadSteamLanguage();
|
TryLoadSystemLanguage();
|
||||||
Client.EnterMenu -= TryLoadSteamLanguageMenuEnterEvent;
|
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);
|
string first2 = lang.Substring(0, 2);
|
||||||
// try some possibly valid language codes
|
// try some possibly valid language codes
|
||||||
if (File.Exists(Path.Combine(_pluginFolder.FullName, lang + ".json")))
|
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);
|
LoadTranslation(lang);
|
||||||
}
|
}
|
||||||
else if (File.Exists(Path.Combine(_pluginFolder.FullName, first2 + ".json")))
|
else if (File.Exists(Path.Combine(_pluginFolder.FullName, first2 + ".json")))
|
||||||
{
|
{
|
||||||
lang = first2;
|
lang = first2;
|
||||||
Logging.MetaLog($"Automatically detected Steam UI language {lang}, loading translations...");
|
Logging.MetaLog($"Automatically detected system UI language {lang}, loading translations...");
|
||||||
LoadTranslation(lang);
|
LoadTranslation(lang);
|
||||||
}
|
}
|
||||||
else if (File.Exists(Path.Combine(_pluginFolder.FullName, first2 + "-" + first2 + ".json")))
|
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)
|
// 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;
|
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);
|
LoadTranslation(lang);
|
||||||
}
|
}
|
||||||
else
|
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...");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue