1+ using System ;
2+ using Rocket . API . Chat ;
3+ using Rocket . API . Commands ;
4+ using Rocket . API . I18N ;
5+ using Rocket . API . Player ;
6+
7+ namespace Rocket . Core . Permissions
8+ {
9+ public static class LocalizationExtensions
10+ {
11+ /// <summary>
12+ /// Sends a localized (translatable) message to the command caller.
13+ /// </summary>
14+ /// <param name="commandCaller">The message receiver.</param>
15+ /// <param name="translations">The translations source.</param>
16+ /// <param name="translationKey">The translation key.</param>
17+ /// <param name="color">The color of the message. Depending on the caller implementation, it may not be used.</param>
18+ /// <param name="bindings">The bindings for the message. See <see cref="string.Format(string, object[])"/></param>
19+ public static void SendLocalizedMessage ( this ICommandCaller commandCaller , ITranslationLocator translations , string translationKey ,
20+ ConsoleColor ? color = null , params object [ ] bindings )
21+ {
22+ commandCaller . SendMessage ( translations . GetLocalizedMessage ( translationKey , bindings ) , color ) ;
23+ }
24+
25+ /// <summary>
26+ /// Sends a localized message to the given player
27+ /// </summary>
28+ /// <param name="chatManager">The chat manager.</param>
29+ /// <param name="translationSource">The translation source</param>
30+ /// <param name="player">The receiver of the message</param>
31+ /// <param name="translationKey">The translation key.</param>
32+ /// <param name="bindings">The bindings for the message</param>
33+ public static void SendLocalizedMessage ( this IChatManager chatManager , ITranslationLocator translations ,
34+ IOnlinePlayer player , string translationKey , params object [ ] bindings )
35+ {
36+ chatManager . SendMessage ( player , translations . GetLocalizedMessage ( translationKey , bindings ) ) ;
37+ }
38+
39+
40+
41+ /// <summary>
42+ /// Broadcasts a localized message to all players
43+ /// </summary>
44+ /// <param name="chatManager">The chat manager.</param>
45+ /// <param name="translations">The translation soruce</param>
46+ /// <param name="translationKey">The key of the translated message to send</param>
47+ /// <param name="bindings">The bindings for the message</param>
48+ public static void BroadcastLocalized ( this IChatManager chatManager , ITranslationLocator translations ,
49+ string translationKey , params object [ ] bindings )
50+ {
51+ chatManager . Broadcast ( translations . GetLocalizedMessage ( translationKey , bindings ) ) ;
52+ }
53+ }
54+ }
0 commit comments