Translate labels with parameters.
This commit is contained in:
committed by
Gustas
parent
474463111f
commit
6e6bf1ca81
@@ -28,7 +28,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
readonly PlayerResources playerResources;
|
||||
readonly LabelWithTooltipWidget cashLabel;
|
||||
readonly CachedTransform<(int Resources, int Capacity), string> siloUsageTooltipCache;
|
||||
readonly string cashTemplate;
|
||||
|
||||
int nextCashTickTime = 0;
|
||||
int displayResources;
|
||||
@@ -47,8 +46,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
TranslationProvider.GetString(SiloUsage, Translation.Arguments("usage", x.Resources, "capacity", x.Capacity)));
|
||||
cashLabel = widget.Get<LabelWithTooltipWidget>("CASH");
|
||||
cashLabel.GetTooltipText = () => siloUsageTooltip;
|
||||
|
||||
cashTemplate = cashLabel.Text;
|
||||
}
|
||||
|
||||
public override void Tick()
|
||||
@@ -80,7 +77,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
|
||||
siloUsageTooltip = siloUsageTooltipCache.Update((playerResources.Resources, playerResources.ResourceCapacity));
|
||||
cashLabel.Text = string.Format(cashTemplate, displayResources);
|
||||
cashLabel.Text = displayResources.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
public class ProductionTooltipLogic : ChromeLogic
|
||||
{
|
||||
[TranslationReference("prequisites")]
|
||||
const string Requires = "label-requires";
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public ProductionTooltipLogic(Widget widget, TooltipContainerWidget tooltipContainer, Player player, Func<ProductionIcon> getTooltipIcon)
|
||||
{
|
||||
@@ -45,7 +48,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var descFont = Game.Renderer.Fonts[descLabel.Font];
|
||||
var requiresFont = Game.Renderer.Fonts[requiresLabel.Font];
|
||||
var formatBuildTime = new CachedTransform<int, string>(time => WidgetUtils.FormatTime(time, world.Timestep));
|
||||
var requiresFormat = requiresLabel.Text;
|
||||
|
||||
ActorInfo lastActor = null;
|
||||
var lastHotkey = Hotkey.Invalid;
|
||||
@@ -100,7 +102,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var requiresSize = int2.Zero;
|
||||
if (prereqs.Any())
|
||||
{
|
||||
requiresLabel.Text = string.Format(requiresFormat, prereqs.JoinWith(", "));
|
||||
requiresLabel.Text = TranslationProvider.GetString(Requires, Translation.Arguments("prequisites", prereqs.JoinWith(", ")));
|
||||
requiresSize = requiresFont.Measure(requiresLabel.Text);
|
||||
requiresLabel.Visible = true;
|
||||
descLabel.Bounds.Y = descLabelY + requiresLabel.Bounds.Height;
|
||||
|
||||
@@ -31,6 +31,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
[TranslationReference("message")]
|
||||
const string NewsParsingFailed = "label-news-parsing-failed";
|
||||
|
||||
[TranslationReference("author", "datetime")]
|
||||
const string AuthorDateTime = "label-author-datetime";
|
||||
|
||||
protected enum MenuType { Main, Singleplayer, Extras, MapEditor, StartupPrompts, None }
|
||||
|
||||
protected enum MenuPanel { None, Missions, Skirmish, Multiplayer, MapEditor, Replays, GameSaves }
|
||||
@@ -425,7 +428,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
titleLabel.GetText = () => item.Title;
|
||||
|
||||
var authorDateTimeLabel = newsItem.Get<LabelWidget>("AUTHOR_DATETIME");
|
||||
var authorDateTime = string.Format(authorDateTimeLabel.Text, item.Author, item.DateTime.ToLocalTime());
|
||||
var authorDateTime = TranslationProvider.GetString(AuthorDateTime, Translation.Arguments(
|
||||
"author", item.Author,
|
||||
"datetime", item.DateTime.ToLocalTime().ToString()));
|
||||
|
||||
authorDateTimeLabel.GetText = () => authorDateTime;
|
||||
|
||||
var contentLabel = newsItem.Get<LabelWidget>("CONTENT");
|
||||
|
||||
@@ -19,6 +19,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
public class HotkeysSettingsLogic : ChromeLogic
|
||||
{
|
||||
[TranslationReference("key")]
|
||||
const string OriginalNotice = "label-original-notice";
|
||||
|
||||
[TranslationReference("key", "context")]
|
||||
const string DuplicateNotice = "label-duplicate-notice";
|
||||
|
||||
readonly ModData modData;
|
||||
readonly Dictionary<string, MiniYaml> logicArgs;
|
||||
|
||||
@@ -220,14 +226,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
duplicateNotice.IsVisible = () => !isHotkeyValid;
|
||||
var duplicateNoticeText = new CachedTransform<HotkeyDefinition, string>(hd =>
|
||||
hd != null ?
|
||||
string.Format(duplicateNotice.Text, hd.Description, hd.Contexts.First(c => selectedHotkeyDefinition.Contexts.Contains(c))) :
|
||||
TranslationProvider.GetString(DuplicateNotice, Translation.Arguments("key", hd.Description,
|
||||
"context", hd.Contexts.First(c => selectedHotkeyDefinition.Contexts.Contains(c)))) :
|
||||
"");
|
||||
duplicateNotice.GetText = () => duplicateNoticeText.Update(duplicateHotkeyDefinition);
|
||||
|
||||
var originalNotice = panel.Get<LabelWidget>("ORIGINAL_NOTICE");
|
||||
originalNotice.TextColor = ChromeMetrics.Get<Color>("NoticeInfoColor");
|
||||
originalNotice.IsVisible = () => isHotkeyValid && !isHotkeyDefault;
|
||||
var originalNoticeText = new CachedTransform<HotkeyDefinition, string>(hd => string.Format(originalNotice.Text, hd?.Default.DisplayString()));
|
||||
var originalNoticeText = new CachedTransform<HotkeyDefinition, string>(hd =>
|
||||
TranslationProvider.GetString(OriginalNotice, Translation.Arguments("key", hd?.Default.DisplayString())));
|
||||
originalNotice.GetText = () => originalNoticeText.Update(selectedHotkeyDefinition);
|
||||
|
||||
var readonlyNotice = panel.Get<LabelWidget>("READONLY_NOTICE");
|
||||
|
||||
@@ -301,7 +301,6 @@ ScrollPanel@NEWS_PANEL:
|
||||
Width: PARENT_RIGHT
|
||||
Height: 15
|
||||
Align: Center
|
||||
Text: by {0} at {1}
|
||||
Font: TinyBold
|
||||
Label@CONTENT:
|
||||
Y: 46
|
||||
|
||||
@@ -1720,7 +1720,6 @@ Container@PLAYER_WIDGETS:
|
||||
Width: 50
|
||||
Height: 22
|
||||
Font: Bold
|
||||
Text: {0}
|
||||
TooltipContainer: TOOLTIP_CONTAINER
|
||||
TooltipTemplate: SIMPLE_TOOLTIP_FACTIONSUFFIX
|
||||
Children:
|
||||
@@ -1737,7 +1736,6 @@ Container@PLAYER_WIDGETS:
|
||||
Height: 22
|
||||
Align: Right
|
||||
Font: Bold
|
||||
Text: {0}
|
||||
TooltipContainer: TOOLTIP_CONTAINER
|
||||
TooltipTemplate: SIMPLE_TOOLTIP_FACTIONSUFFIX
|
||||
Children:
|
||||
|
||||
@@ -125,12 +125,10 @@ Container@HOTKEYS_PANEL:
|
||||
Width: PARENT_RIGHT
|
||||
Height: PARENT_BOTTOM
|
||||
Font: Tiny
|
||||
Text: The default is "{0}"
|
||||
Label@DUPLICATE_NOTICE:
|
||||
Width: PARENT_RIGHT
|
||||
Height: PARENT_BOTTOM
|
||||
Font: Tiny
|
||||
Text: This is already used for "{0}" in the {1} context
|
||||
Label@READONLY_NOTICE:
|
||||
Width: PARENT_RIGHT
|
||||
Height: PARENT_BOTTOM
|
||||
|
||||
@@ -200,7 +200,6 @@ Background@PRODUCTION_TOOLTIP:
|
||||
Y: 20
|
||||
Height: 15
|
||||
Font: TinyBold
|
||||
Text: Requires {0}
|
||||
Label@DESC:
|
||||
X: 5
|
||||
Y: 20
|
||||
@@ -262,7 +261,6 @@ Background@PRODUCTION_TOOLTIP_FACTIONSUFFIX:
|
||||
Y: 20
|
||||
Height: 15
|
||||
Font: TinyBold
|
||||
Text: Requires {0}
|
||||
Label@DESC:
|
||||
X: 5
|
||||
Y: 20
|
||||
|
||||
@@ -18,7 +18,6 @@ Background@CONNECTIONFAILED_PANEL:
|
||||
Y: 46
|
||||
Width: PARENT_RIGHT
|
||||
Height: 25
|
||||
Text: Could not connect to AAA.BBB.CCC.DDD:EEEE
|
||||
Align: Center
|
||||
Label@CONNECTION_ERROR:
|
||||
X: 0
|
||||
@@ -85,7 +84,6 @@ Background@CONNECTING_PANEL:
|
||||
Y: 61
|
||||
Width: PARENT_RIGHT
|
||||
Height: 25
|
||||
Text: Connecting to AAA.BBB.CCC.DDD:EEEE...
|
||||
Align: Center
|
||||
Button@ABORT_BUTTON:
|
||||
X: PARENT_RIGHT - 180
|
||||
|
||||
@@ -171,7 +171,6 @@ ScrollPanel@NEWS_PANEL:
|
||||
Width: PARENT_RIGHT
|
||||
Height: 15
|
||||
Align: Center
|
||||
Text: by {0} at {1}
|
||||
Font: TinyBold
|
||||
Label@CONTENT:
|
||||
Y: 45
|
||||
|
||||
@@ -125,12 +125,10 @@ Container@HOTKEYS_PANEL:
|
||||
Width: PARENT_RIGHT
|
||||
Height: PARENT_BOTTOM
|
||||
Font: Tiny
|
||||
Text: The default is "{0}"
|
||||
Label@DUPLICATE_NOTICE:
|
||||
Width: PARENT_RIGHT
|
||||
Height: PARENT_BOTTOM
|
||||
Font: Tiny
|
||||
Text: This is already used for "{0}" in the {1} context
|
||||
Label@READONLY_NOTICE:
|
||||
Width: PARENT_RIGHT
|
||||
Height: PARENT_BOTTOM
|
||||
|
||||
@@ -254,7 +254,6 @@ Background@PRODUCTION_TOOLTIP:
|
||||
Y: 26
|
||||
Height: 15
|
||||
Font: TinyBold
|
||||
Text: Requires {0}
|
||||
Label@DESC:
|
||||
X: 7
|
||||
Y: 27
|
||||
|
||||
@@ -351,6 +351,10 @@ options-target-lines =
|
||||
.manual = Manual
|
||||
.disabled = Disabled
|
||||
|
||||
## HotkeysSettingsLogic
|
||||
label-original-notice = The default is "{ $key }"
|
||||
label-duplicate-notice = This is already used for "{ $key }" in the { $context } context
|
||||
|
||||
## InputSettingsLogic
|
||||
options-mouse-scroll-type =
|
||||
.disabled = Disabled
|
||||
@@ -434,6 +438,7 @@ dialog-overwrite-save =
|
||||
label-loading-news = Loading news
|
||||
label-news-retrieval-failed = Failed to retrieve news: { $message }
|
||||
label-news-parsing-failed = Failed to parse news: { $message }
|
||||
label-author-datetime = by { $author } at { $datetime }
|
||||
|
||||
## MapChooserLogic
|
||||
label-all-maps = All Maps
|
||||
@@ -488,6 +493,9 @@ label-audio-unmuted = Audio unmuted.
|
||||
label-loading-player-profile = Loading player profile...
|
||||
label-loading-player-profile-failed = Failed to load player profile.
|
||||
|
||||
## ProductionTooltipLogic
|
||||
label-requires = Requires { $prequisites }
|
||||
|
||||
## ReplayBrowserLogic
|
||||
label-duration = Duration: { $time }
|
||||
|
||||
|
||||
@@ -135,7 +135,6 @@ ScrollPanel@NEWS_PANEL:
|
||||
Width: PARENT_RIGHT
|
||||
Height: 15
|
||||
Align: Center
|
||||
Text: by {0} at {1}
|
||||
Font: TinyBold
|
||||
Label@CONTENT:
|
||||
Y: 45
|
||||
|
||||
@@ -446,7 +446,6 @@ Container@PLAYER_WIDGETS:
|
||||
Width: 50
|
||||
Height: 22
|
||||
Font: Bold
|
||||
Text: {0}
|
||||
TooltipContainer: TOOLTIP_CONTAINER
|
||||
TooltipTemplate: SIMPLE_TOOLTIP
|
||||
LabelWithTooltip@POWER:
|
||||
@@ -457,7 +456,6 @@ Container@PLAYER_WIDGETS:
|
||||
Height: 22
|
||||
Align: Right
|
||||
Font: Bold
|
||||
Text: {0}
|
||||
TooltipContainer: TOOLTIP_CONTAINER
|
||||
TooltipTemplate: SIMPLE_TOOLTIP
|
||||
Children:
|
||||
|
||||
@@ -256,7 +256,6 @@ Background@PRODUCTION_TOOLTIP:
|
||||
Y: 22
|
||||
Height: 15
|
||||
Font: TinyBold
|
||||
Text: Requires {0}
|
||||
Label@DESC:
|
||||
X: 7
|
||||
Y: 23
|
||||
|
||||
@@ -623,7 +623,6 @@ Container@PLAYER_WIDGETS:
|
||||
Width: 50
|
||||
Height: 23
|
||||
Font: Bold
|
||||
Text: {0}
|
||||
TooltipContainer: TOOLTIP_CONTAINER
|
||||
TooltipTemplate: SIMPLE_TOOLTIP
|
||||
Children:
|
||||
@@ -640,7 +639,6 @@ Container@PLAYER_WIDGETS:
|
||||
Height: 23
|
||||
Align: Right
|
||||
Font: Bold
|
||||
Text: {0}
|
||||
TooltipContainer: TOOLTIP_CONTAINER
|
||||
TooltipTemplate: SIMPLE_TOOLTIP
|
||||
Children:
|
||||
|
||||
@@ -135,7 +135,6 @@ ScrollPanel@NEWS_PANEL:
|
||||
Width: PARENT_RIGHT
|
||||
Height: 15
|
||||
Align: Center
|
||||
Text: by {0} at {1}
|
||||
Font: TinyBold
|
||||
Label@CONTENT:
|
||||
Y: 45
|
||||
|
||||
@@ -441,7 +441,6 @@ Container@PLAYER_WIDGETS:
|
||||
Width: 50
|
||||
Height: 22
|
||||
Font: Bold
|
||||
Text: {0}
|
||||
TooltipContainer: TOOLTIP_CONTAINER
|
||||
TooltipTemplate: SIMPLE_TOOLTIP
|
||||
Children:
|
||||
@@ -458,7 +457,6 @@ Container@PLAYER_WIDGETS:
|
||||
Height: 22
|
||||
Align: Right
|
||||
Font: Bold
|
||||
Text: {0}
|
||||
TooltipContainer: TOOLTIP_CONTAINER
|
||||
TooltipTemplate: SIMPLE_TOOLTIP
|
||||
Children:
|
||||
|
||||
@@ -127,12 +127,10 @@ Container@HOTKEYS_PANEL:
|
||||
Width: PARENT_RIGHT
|
||||
Height: PARENT_BOTTOM
|
||||
Font: Tiny
|
||||
Text: The default is "{0}"
|
||||
Label@DUPLICATE_NOTICE:
|
||||
Width: PARENT_RIGHT
|
||||
Height: PARENT_BOTTOM
|
||||
Font: Tiny
|
||||
Text: This is already used for "{0}" in the {1} context
|
||||
Label@READONLY_NOTICE:
|
||||
Width: PARENT_RIGHT
|
||||
Height: PARENT_BOTTOM
|
||||
|
||||
Reference in New Issue
Block a user