-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #184 from BUTR/dev
v2.1.7
- Loading branch information
Showing
19 changed files
with
806 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/Bannerlord.ButterLib.Implementation/_Module/ModuleData/Languages/EN/language_data.xml_
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LanguageData xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' | ||
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/BUTR/Bannerlord.XmlSchemas/master/ModuleLanguageData.xsd" | ||
|
||
id="English" | ||
name="English" | ||
subtitle_extension="en-GB" | ||
supported_iso="en-GB,en-US,en,eng,en-us,en-gb,en-au,en-bz,en-ca,en-ie,en-jm,en-nz,en-za,en-tt" | ||
under_development="false"> | ||
<LanguageFile xml_path="sta_strings.xml" /> | ||
</LanguageData> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/Bannerlord.ButterLib.Implementation/_Module/ModuleData/Languages/RU/language_data.xml_
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LanguageData xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' | ||
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/BUTR/Bannerlord.XmlSchemas/master/ModuleLanguageData.xsd" | ||
|
||
id="Русский" | ||
name="Русский" | ||
subtitle_extension="ru" | ||
supported_iso="ru,rus,ru-ru,ru-md" | ||
under_development="false"> | ||
<LanguageFile xml_path="sta_strings.xml" /> | ||
</LanguageData> |
3 changes: 2 additions & 1 deletion
3
src/Bannerlord.ButterLib.Implementation/_Module/ModuleData/Languages/RU/sta_strings.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/Bannerlord.ButterLib/Helpers/LocalizedTextManagerUtils.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using Bannerlord.BUTR.Shared.Helpers; | ||
|
||
using HarmonyLib.BUTR.Extensions; | ||
|
||
using System.IO; | ||
using System.Xml; | ||
|
||
using TaleWorlds.Engine; | ||
|
||
using Path = System.IO.Path; | ||
|
||
namespace Bannerlord.ButterLib.Helpers | ||
{ | ||
internal static class LocalizedTextManagerUtils | ||
{ | ||
private delegate XmlDocument? LoadXmlFileDelegate(string path); | ||
private static readonly LoadXmlFileDelegate? LoadXmlFile = | ||
AccessTools2.GetDeclaredDelegate<LoadXmlFileDelegate>("TaleWorlds.Localization.LocalizedTextManager:LoadXmlFile"); | ||
|
||
private delegate void LoadFromXmlDelegate(XmlDocument doc, string modulePath); | ||
private static readonly LoadFromXmlDelegate? LoadFromXml = | ||
AccessTools2.GetDeclaredDelegate<LoadFromXmlDelegate>("TaleWorlds.Localization.LanguageData:LoadFromXml"); | ||
|
||
public static void LoadLanguageData() | ||
{ | ||
if (LoadXmlFile is null || LoadFromXml is null) return; | ||
|
||
var moduleInfo = ModuleInfoHelper.GetModuleByType(typeof(LocalizedTextManagerUtils)); | ||
if (moduleInfo is null) return; | ||
|
||
var path = Path.Combine(Utilities.GetBasePath(), "Modules", moduleInfo.Id, "ModuleData", "Languages"); | ||
if (!Directory.Exists(path)) return; | ||
|
||
foreach (var file in Directory.GetFiles(path, "language_data.xml_", SearchOption.AllDirectories)) | ||
{ | ||
if (LoadXmlFile(file) is { } xmlDocument) | ||
LoadFromXml(xmlDocument, path); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.