Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Trdo.Tests/LocalizedTextCultureTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Globalization;
using Trdo.Services;

namespace Trdo.Tests;

[TestClass]
public sealed class LocalizedTextCultureTests
{
[TestMethod]
[DataRow("en-US")]
[DataRow("ru-RU")]
[DataRow("uk-UA")]
[DataRow("de-DE")]
public void EnglishFallback_PreservesDurationTextAcrossSystemCultures(string cultureName)
{
CultureInfo previousCulture = CultureInfo.CurrentCulture;
try
{
CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo(cultureName);

Assert.AreEqual("2.5 seconds", SongChangeAnnouncementPolicy.DescribeDelay(2.5));
Assert.AreEqual("2.5 seconds", SongChangeAnnouncementPolicy.DescribeDwell(2.5));
}
finally
{
CultureInfo.CurrentCulture = previousCulture;
}
}
}
1 change: 1 addition & 0 deletions Trdo.Tests/Trdo.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
ApplicationData, DispatcherQueue or a media player does not belong here.
-->
<ItemGroup>
<Compile Include="..\Trdo\Services\LocalizedText.cs" Link="Services\LocalizedText.cs" />
<Compile Include="..\Trdo\Services\Playback\RecoveryPolicy.cs" Link="Playback\RecoveryPolicy.cs" />
<Compile Include="..\Trdo\Services\Playback\EngineHealthStore.cs" Link="Playback\EngineHealthStore.cs" />
<Compile Include="..\Trdo\Services\Playback\PlaybackBackendKind.cs" Link="Playback\PlaybackBackendKind.cs" />
Expand Down
4 changes: 3 additions & 1 deletion Trdo/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public partial class App : Application
/// therefore has to ask "has this track been shown?", not "is this track new?".
/// </summary>
private string? _lastAnnouncedDisplayText;
private readonly PlayerViewModel _playerVm = PlayerViewModel.Shared;
private readonly PlayerViewModel _playerVm;
private readonly UISettings _uiSettings = new();
private Mutex? _singleInstanceMutex;
private EventWaitHandle? _trayIconRestoreEvent;
Expand Down Expand Up @@ -94,6 +94,8 @@ public App()
TaskScheduler.UnobservedTaskException += OnUnobservedTaskException;

LocalizationService.ApplyLanguage(SettingsService.AppLanguage);
// Build saved grouped views only after the resource resolver is ready.
_playerVm = PlayerViewModel.Shared;
SettingsService.MigrateTrayClickActions();
InitializeComponent();
_playerVm.PropertyChanged += PlayerVmOnPropertyChanged;
Expand Down
4 changes: 2 additions & 2 deletions Trdo/Controls/AddLocalMusicWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@
<StackPanel Spacing="4">
<TextBlock x:Uid="AddLocalMusic_VolumeLabel" FontWeight="SemiBold" />
<Grid ColumnDefinitions="*,Auto" ColumnSpacing="12">
<Slider
<Slider x:Uid="Ui_AddLocalMusicWindow_b10fb966d7"
Grid.Column="0"
AutomationProperties.Name="Volume"

Maximum="200"
Minimum="0"
StepFrequency="1"
Expand Down
16 changes: 8 additions & 8 deletions Trdo/Controls/ManualStationWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@
Style="{StaticResource CaptionTextBlockStyle}"
TextWrapping="Wrap" />
<Grid ColumnDefinitions="*,Auto" ColumnSpacing="12">
<Slider
<Slider x:Uid="Ui_ManualStationWindow_25007918d8"
Grid.Column="0"
AutomationProperties.Name="Station volume"

Maximum="200"
Minimum="0"
StepFrequency="1"
Expand All @@ -149,9 +149,9 @@
Margin="0,4,0,0"
IsOn="{x:Bind ViewModel.HasBufferOverride, Mode=TwoWay}" />
<Grid ColumnDefinitions="*,Auto" ColumnSpacing="12">
<Slider
<Slider x:Uid="Ui_ManualStationWindow_8cd98d3873"
Grid.Column="0"
AutomationProperties.Name="Station buffer level"

IsEnabled="{x:Bind ViewModel.HasBufferOverride, Mode=OneWay}"
Maximum="3"
Minimum="0"
Expand Down Expand Up @@ -179,9 +179,9 @@
Margin="0,4,0,0"
IsOn="{x:Bind ViewModel.HasSongPopupDelayOverride, Mode=TwoWay}" />
<Grid ColumnDefinitions="*,Auto" ColumnSpacing="12">
<Slider
<Slider x:Uid="Ui_ManualStationWindow_7a2aa4f240"
Grid.Column="0"
AutomationProperties.Name="Station track info delay in seconds"

IsEnabled="{x:Bind ViewModel.HasSongPopupDelayOverride, Mode=OneWay}"
Maximum="{x:Bind ViewModel.MaxSongPopupDelaySeconds}"
Minimum="0"
Expand Down Expand Up @@ -221,7 +221,7 @@
Click="CancelButton_Click">
<StackPanel Orientation="Horizontal" Spacing="8">
<FontIcon FontSize="16" Glyph="&#xE711;" />
<TextBlock Text="Cancel" />
<TextBlock x:Uid="Ui_ManualStationWindow_19766ed6cc" />
</StackPanel>
</Button>

Expand All @@ -233,7 +233,7 @@
Style="{StaticResource AccentButtonStyle}">
<StackPanel Orientation="Horizontal" Spacing="8">
<FontIcon FontSize="16" Glyph="&#xE74E;" />
<TextBlock Text="Save" />
<TextBlock x:Uid="Ui_ManualStationWindow_1509f561f2" />
</StackPanel>
</Button>
</Grid>
Expand Down
14 changes: 7 additions & 7 deletions Trdo/Controls/MiniPlayerWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:ex="using:WinUIEx"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="Traydio Mini Player"

Width="320"
Height="220"
IsMaximizable="False"
Expand Down Expand Up @@ -44,20 +44,20 @@
PointerReleased="ContentCard_PointerReleased">
<Grid.ContextFlyout>
<MenuFlyout>
<ToggleMenuFlyoutItem
<ToggleMenuFlyoutItem x:Uid="Ui_MiniPlayerWindow_4b851eb47c"
x:Name="VisualizerToggleMenuItem"
Click="VisualizerToggleMenuItem_Click"
IsChecked="True"
Text="Show Visualizer" />
<ToggleMenuFlyoutItem
/>
<ToggleMenuFlyoutItem x:Uid="Ui_MiniPlayerWindow_25b01bd53e"
x:Name="TopmostToggleMenuItem"
Click="TopmostToggleMenuItem_Click"
IsChecked="True"
Text="Always on Top" />
<ToggleMenuFlyoutItem
/>
<ToggleMenuFlyoutItem x:Uid="Ui_MiniPlayerWindow_6a0a9f4059"
x:Name="HideTitleBarToggleMenuItem"
Click="HideTitleBarToggleMenuItem_Click"
Text="Hide Title Bar" />
/>
</MenuFlyout>
</Grid.ContextFlyout>
<Border
Expand Down
1 change: 1 addition & 0 deletions Trdo/Controls/MiniPlayerWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public sealed partial class MiniPlayerWindow : WindowEx
public MiniPlayerWindow()
{
InitializeComponent();
Title = LocalizationService.GetString("Ui_MiniPlayerWindow_021543a6dc/Title", "Traydio Mini Player");

ViewModel = PlayerViewModel.Shared;
ExtendsContentIntoTitleBar = true;
Expand Down
12 changes: 6 additions & 6 deletions Trdo/Controls/SongChangePopupWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public void ShowSongChange(string displayText)
EnsureConfigured();

SongText.Text = displayText;
AutomationProperties.SetName(RootGrid, $"Now playing: {displayText}");
AutomationProperties.SetName(RootGrid, LocalizedText.Format("Ui_SongChangePopupWindow_xaml_38baf87674", "Now playing: {0}", displayText));

// Same art PlayingPage/NowPlayingPage show - track art if the source has one, else the
// station's own favicon/cover - and the same per-source-kind glyph behind it while that
Expand Down Expand Up @@ -287,8 +287,8 @@ private MenuFlyout BuildDelayMenu()
double effective = SongChangeAnnouncementPolicy.ResolveDelaySeconds(stationDelay, globalDelay);

string header = station is null
? "Track info delay"
: $"Track info delay for {station.Name}";
? LocalizedText.Get("Ui_SongChangePopupWindow_xaml_1e55749b3e", "Track info delay")
: LocalizedText.Format("Ui_SongChangePopupWindow_xaml_f51a37acea", "Track info delay for {0}", station.Name);

flyout.Items.Add(new MenuFlyoutItem
{
Expand All @@ -313,7 +313,7 @@ private MenuFlyout BuildDelayMenu()

ToggleMenuFlyoutItem followApp = new()
{
Text = $"Use app setting ({SongChangeAnnouncementPolicy.DescribeDelay(globalDelay)})",
Text = LocalizedText.Format("Ui_SongChangePopupWindow_xaml_5733d6a9e0", "Use app setting ({0})", SongChangeAnnouncementPolicy.DescribeDelay(globalDelay)),
IsChecked = stationDelay is null
};
followApp.Click += (_, _) => ApplyStationDelay(station, null);
Expand All @@ -325,12 +325,12 @@ private MenuFlyout BuildDelayMenu()
{
flyout.Items.Add(new MenuFlyoutItem
{
Text = $"Currently {SongChangeAnnouncementPolicy.DescribeDelay(effective)} (no station selected)",
Text = LocalizedText.Format("Ui_SongChangePopupWindow_xaml_a133d8ce0e", "Currently {0} (no station selected)", SongChangeAnnouncementPolicy.DescribeDelay(effective)),
IsEnabled = false
});
}

MenuFlyoutItem turnOff = new() { Text = "Turn off song popups" };
MenuFlyoutItem turnOff = new() { Text = LocalizedText.Get("Ui_SongChangePopupWindow_xaml_16a1d60039", "Turn off song popups") };
turnOff.Click += (_, _) =>
{
SettingsService.IsSongChangePopupEnabled = false;
Expand Down
3 changes: 2 additions & 1 deletion Trdo/Models/FavoriteTrack.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Trdo.Services;
using System;
using System.Text.Json.Serialization;

Expand Down Expand Up @@ -55,7 +56,7 @@ public class FavoriteTrack
/// </summary>
[JsonIgnore]
public string ExportedOnDisplay => ExportedAt is DateTime exportedAt
? $"Exported on {exportedAt:MMM d, yyyy h:mm tt}"
? LocalizedText.Format("Ui_FavoriteTrack_73edcbce18", "Exported on {0:MMM d, yyyy h:mm tt}", exportedAt)
: string.Empty;

/// <summary>
Expand Down
9 changes: 5 additions & 4 deletions Trdo/Models/StationFilterOption.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Trdo.Services;
namespace Trdo.Models;

/// <summary>
Expand Down Expand Up @@ -37,13 +38,13 @@ public sealed record StationFilterOption(StationFilterFacet Facet, string Value,
/// <summary>Short badge text identifying which attribute this narrows.</summary>
public string FacetLabel => Facet switch
{
StationFilterFacet.Country => "Country",
StationFilterFacet.Language => "Language",
_ => "Genre"
StationFilterFacet.Country => LocalizedText.Get("Ui_StationFilterOption_701d021d08", "Country"),
StationFilterFacet.Language => LocalizedText.Get("Ui_StationFilterOption_a4fe65264e", "Language"),
_ => LocalizedText.Get("Ui_StationFilterOption_6da795a866", "Genre")
};

/// <summary>The station count, formatted for the suggestion row's trailing column.</summary>
public string CountLabel => StationCount == 1 ? "1 station" : $"{StationCount:N0} stations";
public string CountLabel => StationCount == 1 ? LocalizedText.Get("Ui_StationFilterOption_85993e22a3", "1 station") : LocalizedText.Format("Ui_StationFilterOption_d088bdf306", "{0:N0} stations", StationCount);

/// <summary>Chip text: the value alone would be ambiguous once several facets are in play.</summary>
public string ChipLabel => $"{FacetLabel}: {Value}";
Expand Down
4 changes: 2 additions & 2 deletions Trdo/Pages/AddWhiteNoise.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
<StackPanel Spacing="4">
<TextBlock x:Uid="AddWhiteNoise_VolumeLabel" FontWeight="SemiBold" />
<Grid ColumnDefinitions="*,Auto" ColumnSpacing="12">
<Slider
<Slider x:Uid="Ui_AddWhiteNoise_b10fb966d7"
Grid.Column="0"
AutomationProperties.Name="Volume"

Maximum="200"
Minimum="0"
StepFrequency="1"
Expand Down
10 changes: 5 additions & 5 deletions Trdo/Pages/FavoritesPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@
</Button>
<Button
x:Uid="FavoritesPage_Options"
AutomationProperties.Name="More favorites options"

Padding="8">
<FontIcon FontSize="14" Glyph="&#xE712;" />
<Button.Flyout>
<MenuFlyout>
<MenuFlyoutItem
<MenuFlyoutItem x:Uid="Ui_FavoritesPage_483e617f50"
Click="ClearExportHistory_Click"
IsEnabled="{x:Bind ViewModel.HasArchivedFavorites, Mode=OneWay}"
Text="Clear export history">
>
<MenuFlyoutItem.Icon>
<FontIcon Glyph="&#xE7A7;" />
</MenuFlyoutItem.Icon>
Expand Down Expand Up @@ -319,7 +319,7 @@
</ScrollViewer>
</Border>

<Button
<Button x:Uid="Ui_FavoritesPage_e64193c5b7"
Grid.Column="1"
Padding="8"
VerticalAlignment="Center"
Expand All @@ -328,7 +328,7 @@
Click="SettingsButton_Click"
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
Tag="{x:Bind}"
ToolTipService.ToolTip="Music search settings">
>
<FontIcon FontSize="14" Glyph="&#xE713;" />
</Button>
</Grid>
Expand Down
Loading