Rename Fluent *GetString methods to GetMessage.
This commit is contained in:
@@ -112,15 +112,15 @@ namespace OpenRA
|
||||
}
|
||||
}
|
||||
|
||||
public string GetString(string key, object[] args = null)
|
||||
public string GetMessage(string key, object[] args = null)
|
||||
{
|
||||
if (!TryGetString(key, out var message, args))
|
||||
if (!TryGetMessage(key, out var message, args))
|
||||
message = key;
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
public bool TryGetString(string key, out string value, object[] args = null)
|
||||
public bool TryGetMessage(string key, out string value, object[] args = null)
|
||||
{
|
||||
if (key == null)
|
||||
throw new ArgumentNullException(nameof(key));
|
||||
|
||||
@@ -31,32 +31,32 @@ namespace OpenRA
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetString(string key, params object[] args)
|
||||
public static string GetMessage(string key, params object[] args)
|
||||
{
|
||||
lock (SyncObject)
|
||||
{
|
||||
// By prioritizing mod-level fluent bundles we prevent maps from overwriting string keys. We do not want to
|
||||
// allow maps to change the UI nor any other strings not exposed to the map.
|
||||
if (modFluentBundle.TryGetString(key, out var message, args))
|
||||
if (modFluentBundle.TryGetMessage(key, out var message, args))
|
||||
return message;
|
||||
|
||||
if (mapFluentBundle != null)
|
||||
return mapFluentBundle.GetString(key, args);
|
||||
return mapFluentBundle.GetMessage(key, args);
|
||||
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool TryGetString(string key, out string message, params object[] args)
|
||||
public static bool TryGetMessage(string key, out string message, params object[] args)
|
||||
{
|
||||
lock (SyncObject)
|
||||
{
|
||||
// By prioritizing mod-level bundle we prevent maps from overwriting string keys. We do not want to
|
||||
// allow maps to change the UI nor any other strings not exposed to the map.
|
||||
if (modFluentBundle.TryGetString(key, out message, args))
|
||||
if (modFluentBundle.TryGetMessage(key, out message, args))
|
||||
return true;
|
||||
|
||||
if (mapFluentBundle != null && mapFluentBundle.TryGetString(key, out message, args))
|
||||
if (mapFluentBundle != null && mapFluentBundle.TryGetMessage(key, out message, args))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@@ -64,11 +64,11 @@ namespace OpenRA
|
||||
}
|
||||
|
||||
/// <summary>Should only be used by <see cref="MapPreview"/>.</summary>
|
||||
internal static bool TryGetModString(string key, out string message, params object[] args)
|
||||
internal static bool TryGetModMessage(string key, out string message, params object[] args)
|
||||
{
|
||||
lock (SyncObject)
|
||||
{
|
||||
return modFluentBundle.TryGetString(key, out message, args);
|
||||
return modFluentBundle.TryGetMessage(key, out message, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -595,7 +595,7 @@ namespace OpenRA
|
||||
Log.Write("debug", "Taking screenshot " + path);
|
||||
|
||||
Renderer.SaveScreenshot(path);
|
||||
TextNotificationsManager.Debug(FluentProvider.GetString(SavedScreenshot, "filename", filename));
|
||||
TextNotificationsManager.Debug(FluentProvider.GetMessage(SavedScreenshot, "filename", filename));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -152,8 +152,8 @@ namespace OpenRA
|
||||
if (player.IsBot)
|
||||
{
|
||||
var number = Players.Where(p => p.BotType == player.BotType).ToList().IndexOf(player) + 1;
|
||||
return FluentProvider.GetString(EnumeratedBotName,
|
||||
"name", FluentProvider.GetString(player.Name),
|
||||
return FluentProvider.GetMessage(EnumeratedBotName,
|
||||
"name", FluentProvider.GetMessage(player.Name),
|
||||
"number", number);
|
||||
}
|
||||
|
||||
|
||||
@@ -80,12 +80,12 @@ namespace OpenRA
|
||||
public static string DisplayString(Modifiers m)
|
||||
{
|
||||
if (m == Modifiers.Meta && Platform.CurrentPlatform == PlatformType.OSX)
|
||||
return FluentProvider.GetString(Cmd);
|
||||
return FluentProvider.GetMessage(Cmd);
|
||||
|
||||
if (!ModifierFluentKeys.TryGetValue(m, out var fluentKey))
|
||||
return m.ToString();
|
||||
|
||||
return FluentProvider.GetString(fluentKey);
|
||||
return FluentProvider.GetMessage(fluentKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -507,7 +507,7 @@ namespace OpenRA
|
||||
if (!KeycodeFluentKeys.TryGetValue(k, out var fluentKey))
|
||||
return k.ToString();
|
||||
|
||||
return FluentProvider.GetString(fluentKey);
|
||||
return FluentProvider.GetMessage(fluentKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,8 +57,8 @@ namespace OpenRA
|
||||
public readonly bool Hidden;
|
||||
#pragma warning restore IDE1006 // Naming Styles
|
||||
|
||||
public string TitleTranslated => FluentProvider.GetString(Title);
|
||||
public string WindowTitleTranslated => WindowTitle != null ? FluentProvider.GetString(WindowTitle) : null;
|
||||
public string TitleTranslated => FluentProvider.GetMessage(Title);
|
||||
public string WindowTitleTranslated => WindowTitle != null ? FluentProvider.GetMessage(WindowTitle) : null;
|
||||
}
|
||||
|
||||
/// <summary>Describes what is to be loaded in order to run a mod.</summary>
|
||||
|
||||
@@ -224,16 +224,16 @@ namespace OpenRA
|
||||
public int DownloadPercentage { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Functionality mirrors <see cref="FluentProvider.GetString"/>, except instead of using
|
||||
/// Functionality mirrors <see cref="FluentProvider.GetMessage"/>, except instead of using
|
||||
/// loaded <see cref="Map"/>'s fluent bundle as backup, we use this <see cref="MapPreview"/>'s.
|
||||
/// </summary>
|
||||
public string GetString(string key, object[] args = null)
|
||||
public string GetMessage(string key, object[] args = null)
|
||||
{
|
||||
// PERF: instead of loading mod level strings per each MapPreview, reuse the already loaded one in FluentProvider.
|
||||
if (FluentProvider.TryGetModString(key, out var message, args))
|
||||
if (FluentProvider.TryGetModMessage(key, out var message, args))
|
||||
return message;
|
||||
|
||||
return innerData.FluentBundle?.GetString(key, args) ?? key;
|
||||
return innerData.FluentBundle?.GetMessage(key, args) ?? key;
|
||||
}
|
||||
|
||||
Sprite minimap;
|
||||
|
||||
@@ -238,8 +238,8 @@ namespace OpenRA
|
||||
{
|
||||
var botInfo = botInfos.First(b => b.Type == BotType);
|
||||
var botsOfSameType = World.Players.Where(c => c.BotType == BotType).ToArray();
|
||||
return FluentProvider.GetString(EnumeratedBotName,
|
||||
"name", FluentProvider.GetString(botInfo.Name),
|
||||
return FluentProvider.GetMessage(EnumeratedBotName,
|
||||
"name", FluentProvider.GetMessage(botInfo.Name),
|
||||
"number", botsOfSameType.IndexOf(this) + 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -958,7 +958,7 @@ namespace OpenRA.Server
|
||||
DispatchServerOrdersToClients(Order.FromTargetString("FluentMessage", text, true));
|
||||
|
||||
if (Type == ServerType.Dedicated)
|
||||
WriteLineWithTimeStamp(FluentProvider.GetString(key, args));
|
||||
WriteLineWithTimeStamp(FluentProvider.GetMessage(key, args));
|
||||
}
|
||||
|
||||
public void SendFluentMessageTo(Connection conn, string key, object[] args = null)
|
||||
@@ -1302,7 +1302,7 @@ namespace OpenRA.Server
|
||||
{
|
||||
lock (LobbyInfo)
|
||||
{
|
||||
WriteLineWithTimeStamp(FluentProvider.GetString(GameStarted));
|
||||
WriteLineWithTimeStamp(FluentProvider.GetMessage(GameStarted));
|
||||
|
||||
// Drop any players who are not ready
|
||||
foreach (var c in Conns.Where(c => !c.Validated || GetClient(c).IsInvalid).ToArray())
|
||||
|
||||
@@ -38,12 +38,12 @@ namespace OpenRA
|
||||
return;
|
||||
|
||||
if (player == null || player == player.World.LocalPlayer)
|
||||
AddTextNotification(TextNotificationPool.Transients, SystemClientId, SystemMessageLabel, FluentProvider.GetString(text));
|
||||
AddTextNotification(TextNotificationPool.Transients, SystemClientId, SystemMessageLabel, FluentProvider.GetMessage(text));
|
||||
}
|
||||
|
||||
public static void AddFeedbackLine(string text, params object[] args)
|
||||
{
|
||||
AddTextNotification(TextNotificationPool.Feedback, SystemClientId, SystemMessageLabel, FluentProvider.GetString(text, args));
|
||||
AddTextNotification(TextNotificationPool.Feedback, SystemClientId, SystemMessageLabel, FluentProvider.GetMessage(text, args));
|
||||
}
|
||||
|
||||
public static void AddMissionLine(string prefix, string text, Color? prefixColor = null)
|
||||
@@ -53,17 +53,17 @@ namespace OpenRA
|
||||
|
||||
public static void AddPlayerJoinedLine(string text, params object[] args)
|
||||
{
|
||||
AddTextNotification(TextNotificationPool.Join, SystemClientId, SystemMessageLabel, FluentProvider.GetString(text, args));
|
||||
AddTextNotification(TextNotificationPool.Join, SystemClientId, SystemMessageLabel, FluentProvider.GetMessage(text, args));
|
||||
}
|
||||
|
||||
public static void AddPlayerLeftLine(string text, params object[] args)
|
||||
{
|
||||
AddTextNotification(TextNotificationPool.Leave, SystemClientId, SystemMessageLabel, FluentProvider.GetString(text, args));
|
||||
AddTextNotification(TextNotificationPool.Leave, SystemClientId, SystemMessageLabel, FluentProvider.GetMessage(text, args));
|
||||
}
|
||||
|
||||
public static void AddSystemLine(string text, params object[] args)
|
||||
{
|
||||
AddSystemLine(SystemMessageLabel, FluentProvider.GetString(text, args));
|
||||
AddSystemLine(SystemMessageLabel, FluentProvider.GetMessage(text, args));
|
||||
}
|
||||
|
||||
public static void AddSystemLine(string prefix, string text)
|
||||
|
||||
@@ -586,11 +586,11 @@ namespace OpenRA.Traits
|
||||
IReadOnlyDictionary<string, string> values, string defaultValue, bool locked)
|
||||
{
|
||||
Id = id;
|
||||
Name = map.GetString(name);
|
||||
Description = description != null ? map.GetString(description).Replace(@"\n", "\n") : null;
|
||||
Name = map.GetMessage(name);
|
||||
Description = description != null ? map.GetMessage(description).Replace(@"\n", "\n") : null;
|
||||
IsVisible = visible;
|
||||
DisplayOrder = displayorder;
|
||||
Values = values.ToDictionary(v => v.Key, v => map.GetString(v.Value));
|
||||
Values = values.ToDictionary(v => v.Key, v => map.GetMessage(v.Value));
|
||||
DefaultValue = defaultValue;
|
||||
IsLocked = locked;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user