feat(i18n): translate item kinds and schedule generator messages
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
526294ddeb
commit
2d88d17b22
3 files changed
+11
-13
No files matched your search
@@ -1,14 +1,10 @@
|
|||||||
|
using Radiosender.Services.Localization;
|
||||||
|
|
||||||
namespace Radiosender.Models;
|
namespace Radiosender.Models;
|
||||||
|
|
||||||
public record ScheduleItem(ScheduleItemKind Kind, string Title, DateTime Start, TimeSpan Duration, Song? Song = null)
|
public record ScheduleItem(ScheduleItemKind Kind, string Title, DateTime Start, TimeSpan Duration, Song? Song = null)
|
||||||
{
|
{
|
||||||
public DateTime End => Start + Duration;
|
public DateTime End => Start + Duration;
|
||||||
|
|
||||||
public string KindName => Kind switch
|
public string KindName => Loc.T($"Kind_{Kind}");
|
||||||
{
|
|
||||||
ScheduleItemKind.News => "Nachrichten",
|
|
||||||
ScheduleItemKind.Ad => "Werbung",
|
|
||||||
ScheduleItemKind.Moderator => "Moderation",
|
|
||||||
_ => "Song",
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using Radiosender.Models;
|
using Radiosender.Models;
|
||||||
using Radiosender.Services.Audio;
|
using Radiosender.Services.Audio;
|
||||||
|
using Radiosender.Services.Localization;
|
||||||
|
|
||||||
namespace Radiosender.Services.Scheduling;
|
namespace Radiosender.Services.Scheduling;
|
||||||
|
|
||||||
@@ -203,7 +204,7 @@ public sealed class PlaybackEngine(IAudioPlayer player, Func<TimeSpan, Cancellat
|
|||||||
await timeout.CancelAsync();
|
await timeout.CancelAsync();
|
||||||
token.ThrowIfCancellationRequested();
|
token.ThrowIfCancellationRequested();
|
||||||
if (done == stuck)
|
if (done == stuck)
|
||||||
ItemFailed?.Invoke(this, (item, new TimeoutException($"Der Song wurde nicht rechtzeitig fertig: {item.Title}")));
|
ItemFailed?.Invoke(this, (item, new TimeoutException(Loc.F("Scheduling_SongTimeout", item.Title))));
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Radiosender.Models;
|
using Radiosender.Models;
|
||||||
|
using Radiosender.Services.Localization;
|
||||||
|
|
||||||
namespace Radiosender.Services.Scheduling;
|
namespace Radiosender.Services.Scheduling;
|
||||||
|
|
||||||
@@ -25,7 +26,7 @@ public class ScheduleGenerator(ScheduleOptions options, Random random)
|
|||||||
|
|
||||||
List<Song> playable = [.. songs.Where(s => s.Duration > TimeSpan.Zero)];
|
List<Song> playable = [.. songs.Where(s => s.Duration > TimeSpan.Zero)];
|
||||||
if (playable.Count == 0)
|
if (playable.Count == 0)
|
||||||
throw new ScheduleException("Die Bibliothek enthält keine Songs zum Planen.");
|
throw new ScheduleException(Loc.T("Scheduling_NoSongs"));
|
||||||
|
|
||||||
List<ScheduleItem> items = [];
|
List<ScheduleItem> items = [];
|
||||||
var firstNews = new DateTime((start.Ticks + HalfHour.Ticks - 1) / HalfHour.Ticks * HalfHour.Ticks, start.Kind);
|
var firstNews = new DateTime((start.Ticks + HalfHour.Ticks - 1) / HalfHour.Ticks * HalfHour.Ticks, start.Kind);
|
||||||
@@ -78,7 +79,7 @@ public class ScheduleGenerator(ScheduleOptions options, Random random)
|
|||||||
var (picked, gap) = PickBest(options, length, target, songs);
|
var (picked, gap) = PickBest(options, length, target, songs);
|
||||||
if (picked.Count == 0 && target < length)
|
if (picked.Count == 0 && target < length)
|
||||||
throw new ScheduleException(
|
throw new ScheduleException(
|
||||||
$"Keine Song-Kombination füllt den Abschnitt ab {slotStart:HH:mm} so, dass der letzte Song pünktlich endet. Mehr Songs hinzufügen, vor allem kürzere.");
|
Loc.F("Scheduling_NoCombination", slotStart));
|
||||||
|
|
||||||
var (ads, moderator) = Split(options, gap, adTarget, moderatorTarget);
|
var (ads, moderator) = Split(options, gap, adTarget, moderatorTarget);
|
||||||
return Arrange(options, slotStart, picked, ads, moderator, keepFirstSongFirst: false);
|
return Arrange(options, slotStart, picked, ads, moderator, keepFirstSongFirst: false);
|
||||||
@@ -91,9 +92,9 @@ public class ScheduleGenerator(ScheduleOptions options, Random random)
|
|||||||
ArgumentOutOfRangeException.ThrowIfNegative(index);
|
ArgumentOutOfRangeException.ThrowIfNegative(index);
|
||||||
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(index, plan.Count);
|
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(index, plan.Count);
|
||||||
if (plan[index].Kind == ScheduleItemKind.News)
|
if (plan[index].Kind == ScheduleItemKind.News)
|
||||||
throw new ScheduleException("Nachrichten können nicht ersetzt werden.");
|
throw new ScheduleException(Loc.T("Schedule_NewsNoReplace"));
|
||||||
if (requested.Duration <= TimeSpan.Zero)
|
if (requested.Duration <= TimeSpan.Zero)
|
||||||
throw new ScheduleException("Der gewünschte Song hat keine Dauer.");
|
throw new ScheduleException(Loc.T("Scheduling_NoDuration"));
|
||||||
|
|
||||||
var slotStartIndex = LastIndexOf(plan, index, ScheduleItemKind.News); // -1 if the plan does not start with news
|
var slotStartIndex = LastIndexOf(plan, index, ScheduleItemKind.News); // -1 if the plan does not start with news
|
||||||
var nextNewsIndex = IndexOf(plan, index, ScheduleItemKind.News);
|
var nextNewsIndex = IndexOf(plan, index, ScheduleItemKind.News);
|
||||||
@@ -103,7 +104,7 @@ public class ScheduleGenerator(ScheduleOptions options, Random random)
|
|||||||
|
|
||||||
if (requested.Duration > length)
|
if (requested.Duration > length)
|
||||||
throw new ScheduleException(
|
throw new ScheduleException(
|
||||||
$"\"{requested.Title}\" ({requested.Duration:m\\:ss}) passt nicht vor die Nachrichten um {slotEnd:HH:mm}; es sind nur noch {length:m\\:ss} übrig. Ein früheres Element wählen.");
|
Loc.F("Scheduling_DoesNotFit", requested.Title, requested.Duration, slotEnd, length));
|
||||||
|
|
||||||
// Ads/talk already in this slot count against its targets.
|
// Ads/talk already in this slot count against its targets.
|
||||||
var options = Options;
|
var options = Options;
|
||||||
|
|||||||
Reference in new issue
Block a user