Skip to content

Commit

Permalink
Culture
Browse files Browse the repository at this point in the history
  • Loading branch information
PuroSlavKing committed Aug 23, 2024
1 parent fab65b1 commit 56a3d16
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
24 changes: 23 additions & 1 deletion Content.Shared/Localizations/ContentLocalizationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ 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";

// WD-EDIT
private const string Culture = "ru-RU";

// WD-EDIT
private const string FallbackCulture = "en-US";

/// <summary>
/// Custom format strings used for parsing and displaying minutes:seconds timespans.
Expand All @@ -27,7 +32,16 @@ public void Initialize()
{
var culture = new CultureInfo(Culture);

// WD-EDIT
var fallbackCulture = new CultureInfo(FallbackCulture);

_loc.LoadCulture(culture);

// WD-EDIT
_loc.LoadCulture(fallbackCulture);
_loc.SetFallbackCluture(fallbackCulture);
// WD-EDIT

_loc.AddFunction(culture, "PRESSURE", FormatPressure);
_loc.AddFunction(culture, "POWERWATTS", FormatPowerWatts);
_loc.AddFunction(culture, "POWERJOULES", FormatPowerJoules);
Expand All @@ -37,6 +51,14 @@ public void Initialize()
_loc.AddFunction(culture, "NATURALFIXED", FormatNaturalFixed);
_loc.AddFunction(culture, "NATURALPERCENT", FormatNaturalPercent);

_loc.AddFunction(fallbackCulture, "PRESSURE", FormatPressure);
_loc.AddFunction(fallbackCulture, "POWERWATTS", FormatPowerWatts);
_loc.AddFunction(fallbackCulture, "POWERJOULES", FormatPowerJoules);
_loc.AddFunction(fallbackCulture, "UNITS", FormatUnits);
_loc.AddFunction(fallbackCulture, "TOSTRING", args => FormatToString(culture, args));
_loc.AddFunction(fallbackCulture, "LOC", FormatLoc);
_loc.AddFunction(fallbackCulture, "NATURALFIXED", FormatNaturalFixed);
_loc.AddFunction(fallbackCulture, "NATURALPERCENT", FormatNaturalPercent);

/*
* The following language functions are specific to the english localization. When working on your own
Expand Down
18 changes: 18 additions & 0 deletions Content.Shared/_White/CCVar/WhiteCCVars.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Robust.Shared;
using Robust.Shared.Configuration;

namespace Content.Shared._White
{
[CVarDefs]
public sealed class WhiteCCVars : CVars
{

/*
* IDK
*/

public static readonly CVarDef<string>
ServerCulture = CVarDef.Create("white.culture", "ru-RU", CVar.REPLICATED | CVar.SERVER);

}
}

0 comments on commit 56a3d16

Please sign in to comment.