From 4d55e2dd558b05af4b758887516db19e3e565663 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Thu, 28 Dec 2017 21:47:29 +0200 Subject: [PATCH] Move hard-coded gender pronouns from TextManager to Texts.xml --- Barotrauma/BarotraumaShared/Content/Texts.xml | 20 +++++++---- .../GameSession/GameModes/TraitorManager.cs | 2 +- .../BarotraumaShared/Source/TextManager.cs | 36 ++++++++++++------- 3 files changed, 38 insertions(+), 20 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Content/Texts.xml b/Barotrauma/BarotraumaShared/Content/Texts.xml index 475b56b98..db5d66ef1 100644 --- a/Barotrauma/BarotraumaShared/Content/Texts.xml +++ b/Barotrauma/BarotraumaShared/Content/Texts.xml @@ -85,6 +85,14 @@ Are you sure you want to delete "[file]"? Could not delete file "[file]"! + + He + His + Himself + She + Her + Herself + No mission Reward: [reward] @@ -243,12 +251,12 @@ It is possible that there are other agents on this submarine. You don't know their names, but you do have a method of communication. Use the code words to greet the agent and code response to respond. Disguise such words in a normal-looking phrase so the crew doesn't suspect anything.\n\nThe code words are: [codewords].\nThe code response is: [coderesponse]. [traitorname] is the traitor and the target is [targetname]. - [traitorname] was a traitor! [Gendernounpossessive] task was to assassinate [targetname]. The task was successful. - [traitorname] was a traitor! [Gendernounpossessive] task was to assassinate [targetname]. The task was successful, but the traitor did not make it out alive either. - [traitorname] was a traitor! [Gendernounpossessive] task was to assassinate [targetname]. The task was successful, but the traitor was succesfully detained. - [traitorname] was a traitor! [Gendernounpossessive] task was to assassinate [targetname]. The task was unsuccessful. - [traitorname] was a traitor! [Gendernounpossessive] task was to assassinate [targetname], but [gendernoun] got [gendernounreflexive] killed before completing it. - [traitorname] was a traitor! [Gendernounpossessive] task was to assassinate [targetname]. The task failed - [gendernoun] was successfully detained. + [traitorname] was a traitor! [Genderpronounpossessive] task was to assassinate [targetname]. The task was successful. + [traitorname] was a traitor! [Genderpronounpossessive] task was to assassinate [targetname]. The task was successful, but the traitor did not make it out alive either. + [traitorname] was a traitor! [Genderpronounpossessive] task was to assassinate [targetname]. The task was successful, but the traitor was succesfully detained. + [traitorname] was a traitor! [Genderpronounpossessive] task was to assassinate [targetname]. The task was unsuccessful. + [traitorname] was a traitor! [Genderpronounpossessive] task was to assassinate [targetname], but [genderpronoun] got [genderpronounreflexive] killed before completing it. + [traitorname] was a traitor! [Genderpronounpossessive] task was to assassinate [targetname]. The task failed - [genderpronoun] was successfully detained. Succumbed to their injuries diff --git a/Barotrauma/BarotraumaShared/Source/GameSession/GameModes/TraitorManager.cs b/Barotrauma/BarotraumaShared/Source/GameSession/GameModes/TraitorManager.cs index 3d29b4636..0e87247bc 100644 --- a/Barotrauma/BarotraumaShared/Source/GameSession/GameModes/TraitorManager.cs +++ b/Barotrauma/BarotraumaShared/Source/GameSession/GameModes/TraitorManager.cs @@ -178,7 +178,7 @@ namespace Barotrauma } } - endMessage += (TextManager.ReplaceGenderNouns(TextManager.Get(messageTag), traitorCharacter.Info.Gender) + "\n") + endMessage += (TextManager.ReplaceGenderPronouns(TextManager.Get(messageTag), traitorCharacter.Info.Gender) + "\n") .Replace("[traitorname]", traitorCharacter.Name) .Replace("[targetname]", targetCharacter.Name); } diff --git a/Barotrauma/BarotraumaShared/Source/TextManager.cs b/Barotrauma/BarotraumaShared/Source/TextManager.cs index 3f6435ddd..7186f351d 100644 --- a/Barotrauma/BarotraumaShared/Source/TextManager.cs +++ b/Barotrauma/BarotraumaShared/Source/TextManager.cs @@ -57,26 +57,36 @@ namespace Barotrauma return text; } - public static string ReplaceGenderNouns(string text, Gender gender) + public static string ReplaceGenderPronouns(string text, Gender gender) { if (gender == Gender.Male) { - return text.Replace("[gendernoun]", "he") - .Replace("[gendernounpossessive]", "his") - .Replace("[gendernounreflexive]", "himself") - .Replace("[Gendernoun]", "He") - .Replace("[Gendernounpossessive]", "His") - .Replace("[Gendernounreflexive]", "Himself"); + return text.Replace("[genderpronoun]", Get("PronounMale").ToLower()) + .Replace("[genderpronounpossessive]", Get("PronounPossessiveMale").ToLower()) + .Replace("[genderpronounreflexive]", Get("PronounReflexiveMale").ToLower()) + .Replace("[Genderpronoun]", Capitalize(Get("PronounMale"))) + .Replace("[Genderpronounpossessive]", Capitalize(Get("PronounPossessiveMale"))) + .Replace("[Genderpronounreflexive]", Capitalize(Get("PronounReflexiveMale"))); } else { - return text.Replace("[gendernoun]", "she") - .Replace("[gendernounpossessive]", "her") - .Replace("[gendernounreflexive]", "herself") - .Replace("[Gendernoun]", "She") - .Replace("[Gendernounpossessive]", "Her") - .Replace("[Gendernounreflexive]", "Herself"); + return text.Replace("[genderpronoun]", Get("PronounFemale").ToLower()) + .Replace("[genderpronounpossessive]", Get("PronounPossessiveFemale").ToLower()) + .Replace("[genderpronounreflexive]", Get("PronounReflexiveFemale").ToLower()) + .Replace("[Genderpronoun]", Capitalize(Get("PronounFemale"))) + .Replace("[Genderpronounpossessive]", Capitalize(Get("PronounPossessiveFemale"))) + .Replace("[Genderpronounreflexive]", Capitalize(Get("PronounReflexiveFemale"))); } } + + private static string Capitalize(string str) + { + if (string.IsNullOrWhiteSpace(str)) + { + return str; + } + + return char.ToUpper(str[0]) + str.Substring(1); + } } }