Files
wwdpublic/Content.Server/Speech/EntitySystems/RussianAccentSystem.cs
Peptide90 1b249463fb International Space Station Update - New Accent Traits (#1712)
Ports Russian and German languages from Wizden and adds traits for them.

Also adds traits for Italian, French and Spanish since they already
exist.

Not tested because the game didn't want to build locally.

# Changelog

<!--
You can add an author after the `🆑` to change the name that appears
in the changelog (ex: `🆑 Death`)
Leaving it blank will default to your GitHub display name
This includes all available types for the changelog
-->

🆑
- add: Added traits for accents: Russian, German, French, Italian and
Spanish

---------

Signed-off-by: Peptide90 <78795277+Peptide90@users.noreply.github.com>
(cherry picked from commit 91eb7bff09e7c61896b92fde70ac7c4d47e96a6d)
2025-02-05 18:18:09 +03:00

50 lines
1.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Text;
using Content.Server.Speech.Components;
namespace Content.Server.Speech.EntitySystems;
public sealed class RussianAccentSystem : EntitySystem
{
[Dependency] private readonly ReplacementAccentSystem _replacement = default!;
public override void Initialize()
{
SubscribeLocalEvent<RussianAccentComponent, AccentGetEvent>(OnAccent);
}
public string Accentuate(string message)
{
var accentedMessage = new StringBuilder(_replacement.ApplyReplacements(message, "russian"));
for (var i = 0; i < accentedMessage.Length; i++)
{
var c = accentedMessage[i];
accentedMessage[i] = c switch
{
'A' => 'Д',
'b' => 'в',
'N' => 'И',
'n' => 'и',
'K' => 'К',
'k' => 'к',
'm' => 'м',
'h' => 'н',
't' => 'т',
'R' => 'Я',
'r' => 'я',
'Y' => 'У',
'W' => 'Ш',
'w' => 'ш',
_ => accentedMessage[i]
};
}
return accentedMessage.ToString();
}
private void OnAccent(EntityUid uid, RussianAccentComponent component, AccentGetEvent args)
{
args.Message = Accentuate(args.Message);
}
}