Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved French accent (th sound) #33630

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions Content.Server/Speech/EntitySystems/FrenchAccentSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,28 @@ public string Accentuate(string message, FrenchAccentComponent component)

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;
}
Expand Down
Loading