mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Add another translation dictionary that keeps CDATA
This commit is contained in:
parent
fea15287c6
commit
f765e07859
@ -22,7 +22,9 @@
|
|||||||
"DEBUG_PLACE_TEXT": "Place Nomai Text",
|
"DEBUG_PLACE_TEXT": "Place Nomai Text",
|
||||||
"DEBUG_UNDO": "Undo",
|
"DEBUG_UNDO": "Undo",
|
||||||
"DEBUG_REDO": "Redo",
|
"DEBUG_REDO": "Redo",
|
||||||
"Vessel": "Vessel",
|
"Vessel": "Vessel"
|
||||||
|
},
|
||||||
|
"OtherDictionary": {
|
||||||
"NOMAI_SHUTTLE_COMPUTER": "The <![CDATA[<color=orange>shuttle</color>]]> is currently resting at <![CDATA[<color=lightblue>{0}</color>]]>."
|
"NOMAI_SHUTTLE_COMPUTER": "The <![CDATA[<color=orange>shuttle</color>]]> is currently resting at <![CDATA[<color=lightblue>{0}</color>]]>."
|
||||||
},
|
},
|
||||||
"AchievementTranslations": {
|
"AchievementTranslations": {
|
||||||
|
|||||||
@ -159,7 +159,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
var shuttle = ShuttleBuilder.Shuttles[id];
|
var shuttle = ShuttleBuilder.Shuttles[id];
|
||||||
var planet = AstroObjectLocator.GetPlanetName(shuttle.GetComponentInParent<AstroObject>());
|
var planet = AstroObjectLocator.GetPlanetName(shuttle.GetComponentInParent<AstroObject>());
|
||||||
|
|
||||||
var displayText = TranslationHandler.GetTranslation("NOMAI_SHUTTLE_COMPUTER", TranslationHandler.TextType.UI).Replace("{0}", planet);
|
var displayText = TranslationHandler.GetTranslation("NOMAI_SHUTTLE_COMPUTER", TranslationHandler.TextType.OTHER).Replace("{0}", planet);
|
||||||
NHLogger.Log(displayText);
|
NHLogger.Log(displayText);
|
||||||
var xmlContent = $"<NomaiObject>\r\n <TextBlock>\r\n <ID>1</ID>\r\n <Text>{displayText}</Text>\r\n </TextBlock>\r\n</NomaiObject>";
|
var xmlContent = $"<NomaiObject>\r\n <TextBlock>\r\n <ID>1</ID>\r\n <Text>{displayText}</Text>\r\n </TextBlock>\r\n</NomaiObject>";
|
||||||
|
|
||||||
|
|||||||
@ -23,6 +23,11 @@ namespace NewHorizons.External.Configs
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Dictionary<string, string> UIDictionary;
|
public Dictionary<string, string> UIDictionary;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Translation table for other text, will be taken verbatim without correcting CDATA
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<string, string> OtherDictionary;
|
||||||
|
|
||||||
#region Achievements+
|
#region Achievements+
|
||||||
// This only exists for schema generation, Achievements+ handles the parsing
|
// This only exists for schema generation, Achievements+ handles the parsing
|
||||||
#pragma warning disable 0169
|
#pragma warning disable 0169
|
||||||
@ -63,6 +68,10 @@ namespace NewHorizons.External.Configs
|
|||||||
UIDictionary =
|
UIDictionary =
|
||||||
(Dictionary<string, string>) (dict[nameof(UIDictionary)] as JObject).ToObject(
|
(Dictionary<string, string>) (dict[nameof(UIDictionary)] as JObject).ToObject(
|
||||||
typeof(Dictionary<string, string>));
|
typeof(Dictionary<string, string>));
|
||||||
|
if (dict.ContainsKey(nameof(OtherDictionary)))
|
||||||
|
OtherDictionary =
|
||||||
|
(Dictionary<string, string>)(dict[nameof(OtherDictionary)] as JObject).ToObject(
|
||||||
|
typeof(Dictionary<string, string>));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -11,12 +11,14 @@ namespace NewHorizons.Handlers
|
|||||||
private static Dictionary<TextTranslation.Language, Dictionary<string, string>> _shipLogTranslationDictionary = new();
|
private static Dictionary<TextTranslation.Language, Dictionary<string, string>> _shipLogTranslationDictionary = new();
|
||||||
private static Dictionary<TextTranslation.Language, Dictionary<string, string>> _dialogueTranslationDictionary = new();
|
private static Dictionary<TextTranslation.Language, Dictionary<string, string>> _dialogueTranslationDictionary = new();
|
||||||
private static Dictionary<TextTranslation.Language, Dictionary<string, string>> _uiTranslationDictionary = new();
|
private static Dictionary<TextTranslation.Language, Dictionary<string, string>> _uiTranslationDictionary = new();
|
||||||
|
private static Dictionary<TextTranslation.Language, Dictionary<string, string>> _otherTranslationDictionary = new();
|
||||||
|
|
||||||
public enum TextType
|
public enum TextType
|
||||||
{
|
{
|
||||||
SHIPLOG,
|
SHIPLOG,
|
||||||
DIALOGUE,
|
DIALOGUE,
|
||||||
UI
|
UI,
|
||||||
|
OTHER
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetTranslation(string text, TextType type) => GetTranslation(text, type, true);
|
public static string GetTranslation(string text, TextType type) => GetTranslation(text, type, true);
|
||||||
@ -36,6 +38,9 @@ namespace NewHorizons.Handlers
|
|||||||
break;
|
break;
|
||||||
case TextType.UI:
|
case TextType.UI:
|
||||||
dictionary = _uiTranslationDictionary;
|
dictionary = _uiTranslationDictionary;
|
||||||
|
break;
|
||||||
|
case TextType.OTHER:
|
||||||
|
dictionary = _otherTranslationDictionary;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (warn) NHLogger.LogVerbose($"Invalid TextType {type}");
|
if (warn) NHLogger.LogVerbose($"Invalid TextType {type}");
|
||||||
@ -93,14 +98,27 @@ namespace NewHorizons.Handlers
|
|||||||
if (!_uiTranslationDictionary.ContainsKey(language)) _uiTranslationDictionary.Add(language, new Dictionary<string, string>());
|
if (!_uiTranslationDictionary.ContainsKey(language)) _uiTranslationDictionary.Add(language, new Dictionary<string, string>());
|
||||||
foreach (var originalKey in config.UIDictionary.Keys)
|
foreach (var originalKey in config.UIDictionary.Keys)
|
||||||
{
|
{
|
||||||
// Don't remove CDATA from UI
|
var key = originalKey.Replace("<", "<").Replace(">", ">").Replace("<![CDATA[", "").Replace("]]>", "");
|
||||||
var key = originalKey.Replace("<", "<").Replace(">", ">");
|
var value = config.UIDictionary[originalKey].Replace("<", "<").Replace(">", ">").Replace("<![CDATA[", "").Replace("]]>", "");
|
||||||
var value = config.UIDictionary[originalKey].Replace("<", "<").Replace(">", ">");
|
|
||||||
|
|
||||||
if (!_uiTranslationDictionary[language].ContainsKey(key)) _uiTranslationDictionary[language].Add(key, value);
|
if (!_uiTranslationDictionary[language].ContainsKey(key)) _uiTranslationDictionary[language].Add(key, value);
|
||||||
else _uiTranslationDictionary[language][key] = value;
|
else _uiTranslationDictionary[language][key] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.OtherDictionary != null && config.OtherDictionary.Count() > 0)
|
||||||
|
{
|
||||||
|
if (!_otherTranslationDictionary.ContainsKey(language)) _otherTranslationDictionary.Add(language, new Dictionary<string, string>());
|
||||||
|
foreach (var originalKey in config.OtherDictionary.Keys)
|
||||||
|
{
|
||||||
|
// Don't remove CDATA
|
||||||
|
var key = originalKey.Replace("<", "<").Replace(">", ">");
|
||||||
|
var value = config.OtherDictionary[originalKey].Replace("<", "<").Replace(">", ">");
|
||||||
|
|
||||||
|
if (!_otherTranslationDictionary[language].ContainsKey(key)) _otherTranslationDictionary[language].Add(key, value);
|
||||||
|
else _otherTranslationDictionary[language][key] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AddDialogue(string rawText, bool trimRawTextForKey = false, params string[] rawPreText)
|
public static void AddDialogue(string rawText, bool trimRawTextForKey = false, params string[] rawPreText)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user