Extract translation strings.

This commit is contained in:
Matthias Mailänder
2022-08-29 20:56:25 +02:00
committed by Gustas
parent dfd5a960ed
commit 0b67b5bfae
42 changed files with 1819 additions and 410 deletions

View File

@@ -60,6 +60,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
float spriteScale;
float modelScale;
[TranslationReference("length")]
static readonly string LengthInSeconds = "length-in-seconds";
[TranslationReference]
static readonly string AllPackages = "all-packages";
readonly string allPackages;
[ObjectCreator.UseCtor]
public AssetBrowserLogic(Widget widget, Action onExit, ModData modData, WorldRenderer worldRenderer)
{
@@ -67,6 +75,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
this.modData = modData;
panel = widget;
allPackages = modData.Translation.GetString(AllPackages);
var colorPickerPalettes = world.WorldActor.TraitsImplementing<IProvidesAssetBrowserColorPickerPalettes>()
.SelectMany(p => p.ColorPickerPaletteNames)
.ToArray();
@@ -194,13 +204,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var frameText = panel.GetOrNull<LabelWidget>("FRAME_COUNT");
if (frameText != null)
{
var soundLength = new CachedTransform<int, string>(p =>
modData.Translation.GetString(LengthInSeconds, Translation.Arguments("length", p)));
frameText.GetText = () =>
{
if (isVideoLoaded)
return $"{player.Video.CurrentFrameIndex + 1} / {player.Video.FrameCount}";
if (currentSoundFormat != null)
return $"{Math.Round(currentSoundFormat.LengthInSeconds, 3)} sec";
return soundLength.Update((int)currentSoundFormat.LengthInSeconds);
return $"{currentFrame} / {currentSprites.Length - 1}";
};
@@ -607,7 +619,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
string GetSourceDisplayName(IReadOnlyPackage source)
{
if (source == null)
return "All Packages";
return allPackages;
// Packages that are explicitly mounted in the filesystem use their explicit mount name
var fs = (OpenRA.FileSystem.FileSystem)modData.DefaultFileSystem;