@@ -21,13 +21,21 @@ public IEnumerable<LocalizedString> GetAllStrings(bool includeParentCultures)
21
21
22
22
public string this [ string name , params object [ ] arguments ] => Translate ( name , arguments ) ;
23
23
24
+ private const string CenterModifier = "center." ;
25
+ private const string HtmlModifier = "html." ;
26
+
24
27
private string Translate ( string key , params object [ ] arguments )
25
28
{
26
- var centerModifier = "center." ;
27
- var isCenter = key . StartsWith ( centerModifier ) ;
29
+ var isCenter = key . StartsWith ( CenterModifier ) ;
30
+ var isHtml = key . StartsWith ( HtmlModifier ) ;
31
+
28
32
if ( isCenter )
29
33
{
30
- key = key . Substring ( centerModifier . Length ) ;
34
+ key = key . Substring ( CenterModifier . Length ) ;
35
+ }
36
+ else if ( isHtml )
37
+ {
38
+ key = key . Substring ( HtmlModifier . Length ) ;
31
39
}
32
40
33
41
var localizedString = _stringLocalizerImplementation [ key , arguments ] ;
@@ -40,50 +48,27 @@ private string Translate(string key, params object[] arguments)
40
48
var translation = localizedString . Value ;
41
49
42
50
// 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
-
66
51
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 ( ) ) ;
88
73
}
89
74
}
0 commit comments