Skip to content

Commit cac2202

Browse files
committed
Continued updates to translation layer
1 parent 5147551 commit cac2202

File tree

2 files changed

+33
-48
lines changed

2 files changed

+33
-48
lines changed

Modules/Translator.cs

Lines changed: 32 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,21 @@ public IEnumerable<LocalizedString> GetAllStrings(bool includeParentCultures)
2121

2222
public string this[string name, params object[] arguments] => Translate(name, arguments);
2323

24+
private const string CenterModifier = "center.";
25+
private const string HtmlModifier = "html.";
26+
2427
private string Translate(string key, params object[] arguments)
2528
{
26-
var centerModifier = "center.";
27-
var isCenter = key.StartsWith(centerModifier);
29+
var isCenter = key.StartsWith(CenterModifier);
30+
var isHtml = key.StartsWith(HtmlModifier);
31+
2832
if (isCenter)
2933
{
30-
key = key.Substring(centerModifier.Length);
34+
key = key.Substring(CenterModifier.Length);
35+
}
36+
else if (isHtml)
37+
{
38+
key = key.Substring(HtmlModifier.Length);
3139
}
3240

3341
var localizedString = _stringLocalizerImplementation[key, arguments];
@@ -40,50 +48,27 @@ private string Translate(string key, params object[] arguments)
4048
var translation = localizedString.Value;
4149

4250
// Handle translation colours
43-
// return translation
44-
// .Replace("[GREEN]", isHtml ? "<font color='green'>" : ChatColors.Green.ToString())
45-
// .Replace("[RED]", isHtml ? "<font color='red'>" : ChatColors.Red.ToString())
46-
// .Replace("[YELLOW]", isHtml ? "<font color='yellow'>" : ChatColors.Yellow.ToString())
47-
// .Replace("[BLUE]", isHtml ? "<font color='blue'>" : ChatColors.Blue.ToString())
48-
// .Replace("[PURPLE]", isHtml ? "<font color='purple'>" : ChatColors.Purple.ToString())
49-
// .Replace("[ORANGE]", isHtml ? "<font color='orange'>" : ChatColors.Orange.ToString())
50-
// .Replace("[WHITE]", isHtml ? "<font color='white'>" : ChatColors.White.ToString())
51-
// .Replace("[NORMAL]", isHtml ? "<font color='white'>" : ChatColors.White.ToString())
52-
// .Replace("[GREY]", isHtml ? "<font color='grey'>" : ChatColors.Grey.ToString())
53-
// .Replace("[LIGHT_RED]", isHtml ? "<font color='lightred'>" : ChatColors.LightRed.ToString())
54-
// .Replace("[LIGHT_BLUE]", isHtml ? "<font color='lightblue'>" : ChatColors.LightBlue.ToString())
55-
// .Replace("[LIGHT_PURPLE]", isHtml ? "<font color='mediumpurple'>" : ChatColors.LightPurple.ToString())
56-
// .Replace("[LIGHT_YELLOW]", isHtml ? "<font color='lightyellow'>" : ChatColors.LightYellow.ToString())
57-
// .Replace("[DARK_RED]", isHtml ? "<font color='darkred'>" : ChatColors.DarkRed.ToString())
58-
// .Replace("[DARK_BLUE]", isHtml ? "<font color='darkblue'>" : ChatColors.DarkBlue.ToString())
59-
// .Replace("[BLUE_GREY]", isHtml ? "<font color='grey'>" : ChatColors.BlueGrey.ToString())
60-
// .Replace("[OLIVE]", isHtml ? "<font color='olive'>" : ChatColors.Olive.ToString())
61-
// .Replace("[LIME]", isHtml ? "<font color='lime'>" : ChatColors.Lime.ToString())
62-
// .Replace("[GOLD]", isHtml ? "<font color='gold'>" : ChatColors.Gold.ToString())
63-
// .Replace("[SILVER]", isHtml ? "<font color='silver'>" : ChatColors.Silver.ToString())
64-
// .Replace("[MAGENTA]", isHtml ? "<font color='magenta'>" : ChatColors.Magenta.ToString());
65-
6651
return translation
67-
.Replace("[GREEN]", isCenter ? "" : ChatColors.Green.ToString())
68-
.Replace("[RED]", isCenter ? "" : ChatColors.Red.ToString())
69-
.Replace("[YELLOW]", isCenter ? "" : ChatColors.Yellow.ToString())
70-
.Replace("[BLUE]", isCenter ? "" : ChatColors.Blue.ToString())
71-
.Replace("[PURPLE]", isCenter ? "" : ChatColors.Purple.ToString())
72-
.Replace("[ORANGE]", isCenter ? "" : ChatColors.Orange.ToString())
73-
.Replace("[WHITE]", isCenter ? "" : ChatColors.White.ToString())
74-
.Replace("[NORMAL]", isCenter ? "" : ChatColors.White.ToString())
75-
.Replace("[GREY]", isCenter ? "" : ChatColors.Grey.ToString())
76-
.Replace("[LIGHT_RED]", isCenter ? "" : ChatColors.LightRed.ToString())
77-
.Replace("[LIGHT_BLUE]", isCenter ? "" : ChatColors.LightBlue.ToString())
78-
.Replace("[LIGHT_PURPLE]", isCenter ? "" : ChatColors.LightPurple.ToString())
79-
.Replace("[LIGHT_YELLOW]", isCenter ? "" : ChatColors.LightYellow.ToString())
80-
.Replace("[DARK_RED]", isCenter ? "" : ChatColors.DarkRed.ToString())
81-
.Replace("[DARK_BLUE]", isCenter ? "" : ChatColors.DarkBlue.ToString())
82-
.Replace("[BLUE_GREY]", isCenter ? "" : ChatColors.BlueGrey.ToString())
83-
.Replace("[OLIVE]", isCenter ? "" : ChatColors.Olive.ToString())
84-
.Replace("[LIME]", isCenter ? "" : ChatColors.Lime.ToString())
85-
.Replace("[GOLD]", isCenter ? "" : ChatColors.Gold.ToString())
86-
.Replace("[SILVER]", isCenter ? "" : ChatColors.Silver.ToString())
87-
.Replace("[MAGENTA]", isCenter ? "" : ChatColors.Magenta.ToString());
52+
.Replace("[GREEN]", isCenter ? "" : isHtml ? "<font color='green'>" : ChatColors.Green.ToString())
53+
.Replace("[RED]", isCenter ? "" : isHtml ? "<font color='red'>" : ChatColors.Red.ToString())
54+
.Replace("[YELLOW]", isCenter ? "" : isHtml ? "<font color='yellow'>" : ChatColors.Yellow.ToString())
55+
.Replace("[BLUE]", isCenter ? "" : isHtml ? "<font color='blue'>" : ChatColors.Blue.ToString())
56+
.Replace("[PURPLE]", isCenter ? "" : isHtml ? "<font color='purple'>" : ChatColors.Purple.ToString())
57+
.Replace("[ORANGE]", isCenter ? "" : isHtml ? "<font color='orange'>" : ChatColors.Orange.ToString())
58+
.Replace("[WHITE]", isCenter ? "" : isHtml ? "<font color='white'>" : ChatColors.White.ToString())
59+
.Replace("[NORMAL]", isCenter ? "" : isHtml ? "<font color='white'>" : ChatColors.White.ToString())
60+
.Replace("[GREY]", isCenter ? "" : isHtml ? "<font color='grey'>" : ChatColors.Grey.ToString())
61+
.Replace("[LIGHT_RED]", isCenter ? "" : isHtml ? "<font color='lightred'>" : ChatColors.LightRed.ToString())
62+
.Replace("[LIGHT_BLUE]", isCenter ? "" : isHtml ? "<font color='lightblue'>" : ChatColors.LightBlue.ToString())
63+
.Replace("[LIGHT_PURPLE]", isCenter ? "" : isHtml ? "<font color='mediumpurple'>" : ChatColors.LightPurple.ToString())
64+
.Replace("[LIGHT_YELLOW]", isCenter ? "" : isHtml ? "<font color='lightyellow'>" : ChatColors.LightYellow.ToString())
65+
.Replace("[DARK_RED]", isCenter ? "" : isHtml ? "<font color='darkred'>" : ChatColors.DarkRed.ToString())
66+
.Replace("[DARK_BLUE]", isCenter ? "" : isHtml ? "<font color='darkblue'>" : ChatColors.DarkBlue.ToString())
67+
.Replace("[BLUE_GREY]", isCenter ? "" : isHtml ? "<font color='grey'>" : ChatColors.BlueGrey.ToString())
68+
.Replace("[OLIVE]", isCenter ? "" : isHtml ? "<font color='olive'>" : ChatColors.Olive.ToString())
69+
.Replace("[LIME]", isCenter ? "" : isHtml ? "<font color='lime'>" : ChatColors.Lime.ToString())
70+
.Replace("[GOLD]", isCenter ? "" : isHtml ? "<font color='gold'>" : ChatColors.Gold.ToString())
71+
.Replace("[SILVER]", isCenter ? "" : isHtml ? "<font color='silver'>" : ChatColors.Silver.ToString())
72+
.Replace("[MAGENTA]", isCenter ? "" : isHtml ? "<font color='magenta'>" : ChatColors.Magenta.ToString());
8873
}
8974
}

RetakesPlugin.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace RetakesPlugin;
1717
[MinimumApiVersion(154)]
1818
public class RetakesPlugin : BasePlugin
1919
{
20-
private const string Version = "1.3.28";
20+
private const string Version = "1.3.29";
2121

2222
#region Plugin info
2323
public override string ModuleName => "Retakes Plugin";

0 commit comments

Comments
 (0)