diff --git a/Content.Server/Speech/Components/FrenchAccentComponent.cs b/Content.Server/Speech/Components/FrenchAccentComponent.cs new file mode 100644 index 00000000000000..f696c35ea03f45 --- /dev/null +++ b/Content.Server/Speech/Components/FrenchAccentComponent.cs @@ -0,0 +1,11 @@ +using Content.Server.Speech.EntitySystems; + +namespace Content.Server.Speech.Components; + +/// +/// French accent replaces spoken letters. "th" becomes "z" and "H" at the start of a word becomes "'". +/// +[RegisterComponent] +[Access(typeof(FrenchAccentSystem))] +public sealed partial class FrenchAccentComponent : Component +{ } diff --git a/Content.Server/Speech/EntitySystems/FrenchAccentSystem.cs b/Content.Server/Speech/EntitySystems/FrenchAccentSystem.cs new file mode 100644 index 00000000000000..563728873252f9 --- /dev/null +++ b/Content.Server/Speech/EntitySystems/FrenchAccentSystem.cs @@ -0,0 +1,45 @@ +using Content.Server.Speech.Components; +using System.Text.RegularExpressions; + +namespace Content.Server.Speech.EntitySystems; + +/// +/// System that gives the speaker a faux-French accent. +/// +public sealed class FrenchAccentSystem : EntitySystem +{ + [Dependency] private readonly ReplacementAccentSystem _replacement = default!; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnAccentGet); + } + + public string Accentuate(string message, FrenchAccentComponent component) + { + var msg = message; + + msg = _replacement.ApplyReplacements(msg, "french"); + + // replaces th with dz + msg = Regex.Replace(msg, @"th", "'z", RegexOptions.IgnoreCase); + + // removes the letter h from the start of words. + msg = Regex.Replace(msg, @"(?