Skip to content

Commit

Permalink
Corvax Localisation
Browse files Browse the repository at this point in the history
  • Loading branch information
Vonsant committed Aug 3, 2024
1 parent 1f23689 commit 6aeabd7
Show file tree
Hide file tree
Showing 17 changed files with 1,252 additions and 964 deletions.
47 changes: 46 additions & 1 deletion Content.Server/Chat/Managers/ChatSanitizationManager.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Text.RegularExpressions;
using Content.Shared.CCVar;
using Robust.Shared.Configuration;

Expand Down Expand Up @@ -93,10 +94,51 @@ public sealed class ChatSanitizationManager : IChatSanitizationManager
{ "[':", "chatsan-tearfully-smiles" },
{ "('=", "chatsan-tearfully-smiles" },
{ "['=", "chatsan-tearfully-smiles" },
// Corvax-Localization-Start
{ "хд", "chatsan-laughs" },
{ "о-о", "chatsan-wide-eyed" }, // cyrillic о
{ "о.о", "chatsan-wide-eyed" }, // cyrillic о
{ "0_о", "chatsan-wide-eyed" }, // cyrillic о
{ "о/", "chatsan-waves" }, // cyrillic о
{ "о7", "chatsan-salutes" }, // cyrillic о
{ "0_o", "chatsan-wide-eyed" },
{ "лмао", "chatsan-laughs" },
{ "рофл", "chatsan-laughs" },
{ "яхз", "chatsan-shrugs" },
{ ":0", "chatsan-surprised" },
{ ":р", "chatsan-stick-out-tongue" }, // cyrillic р
{ "кек", "chatsan-laughs" },
{ "T_T", "chatsan-cries" },
{ "Т_Т", "chatsan-cries" }, // cyrillic T
{ "=_(", "chatsan-cries" },
{ "!с", "chatsan-laughs" },
{ "!в", "chatsan-sighs" },
{ "!х", "chatsan-claps" },
{ "!щ", "chatsan-snaps" },
{ "))", "chatsan-smiles-widely" },
{ ")", "chatsan-smiles" },
{ "((", "chatsan-frowns-deeply" },
{ "(", "chatsan-frowns" },
{ "дрочит", "молится" },
{ "ебет", "молится" },
{ "ебёт", "молится" },
{ "трахает", "молится" },
{ "срёт", "молится" },
{ "срет", "молится" },
{ "ссыт", "молится" },
{ "обоссал", "помолился" },
{ "зигует", "бьёт себя по лицу" },
{ "зиганул", "бьёт себя по лицу" },
{ "кинул плотную", "бьёт себя по лицу" },
{ "кинул потную", "бьёт себя по лицу" },
// Corvax-Localization-End
};

private bool _doSanitize;

// Anti-Goida
private static readonly Regex GoydaRegex = new(@"[ГгGg][ОоOo]+[ЙйYy][ДдDd][АаAa]", RegexOptions.Compiled | RegexOptions.IgnoreCase);

public void Initialize()
{
_configurationManager.OnValueChanged(CCVars.ChatSanitizerEnabled, x => _doSanitize = x, true);
Expand All @@ -113,6 +155,9 @@ public bool TrySanitizeOutSmilies(string input, EntityUid speaker, out string sa

input = input.TrimEnd();

// Apply Anti-Goida filter
input = GoydaRegex.Replace(input, "Я долбоёб");

foreach (var (smiley, replacement) in SmileyToEmote)
{
if (input.EndsWith(smiley, true, CultureInfo.InvariantCulture))
Expand All @@ -127,4 +172,4 @@ public bool TrySanitizeOutSmilies(string input, EntityUid speaker, out string sa
emote = null;
return false;
}
}
}
13 changes: 11 additions & 2 deletions Content.Server/Speech/EntitySystems/BarkAccentSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public sealed class BarkAccentSystem : EntitySystem
[Dependency] private readonly IRobustRandom _random = default!;

private static readonly IReadOnlyList<string> Barks = new List<string>{
" Woof!", " WOOF", " wof-wof"
" Гав!", " ГАВ", " вуф-вуф" // Corvax-Localization
}.AsReadOnly();

private static readonly IReadOnlyDictionary<string, string> SpecialWords = new Dictionary<string, string>()
Expand All @@ -17,6 +17,12 @@ public sealed class BarkAccentSystem : EntitySystem
{ "Ah", "Arf" },
{ "oh", "oof" },
{ "Oh", "Oof" },
//Corvax-Localization-Start
{ "га", "гаф" },
{ "Га", "Гаф" },
{ "угу", "вуф" },
{ "Угу", "Вуф" },
//Corvax-Localization-End
};

public override void Initialize()
Expand All @@ -32,7 +38,10 @@ public string Accentuate(string message)
}

return message.Replace("!", _random.Pick(Barks))
.Replace("l", "r").Replace("L", "R");
//Corvax-Localization-Start
.Replace("l", "r").Replace("L", "R")
.Replace("л", "р").Replace("Л", "Р");
//Corvax-Localization-End
}

private void OnAccent(EntityUid uid, BarkAccentComponent component, AccentGetEvent args)
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Speech/EntitySystems/StutteringSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public sealed class StutteringSystem : SharedStutteringSystem
[Dependency] private readonly IRobustRandom _random = default!;

// Regex of characters to stutter.
private static readonly Regex Stutter = new(@"[b-df-hj-np-tv-wxyz]",
private static readonly Regex Stutter = new(@"[b-df-hj-np-tv-wxyz-б-вд-к-лмн-прст]", // Corvax-Localization
RegexOptions.Compiled | RegexOptions.IgnoreCase);

public override void Initialize()
Expand Down
17 changes: 15 additions & 2 deletions Content.Shared/Humanoid/NamingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,22 @@ public string GetFirstName(SpeciesPrototype speciesProto, Gender? gender = null)
}
}

public string GetLastName(SpeciesPrototype speciesProto)
// Corvax-LastnameGender-Start: Added custom gender split logic
public string GetLastName(SpeciesPrototype speciesProto, Gender? gender = null)
{
return _random.Pick(_prototypeManager.Index<DatasetPrototype>(speciesProto.LastNames).Values);
switch (gender)
{
case Gender.Male:
return _random.Pick(_prototypeManager.Index<DatasetPrototype>(speciesProto.MaleLastNames).Values);
case Gender.Female:
return _random.Pick(_prototypeManager.Index<DatasetPrototype>(speciesProto.FemaleLastNames).Values);
default:
if (_random.Prob(0.5f))
return _random.Pick(_prototypeManager.Index<DatasetPrototype>(speciesProto.MaleLastNames).Values);
else
return _random.Pick(_prototypeManager.Index<DatasetPrototype>(speciesProto.FemaleLastNames).Values);
}
}
// Corvax-LastnameGender-End
}
}
7 changes: 6 additions & 1 deletion Content.Shared/Humanoid/Prototypes/SpeciesPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,13 @@ public sealed partial class SpeciesPrototype : IPrototype
[DataField]
public string FemaleFirstNames { get; private set; } = "names_first_female";

// Corvax-LastnameGender-Start: Split lastname field by gender
[DataField]
public string LastNames { get; private set; } = "names_last";
public string MaleLastNames { get; private set; } = "names_last_male";

[DataField]
public string FemaleLastNames { get; private set; } = "names_last_female";
// Corvax-LastnameGender-End

[DataField]
public SpeciesNaming Naming { get; private set; } = SpeciesNaming.FirstLast;
Expand Down
7 changes: 6 additions & 1 deletion Content.Shared/Localizations/ContentLocalizationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ public sealed class ContentLocalizationManager
[Dependency] private readonly ILocalizationManager _loc = default!;

// If you want to change your codebase's language, do it here.
private const string Culture = "en-US";
private const string Culture = "ru-RU"; // Corvax-Localization
private const string FallbackCulture = "en-US"; // Corvax-Localization

/// <summary>
/// Custom format strings used for parsing and displaying minutes:seconds timespans.
Expand All @@ -26,8 +27,11 @@ public sealed class ContentLocalizationManager
public void Initialize()
{
var culture = new CultureInfo(Culture);
var fallbackCulture = new CultureInfo(FallbackCulture); // Corvax-Localization

_loc.LoadCulture(culture);
_loc.LoadCulture(fallbackCulture); // Corvax-Localization
_loc.SetFallbackCluture(fallbackCulture); // Corvax-Localization
_loc.AddFunction(culture, "PRESSURE", FormatPressure);
_loc.AddFunction(culture, "POWERWATTS", FormatPowerWatts);
_loc.AddFunction(culture, "POWERJOULES", FormatPowerJoules);
Expand All @@ -36,6 +40,7 @@ public void Initialize()
_loc.AddFunction(culture, "LOC", FormatLoc);
_loc.AddFunction(culture, "NATURALFIXED", FormatNaturalFixed);
_loc.AddFunction(culture, "NATURALPERCENT", FormatNaturalPercent);
_loc.AddFunction(culture, "MANY", FormatMany); // Corvax-Localization


/*
Expand Down
5 changes: 3 additions & 2 deletions Content.Shared/Preferences/HumanoidCharacterProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace Content.Shared.Preferences
[Serializable, NetSerializable]
public sealed partial class HumanoidCharacterProfile : ICharacterProfile
{
private static readonly Regex RestrictedNameRegex = new("[^A-Z,a-z,0-9, ,\\-,']");
private static readonly Regex RestrictedNameRegex = new("[^а-яА-Яa-zA-Z-'0-9\\ ]"); // Corvax-Localization
private static readonly Regex ICNameCaseRegex = new(@"^(?<word>\w)|\b(?<word>\w)(?=\w*$)");

public const int MaxNameLength = 32;
Expand Down Expand Up @@ -539,7 +539,7 @@ public void EnsureValid(ICommonSession session, IDependencyCollection collection

if (configManager.GetCVar(CCVars.RestrictedNames))
{
name = Regex.Replace(name, @"[^\u0041-\u005A,\u0061-\u007A,\u00C0-\u00D6,\u00D8-\u00F6,\u00F8-\u00FF,\u0100-\u017F, -]", string.Empty);
//name = Regex.Replace(name, @"[^\u0041-\u005A,\u0061-\u007A,\u00C0-\u00D6,\u00D8-\u00F6,\u00F8-\u00FF,\u0100-\u017F, -]", string.Empty);
/*
* 0041-005A Basic Latin: Uppercase Latin Alphabet
* 0061-007A Basic Latin: Lowercase Latin Alphabet
Expand All @@ -548,6 +548,7 @@ public void EnsureValid(ICommonSession session, IDependencyCollection collection
* 00F8-00FF Latin-1 Supplement: Letters III
* 0100-017F Latin Extended A: European Latin
*/
name = RestrictedNameRegex.Replace(name, string.Empty);
}

if (configManager.GetCVar(CCVars.ICNameCase))
Expand Down
Loading

0 comments on commit 6aeabd7

Please sign in to comment.