]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Improved French accent (th sound) (#33630)
authorObani Gemini <ObaniGemini@users.noreply.github.com>
Fri, 30 May 2025 20:10:13 +0000 (22:10 +0200)
committerGitHub <noreply@github.com>
Fri, 30 May 2025 20:10:13 +0000 (13:10 -0700)
* Improved French accent

* Remove the double consonna part to simplify the code and behaviour

* French accent: clarify a comment

Co-authored-by: Centronias <charlie.t.santos@gmail.com>
---------

Co-authored-by: Centronias <charlie.t.santos@gmail.com>
Content.Server/Speech/EntitySystems/FrenchAccentSystem.cs

index d71655569cb63408ad567e36f1fff7f8d1112bc7..1b7c46e13a0d467ee6bb9b14db00f0b827042e8c 100644 (file)
@@ -27,14 +27,28 @@ public sealed class FrenchAccentSystem : EntitySystem
 
         msg = _replacement.ApplyReplacements(msg, "french");
 
-        // replaces th with z
-        msg = RegexTh.Replace(msg, "'z");
-
         // replaces h with ' at the start of words.
         msg = RegexStartH.Replace(msg, "'");
 
         // spaces out ! ? : and ;.
         msg = RegexSpacePunctuation.Replace(msg, " $&");
+        
+        // replaces th with 'z or 's depending on the case
+        foreach (Match match in RegexTh.Matches(msg))
+        {
+            var uppercase = msg.Substring(match.Index, 2).Contains("TH");
+            var Z = uppercase ? "Z" : "z";
+            var S = uppercase ? "S" : "s";
+            var idxLetter = match.Index + 2;
+
+            // If th is alone, just do 'z
+            if (msg.Length <= idxLetter) {
+                msg = msg.Substring(0, match.Index) + "'" + Z;
+            } else {
+                var c = "aeiouy".Contains(msg.Substring(idxLetter, 1).ToLower()) ? Z : S;
+                msg = msg.Substring(0, match.Index) + "'" + c + msg.Substring(idxLetter);
+            }
+        }
 
         return msg;
     }