Co-authored-by: Seven2280 <semvalentin123@gmail.com>
This commit is contained in:
banumbas 2025-01-10 01:19:48 +03:00 committed by GitHub
parent 22a5170aec
commit 21ede66dfe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 179 additions and 0 deletions

View file

@ -0,0 +1,5 @@
namespace Content.Server._Sunrise.Speech.Components;
[RegisterComponent]
public sealed partial class TransliterationAccentComponent : Component
{
}

View file

@ -0,0 +1,162 @@
using System.Text;
using Content.Server._Sunrise.Speech.Components;
using Content.Server.Speech;
using Content.Server.Speech.Components;
using Content.Server.Speech.EntitySystems;
namespace Content.Server._Sunrise.Speech.EntitySystems;
public sealed class TransliterationAccentSystem : EntitySystem
{
[Dependency] private readonly ReplacementAccentSystem _replacement = default!;
public override void Initialize()
{
SubscribeLocalEvent<TransliterationAccentComponent, AccentGetEvent>(OnAccent);
}
private string Accentuate(string message)
{
var accentedMessage = new StringBuilder(_replacement.ApplyReplacements(message, "transliteration"));
for (var i = 0; i < accentedMessage.Length; i++)
{
var c = accentedMessage[i];
accentedMessage[i] = c switch
{
'й' => 'q',
'ц' => 'w',
'у' => 'e',
'к' => 'r',
'е' => 't',
'н' => 'y',
'г' => 'u',
'ш' => 'i',
'щ' => 'o',
'з' => 'p',
'х' => '[',
'ъ' => ']',
'ф' => 'a',
'ы' => 's',
'в' => 'd',
'а' => 'f',
'п' => 'g',
'р' => 'h',
'о' => 'j',
'л' => 'k',
'д' => 'l',
'ж' => ';',
'э' => '"',
'я' => 'z',
'ч' => 'x',
'с' => 'c',
'м' => 'v',
'и' => 'b',
'т' => 'n',
'ь' => 'm',
'б' => ',',
'ю' => '.',
'ё' => '`',
'Й' => 'Q',
'Ц' => 'W',
'У' => 'E',
'К' => 'R',
'Е' => 'T',
'Н' => 'Y',
'Г' => 'U',
'Ш' => 'I',
'Щ' => 'O',
'З' => 'P',
'Х' => '{',
'Ъ' => '}',
'Ф' => 'A',
'Ы' => 'S',
'В' => 'D',
'А' => 'F',
'П' => 'G',
'Р' => 'H',
'О' => 'J',
'Л' => 'K',
'Д' => 'L',
'Ж' => ':',
'Э' => '"',
'Я' => 'Z',
'Ч' => 'X',
'С' => 'C',
'М' => 'V',
'И' => 'B',
'Т' => 'N',
'Ь' => 'M',
'Б' => '<',
'Ю' => '>',
'Ё' => '~',
'q' => 'й',
'w' => 'ц',
'e' => 'у',
'r' => 'к',
't' => 'е',
'y' => 'н',
'u' => 'г',
'i' => 'ш',
'o' => 'щ',
'p' => 'з',
'[' => 'х',
']' => 'ъ',
'a' => 'ф',
's' => 'ы',
'd' => 'в',
'f' => 'а',
'g' => 'п',
'h' => 'р',
'j' => 'о',
'k' => 'л',
'l' => 'д',
';' => 'ж',
'\'' => 'э',
'z' => 'я',
'x' => 'ч',
'c' => 'с',
'v' => 'м',
'b' => 'и',
'n' => 'т',
'm' => 'ь',
',' => 'б',
'`' => 'ё',
'Q' => 'Й',
'W' => 'Ц',
'E' => 'У',
'R' => 'К',
'T' => 'Е',
'Y' => 'Н',
'U' => 'Г',
'I' => 'Ш',
'O' => 'Щ',
'P' => 'З',
'{' => 'Х',
'}' => 'Ъ',
'A' => 'Ф',
'S' => 'Ы',
'D' => 'В',
'F' => 'А',
'G' => 'П',
'H' => 'Р',
'J' => 'О',
'K' => 'Л',
'L' => 'Д',
':' => 'Ж',
'"' => 'Э',
'Z' => 'Я',
'X' => 'Ч',
'C' => 'С',
'V' => 'М',
'B' => 'И',
'N' => 'Т',
'M' => 'Ь',
'<' => 'Б',
'>' => 'Ю',
'~' => 'Ё',
_ => accentedMessage[i]
};
}
return accentedMessage.ToString();
}
private void OnAccent(EntityUid uid, TransliterationAccentComponent component, AccentGetEvent args)
{
args.Message = Accentuate(args.Message);
}
}

View file

@ -8,3 +8,5 @@ trait-ukrainian-accent-name = Украинский акцент
trait-ukrainian-accent-desc = Заробiтчани вже навiть у космосi.
trait-russian-accent-name = Русский акцент
trait-russian-accent-desc = Товарищ, это не ваше а наше.
trait-transliteration-accent-name = Транслитерированный акцент
trait-transliteration-accent-desc = Ds ujdjhbnt nhfyckbnjv.

View file

@ -28,3 +28,13 @@
components:
- type: RussianAccent
# 2 Cost
- type: trait
id: TransliterationAccent
name: trait-transliteration-accent-name
description: trait-transliteration-accent-desc
category: SpeechTraits
cost: 2
components:
- type: TransliterationAccent