From e26ed1fe30274fc02ae9c95708f4ae27edd7f779 Mon Sep 17 00:00:00 2001 From: Hyper B <137433177+HyperB1@users.noreply.github.com> Date: Mon, 20 Jul 2026 04:41:41 +0500 Subject: [PATCH] Make Spanish accent more linguistically accurate (#38249) * Update SpanishAccentSystem.cs Use RegEx in accordance with the phonotactics of the Spanish language. * Allow SH * Addressing review comments * better comment * conflict --------- Co-authored-by: AJCM-git --- .../EntitySystems/SpanishAccentSystem.cs | 36 +++++++++---------- Resources/Locale/en-US/traits/traits.ftl | 2 +- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/Content.Server/Speech/EntitySystems/SpanishAccentSystem.cs b/Content.Server/Speech/EntitySystems/SpanishAccentSystem.cs index b2c3b4eea4..e68d23a190 100644 --- a/Content.Server/Speech/EntitySystems/SpanishAccentSystem.cs +++ b/Content.Server/Speech/EntitySystems/SpanishAccentSystem.cs @@ -1,3 +1,4 @@ +using System.Text.RegularExpressions; using System.Text; using Content.Server.Speech.Components; using Content.Shared.Speech.EntitySystems; @@ -6,9 +7,17 @@ namespace Content.Server.Speech.EntitySystems; public sealed class SpanishAccentSystem : RelayAccentSystem { + // for words in all lowercase (multiple "s" are allowed) + private static readonly Regex RegexLower = new(@"(? Estation; Capital "S" Is Replaced Directly, Multiple "S" Are Allowed) + private static readonly Regex RegexCaps = new(@"(?? ent = null) { - // Insert E before every S + // Insert E before every S that is followed by a consonant that makes a distinct sound + // (H is excluded because [sh] is a single sound) message = InsertS(message); // If a sentence ends with ?, insert a reverse ? at the beginning of the sentence message = ReplacePunctuation(message); @@ -17,20 +26,11 @@ public sealed class SpanishAccentSystem : RelayAccentSystem