Compare commits
1
Commits
main
...
beta15/pr1-lists
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c51cf3d0d |
No files matched your search
@@ -28,6 +28,12 @@ numeric core and does not move; the heading is the full version — corrected 20
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Fixed
|
||||
|
||||
- **After a change of language some text stayed in the old one** until FrameLedger restarted: the theme and update-channel
|
||||
lists in Settings, the log and level lists on the Logs page, the sort order on the Games page, the tray icon's menu and
|
||||
the Agent's status in the title bar. They follow the language at once now.
|
||||
|
||||
## [0.1.0-beta.14] - 2026-10-06
|
||||
|
||||
**The fourteenth pre-release: a wheel that scrolls, updates that find this channel and wait for your games, crashes told
|
||||
|
||||
@@ -17,6 +17,12 @@ Languages: **en** (neutral/default) · **vi** · **ja**. Same `.resx` pattern as
|
||||
- One `Strings.resx` (+ `Strings.vi.resx`, `Strings.ja.resx`) per assembly that has user-visible text (`App`, `Shared` ~~for error codes~~ for the safety family, the `Safety_*` keys — corrected 2026-10-04). Access through a generated strongly-typed class; **no string literals in XAML/C# for user-visible text** (analyzer TODO: Meziantou MA0011/manual review in PR checklist). **As built (P3 PR-2, 2026-09-13):** the class is `Strings.Designer.cs`, written by `tools/resx-gen.ps1 -Resx <file>` and **committed** — not the SDK's `ResXFileCodeGenerator`, which the SDK-style WPF project does not run — with `Culture`, `ResourceManager`, `Keys`, and one property per key; the audit below fails when it is stale. The first family is `src/FrameLedger.App/Strings.resx` (65 keys); `Shared`'s arrives with PR-4's `Safety_*` text, because an empty family is what the audit refuses.
|
||||
- XAML binding via `{x:Static res:Strings.Key}` ~~plus a `LocalizeExtension` for the few dynamic cases~~ *(corrected 2026-10-04: no `LocalizeExtension` exists; text that varies is composed in the view model from `Strings.*`)*.
|
||||
- **Runtime switching:** setting change → set `CultureInfo.CurrentUICulture` + `Thread` defaults → re-create the main window shell (cheap; state preserved via VM). Persist in `settings`.
|
||||
**Two kinds of text did not follow, until beta.15:** a list of choices built once in a static (Settings' themes and update
|
||||
channels, the Logs page's two lists, the Games page's sort order — `x:Static` read the list built in the language the
|
||||
App started in), and the singletons that outlive the rebuilt window (the tray's menu, the title bar's Agent pill and the
|
||||
update banner). The lists are per page now, bound through the view model; the singletons implement
|
||||
`ILanguageFollower`, which `ShellHost.Rebuild` calls once the new window is up. `LanguageFollowingTests` refuses a new
|
||||
static list of labelled choices — the language list, each language in its own words, is the one exception.
|
||||
- `SatelliteResourceLanguages` = `en;vi;ja` in ~~the App csproj~~ `Directory.Build.props` (corrected 2026-10-04) to keep publish size down.
|
||||
|
||||
## Key conventions
|
||||
|
||||
@@ -291,14 +291,7 @@ public partial class App : System.Windows.Application
|
||||
|
||||
AddLibrary(builder.Services);
|
||||
|
||||
// The shell: the window is TRANSIENT because a language change rebuilds it (09_I18N §Mechanics); the
|
||||
// shell host tracks the live one. Pages and their view models are transient (16 §Navigation).
|
||||
builder.Services.AddSingleton<ShellHost>();
|
||||
builder.Services.AddSingleton<IShellPresence>(static sp => sp.GetRequiredService<ShellHost>());
|
||||
builder.Services.AddSingleton<TrayViewModel>();
|
||||
builder.Services.AddSingleton<TrayHost>();
|
||||
builder.Services.AddTransient<MainWindow>();
|
||||
builder.Services.AddSingleton<MainWindowViewModel>();
|
||||
AddShell(builder.Services);
|
||||
builder.Services.AddTransient<DashboardPage>();
|
||||
builder.Services.AddTransient<DashboardViewModel>();
|
||||
builder.Services.AddTransient<GamesPage>();
|
||||
@@ -315,6 +308,23 @@ public partial class App : System.Windows.Application
|
||||
return builder.Build();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The shell: the window is TRANSIENT because a language change rebuilds it (09_I18N §Mechanics); the shell host tracks
|
||||
/// the live one. Pages and their view models are transient (16 §Navigation). The singletons that wrote their text once
|
||||
/// read it again after a change of language (beta.15, <see cref="ILanguageFollower"/>, called by ShellHost.Rebuild).
|
||||
/// </summary>
|
||||
private static void AddShell(IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<ShellHost>();
|
||||
services.AddSingleton<IShellPresence>(static sp => sp.GetRequiredService<ShellHost>());
|
||||
services.AddSingleton<TrayViewModel>();
|
||||
services.AddSingleton<TrayHost>();
|
||||
services.AddTransient<MainWindow>();
|
||||
services.AddSingleton<MainWindowViewModel>();
|
||||
services.AddSingleton<ILanguageFollower>(static sp => sp.GetRequiredService<TrayHost>());
|
||||
services.AddSingleton<ILanguageFollower>(static sp => sp.GetRequiredService<MainWindowViewModel>());
|
||||
}
|
||||
|
||||
/// <summary>The Agent over the pipe (07_IPC §Client behavior): connect, start it when it is not there, tell the shell.</summary>
|
||||
private static void AddAgentLink(IServiceCollection services)
|
||||
{
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
<ComboBox Grid.Column="2" MinWidth="150" Margin="0,0,12,0" VerticalAlignment="Center"
|
||||
AutomationProperties.Name="{x:Static res:Strings.A11y_Games_Sort}"
|
||||
DisplayMemberPath="Label"
|
||||
ItemsSource="{x:Static vm:GamesViewModel.Sorts}"
|
||||
ItemsSource="{Binding ViewModel.Sorts}"
|
||||
SelectedValue="{Binding ViewModel.Sort, Mode=TwoWay}"
|
||||
SelectedValuePath="Value" />
|
||||
<!-- The view switch: the one button shown is the other view. -->
|
||||
|
||||
@@ -25,14 +25,14 @@
|
||||
Margin="0,0,8,4"
|
||||
AutomationProperties.Name="{x:Static res:Strings.A11y_Logs_Source}"
|
||||
DisplayMemberPath="Label"
|
||||
ItemsSource="{x:Static vm:LogsViewModel.Sources}"
|
||||
ItemsSource="{Binding ViewModel.Sources}"
|
||||
SelectedValue="{Binding ViewModel.Source, Mode=TwoWay}"
|
||||
SelectedValuePath="Value" />
|
||||
<ComboBox MinWidth="170"
|
||||
Margin="0,0,8,4"
|
||||
AutomationProperties.Name="{x:Static res:Strings.A11y_Logs_Level}"
|
||||
DisplayMemberPath="Label"
|
||||
ItemsSource="{x:Static vm:LogsViewModel.Levels}"
|
||||
ItemsSource="{Binding ViewModel.Levels}"
|
||||
SelectedValue="{Binding ViewModel.Level, Mode=TwoWay}"
|
||||
SelectedValuePath="Value" />
|
||||
<ui:TextBox MinWidth="220"
|
||||
|
||||
@@ -268,7 +268,7 @@
|
||||
<ComboBox MinWidth="180"
|
||||
AutomationProperties.Name="{x:Static vm:SettingsViewModel.ThemeLabel}"
|
||||
DisplayMemberPath="Label"
|
||||
ItemsSource="{x:Static vm:SettingsViewModel.Themes}"
|
||||
ItemsSource="{Binding ViewModel.Themes}"
|
||||
SelectedValue="{Binding ViewModel.SelectedTheme, Mode=TwoWay}"
|
||||
SelectedValuePath="Value" />
|
||||
</ui:CardControl>
|
||||
@@ -340,7 +340,7 @@
|
||||
<ComboBox MinWidth="140"
|
||||
AutomationProperties.Name="{x:Static res:Strings.Settings_UpdateChannel_Label}"
|
||||
DisplayMemberPath="Label"
|
||||
ItemsSource="{x:Static vm:SettingsViewModel.UpdateChannels}"
|
||||
ItemsSource="{Binding ViewModel.UpdateChannels}"
|
||||
SelectedValue="{Binding ViewModel.UpdateChannel, Mode=TwoWay}"
|
||||
SelectedValuePath="Value" />
|
||||
</ui:CardControl>
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>
|
||||
/// A long-lived piece of the UI that read its text when it was made and must read it again after a language change
|
||||
/// (beta.15). A language change rebuilds the window and its pages (<see cref="ShellHost.Rebuild"/>), so everything transient
|
||||
/// follows on its own; a singleton — the tray's menu, the title bar's Agent pill — kept the language it started in until
|
||||
/// its state next changed. <see cref="ShellHost.Rebuild"/> calls every registered follower once the new window is up.
|
||||
/// </summary>
|
||||
public interface ILanguageFollower
|
||||
{
|
||||
/// <summary>Reads every text again in the current UI culture. Called on the UI thread.</summary>
|
||||
void FollowLanguage();
|
||||
}
|
||||
@@ -71,12 +71,19 @@ public sealed class ShellHost(IServiceProvider services, INavigationService navi
|
||||
/// <summary>The page the shell will open on, kept across a rebuild.</summary>
|
||||
public void Remember(Type page) => _page = page;
|
||||
|
||||
/// <summary>A new window in the current UI culture; the old one closes after the new one is up.</summary>
|
||||
/// <summary>
|
||||
/// A new window in the current UI culture; the old one closes after the new one is up. The long-lived pieces that
|
||||
/// read their text once — the tray's menu, the Agent pill — read it again (<see cref="ILanguageFollower"/>, beta.15).
|
||||
/// </summary>
|
||||
public void Rebuild()
|
||||
{
|
||||
MainWindow? old = _current;
|
||||
Show();
|
||||
old?.Close();
|
||||
foreach (ILanguageFollower follower in services.GetServices<ILanguageFollower>())
|
||||
{
|
||||
follower.FollowLanguage();
|
||||
}
|
||||
}
|
||||
|
||||
public Window? Current => _current;
|
||||
|
||||
@@ -15,12 +15,16 @@ namespace FrameLedger.App.Services;
|
||||
/// and tooltip follow the state, the context menu is the four items, a left click opens the window, and the
|
||||
/// FR-3.8 balloon's click opens the saved session. Created once the shell is up, on the UI thread.
|
||||
/// </summary>
|
||||
public sealed class TrayHost : IDisposable
|
||||
public sealed class TrayHost : IDisposable, ILanguageFollower
|
||||
{
|
||||
private readonly TrayViewModel _viewModel;
|
||||
private readonly WindowClosePolicy _policy;
|
||||
private TaskbarIcon? _icon;
|
||||
private System.Drawing.Icon? _image;
|
||||
private MenuItem? _open;
|
||||
private MenuItem? _pause;
|
||||
private MenuItem? _status;
|
||||
private MenuItem? _exit;
|
||||
|
||||
public TrayHost(TrayViewModel viewModel, WindowClosePolicy policy)
|
||||
{
|
||||
@@ -40,12 +44,16 @@ public sealed class TrayHost : IDisposable
|
||||
try
|
||||
{
|
||||
var menu = new ContextMenu();
|
||||
menu.Items.Add(new MenuItem { Header = Strings.Tray_Open, Command = _viewModel.OpenCommand });
|
||||
_open = new MenuItem { Header = Strings.Tray_Open, Command = _viewModel.OpenCommand };
|
||||
menu.Items.Add(_open);
|
||||
var pause = new MenuItem { Header = _viewModel.PauseText, Command = _viewModel.TogglePauseCommand };
|
||||
_pause = pause;
|
||||
menu.Items.Add(pause);
|
||||
menu.Items.Add(new MenuItem { Header = Strings.Tray_AgentStatus, Command = _viewModel.AgentStatusCommand });
|
||||
_status = new MenuItem { Header = Strings.Tray_AgentStatus, Command = _viewModel.AgentStatusCommand };
|
||||
menu.Items.Add(_status);
|
||||
menu.Items.Add(new Separator());
|
||||
menu.Items.Add(new MenuItem { Header = Strings.Tray_Exit, Command = _viewModel.ExitCommand });
|
||||
_exit = new MenuItem { Header = Strings.Tray_Exit, Command = _viewModel.ExitCommand };
|
||||
menu.Items.Add(_exit);
|
||||
|
||||
_image = TrayIcons.For(_viewModel.State);
|
||||
var icon = new TaskbarIcon
|
||||
@@ -111,6 +119,30 @@ public sealed class TrayHost : IDisposable
|
||||
_image = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The menu and the tooltip in the current language (beta.15): they were written once, when the icon was made, and a
|
||||
/// change of language left them in the first one. Nothing before the icon exists.
|
||||
/// </summary>
|
||||
public void FollowLanguage()
|
||||
{
|
||||
if (_icon is null || _open is null || _pause is null || _status is null || _exit is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_open.Header = Strings.Tray_Open;
|
||||
_pause.Header = _viewModel.PauseText;
|
||||
_status.Header = Strings.Tray_AgentStatus;
|
||||
_exit.Header = Strings.Tray_Exit;
|
||||
_icon.ToolTipText = _viewModel.Tooltip;
|
||||
}
|
||||
|
||||
/// <summary>The menu's items as shown, in order, for a test; empty before the icon exists.</summary>
|
||||
internal IReadOnlyList<string> MenuHeaders =>
|
||||
_open is null || _pause is null || _status is null || _exit is null
|
||||
? []
|
||||
: [.. new[] { _open, _pause, _status, _exit }.Select(static m => m.Header as string ?? string.Empty)];
|
||||
|
||||
private void OnViewModelChanged(MenuItem pause, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (_icon is null)
|
||||
|
||||
@@ -89,7 +89,8 @@ public sealed partial class GamesViewModel : ObservableObject
|
||||
|
||||
public static string ListText => Strings.Games_View_List;
|
||||
|
||||
public static IReadOnlyList<Choice<GamesSort>> Sorts { get; } =
|
||||
/// <summary>The sort orders, labelled in the language this page opened in (beta.15: a static list kept the first language).</summary>
|
||||
public IReadOnlyList<Choice<GamesSort>> Sorts { get; } =
|
||||
[
|
||||
new(GamesSort.Name, Strings.Games_Sort_Name),
|
||||
new(GamesSort.LastPlayed, Strings.Games_Sort_LastPlayed),
|
||||
|
||||
@@ -63,13 +63,14 @@ public sealed partial class LogsViewModel : ObservableObject, IDisposable
|
||||
|
||||
public static string Header => Strings.Logs_Header;
|
||||
|
||||
public static IReadOnlyList<Choice<LogSource>> Sources { get; } =
|
||||
/// <summary>The two logs, labelled in the language this page opened in (beta.15: a static list kept the first language).</summary>
|
||||
public IReadOnlyList<Choice<LogSource>> Sources { get; } =
|
||||
[
|
||||
new(LogSource.Ui, Strings.Logs_Source_Ui),
|
||||
new(LogSource.Agent, Strings.Logs_Source_Agent),
|
||||
];
|
||||
|
||||
public static IReadOnlyList<Choice<LogLevelFilter>> Levels { get; } =
|
||||
public IReadOnlyList<Choice<LogLevelFilter>> Levels { get; } =
|
||||
[
|
||||
new(LogLevelFilter.All, Strings.Logs_Level_All),
|
||||
new(LogLevelFilter.WarningAndAbove, Strings.Logs_Level_Warning),
|
||||
|
||||
@@ -18,7 +18,7 @@ using Wpf.Ui.Controls;
|
||||
namespace FrameLedger.App.ViewModels;
|
||||
|
||||
/// <summary>The shell's state: the Agent pill, the offline banner, and the menu commands that exist in this build.</summary>
|
||||
public sealed partial class MainWindowViewModel : ObservableObject, IDisposable
|
||||
public sealed partial class MainWindowViewModel : ObservableObject, IDisposable, ILanguageFollower
|
||||
{
|
||||
private readonly AgentConnection _agent;
|
||||
private readonly ISnackbarService _snackbar;
|
||||
@@ -124,6 +124,16 @@ public sealed partial class MainWindowViewModel : ObservableObject, IDisposable
|
||||
[RelayCommand]
|
||||
private Task RestartToUpdateAsync() => _updates.RestartToUpdateAsync();
|
||||
|
||||
/// <summary>
|
||||
/// The Agent pill, its banner and the update banner in the current language (beta.15): this view model outlives a
|
||||
/// rebuilt window, and its texts were read at the last change of state.
|
||||
/// </summary>
|
||||
public void FollowLanguage()
|
||||
{
|
||||
Refresh();
|
||||
RefreshUpdate();
|
||||
}
|
||||
|
||||
private void Refresh()
|
||||
{
|
||||
(string text, ControlAppearance appearance) = AgentStatusPresentation.Pill(_agent.State);
|
||||
|
||||
@@ -196,13 +196,18 @@ public sealed partial class SettingsViewModel : ObservableObject
|
||||
public static string LanguageLabel => Strings.Settings_Language_Label;
|
||||
|
||||
|
||||
public static IReadOnlyList<Choice<AppTheme>> Themes { get; } =
|
||||
/// <summary>
|
||||
/// The themes, labelled in the language this page opened in (beta.15): a static list kept the language the App started
|
||||
/// in after a change of language, while the rest of the rebuilt page followed it.
|
||||
/// </summary>
|
||||
public IReadOnlyList<Choice<AppTheme>> Themes { get; } =
|
||||
[
|
||||
new(AppTheme.System, Strings.Settings_Theme_System),
|
||||
new(AppTheme.Light, Strings.Settings_Theme_Light),
|
||||
new(AppTheme.Dark, Strings.Settings_Theme_Dark),
|
||||
];
|
||||
|
||||
/// <summary>Each language in its own words, so the same in every language: the one list that may stay static.</summary>
|
||||
public static IReadOnlyList<Choice<string>> Languages { get; } =
|
||||
[
|
||||
new("en", "English"),
|
||||
@@ -212,9 +217,10 @@ public sealed partial class SettingsViewModel : ObservableObject
|
||||
|
||||
/// <summary>
|
||||
/// D47 (beta.14): Automatic first, its label saying what it resolves to for this copy — "Automatic (Beta)" on a
|
||||
/// pre-release — then the two explicit choices, either of which wins over the copy.
|
||||
/// pre-release — then the two explicit choices, either of which wins over the copy. Per page since beta.15, so the
|
||||
/// labels follow a change of language.
|
||||
/// </summary>
|
||||
public static IReadOnlyList<Choice<string>> UpdateChannels { get; } =
|
||||
public IReadOnlyList<Choice<string>> UpdateChannels { get; } =
|
||||
[
|
||||
new(Update.UpdateChannelPolicy.Automatic, string.Format(CultureInfo.CurrentCulture, Strings.Settings_Channel_Auto_Format,
|
||||
Update.UpdateChannelPolicy.IsPrerelease(UiIdentity.Version) ? Strings.Settings_Channel_Beta : Strings.Settings_Channel_Stable)),
|
||||
|
||||
@@ -953,4 +953,27 @@ public sealed class GameDetailViewModelTests
|
||||
(await BuildAsync(s, without.Id)).Vm.AnyLatency.Should().BeFalse();
|
||||
(await BuildAsync(s, with.Id)).Vm.AnyLatency.Should().BeTrue();
|
||||
}
|
||||
/// <summary>beta.8 made the trend selector per page; beta.15 pins it: a page opened in Vietnamese lists Vietnamese metrics.</summary>
|
||||
[Fact]
|
||||
public async Task TheTrendSelectorIsInTheLanguageThePageOpenedIn()
|
||||
{
|
||||
CultureInfo? previous = Strings.Culture;
|
||||
try
|
||||
{
|
||||
await using ScratchLedger s = await ScratchLedger.OpenAsync();
|
||||
GameRow game = await s.GameAsync("Alpha");
|
||||
Strings.Culture = CultureInfo.GetCultureInfo("en");
|
||||
string english = Strings.Trend_Metric_PresentedFps;
|
||||
(GameDetailViewModel en, _, _, _, _) = await BuildAsync(s, game.Id);
|
||||
Strings.Culture = CultureInfo.GetCultureInfo("vi");
|
||||
(GameDetailViewModel vi, _, _, _, _) = await BuildAsync(s, game.Id);
|
||||
|
||||
en.TrendMetrics[0].Label.Should().Be(english);
|
||||
vi.TrendMetrics[0].Label.Should().Be(Strings.Trend_Metric_PresentedFps).And.NotBe(english);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Strings.Culture = previous;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using FluentAssertions;
|
||||
using FrameLedger.App.Controls;
|
||||
@@ -131,4 +132,31 @@ public sealed class GamesViewModelTests
|
||||
((columns * item) + ((columns - 1) * 12)).Should().BeApproximately(width, 0.001, "a row fills the width");
|
||||
}
|
||||
}
|
||||
/// <summary>beta.15: the sort order is labelled in the language the page opened in.</summary>
|
||||
[Fact]
|
||||
public async Task TheSortListIsInTheLanguageThePageOpenedIn()
|
||||
{
|
||||
CultureInfo? previous = Strings.Culture;
|
||||
try
|
||||
{
|
||||
await using ScratchLedger s = await ScratchLedger.OpenAsync();
|
||||
var selection = new GameSelection();
|
||||
var nav = new NoNavigation();
|
||||
GamesViewModel Open() => new(s.Library, selection, nav, new AddGameFlow(s.Library, new NoPicker(), selection, nav, new NoStrip()));
|
||||
Strings.Culture = CultureInfo.GetCultureInfo("en");
|
||||
GamesViewModel english = Open();
|
||||
string englishName = Strings.Games_Sort_Name;
|
||||
Strings.Culture = CultureInfo.GetCultureInfo("vi");
|
||||
GamesViewModel vietnamese = Open();
|
||||
await english.Pending;
|
||||
await vietnamese.Pending;
|
||||
|
||||
english.Sorts[0].Label.Should().Be(englishName);
|
||||
vietnamese.Sorts[0].Label.Should().Be(Strings.Games_Sort_Name).And.NotBe(englishName);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Strings.Culture = previous;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.Reflection;
|
||||
using FluentAssertions;
|
||||
using FrameLedger.App.ViewModels;
|
||||
|
||||
namespace FrameLedger.App.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// beta.15: a list of choices built once, in a static, keeps the language the App started in after a change of language,
|
||||
/// while the page around it — rebuilt — follows. The themes, the update channels, the Logs page's two lists and the
|
||||
/// Games page's sort order were such lists until beta.15; this keeps a new one from appearing. The language list is the
|
||||
/// one exception: each language is named in its own words, the same in every language.
|
||||
/// </summary>
|
||||
public sealed class LanguageFollowingTests
|
||||
{
|
||||
[Fact]
|
||||
public void NoViewModelKeepsAStaticListOfLabelledChoices()
|
||||
{
|
||||
string[] statics =
|
||||
[
|
||||
.. typeof(SettingsViewModel).Assembly.GetTypes()
|
||||
.Where(static t => string.Equals(t.Namespace, "FrameLedger.App.ViewModels", StringComparison.Ordinal))
|
||||
.SelectMany(static t => t.GetProperties(BindingFlags.Public | BindingFlags.Static).Select(p => (Type: t, Property: p)))
|
||||
.Where(static x => x.Property.PropertyType.IsGenericType
|
||||
&& x.Property.PropertyType.GetGenericTypeDefinition() == typeof(IReadOnlyList<>)
|
||||
&& x.Property.PropertyType.GetGenericArguments()[0] is { IsGenericType: true } item
|
||||
&& item.GetGenericTypeDefinition() == typeof(Choice<>))
|
||||
.Select(static x => x.Type.Name + "." + x.Property.Name),
|
||||
];
|
||||
|
||||
statics.Should().Equal(["SettingsViewModel.Languages"], "every other list is labelled in a language, and must be built per page");
|
||||
}
|
||||
}
|
||||
@@ -682,4 +682,28 @@ public sealed class SettingsViewModelTests
|
||||
Strings.Culture = previous;
|
||||
}
|
||||
}
|
||||
/// <summary>beta.15: the theme and channel lists are labelled in the language the page opened in — a rebuilt page follows a change.</summary>
|
||||
[Fact]
|
||||
public async Task TheChoiceListsAreInTheLanguageThePageOpenedIn()
|
||||
{
|
||||
CultureInfo? previous = Strings.Culture;
|
||||
try
|
||||
{
|
||||
await using ScratchLedger s = await ScratchLedger.OpenAsync();
|
||||
Strings.Culture = CultureInfo.GetCultureInfo("en");
|
||||
Harness english = await OpenAsync(s);
|
||||
string englishSystem = Strings.Settings_Theme_System;
|
||||
string englishStable = Strings.Settings_Channel_Stable;
|
||||
Strings.Culture = CultureInfo.GetCultureInfo("vi");
|
||||
Harness vietnamese = await OpenAsync(s);
|
||||
|
||||
english.Vm.Themes[0].Label.Should().Be(englishSystem);
|
||||
vietnamese.Vm.Themes[0].Label.Should().Be(Strings.Settings_Theme_System).And.NotBe(englishSystem);
|
||||
vietnamese.Vm.UpdateChannels.Single(static c => string.Equals(c.Value, "stable", StringComparison.Ordinal)).Label.Should().Be(Strings.Settings_Channel_Stable).And.NotBe(englishStable);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Strings.Culture = previous;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.Globalization;
|
||||
using System.Windows.Threading;
|
||||
using FluentAssertions;
|
||||
using FrameLedger.App.Services;
|
||||
@@ -16,6 +17,7 @@ namespace FrameLedger.App.Tests;
|
||||
/// a thread-pool thread and <see cref="TrayHost.Dispose"/> removed the icon there — a WPF object whose disposal unsubscribes
|
||||
/// <c>Application.Exit</c>, both owned by the UI thread.
|
||||
/// </summary>
|
||||
[Collection(StringsCultureCollection.Name)]
|
||||
public sealed class TrayHostTests
|
||||
{
|
||||
private sealed class Shell : IShellPresence
|
||||
@@ -88,4 +90,34 @@ public sealed class TrayHostTests
|
||||
error.Should().BeNull("the icon is removed on the thread that owns it, whatever thread asks");
|
||||
stillCreated.Should().BeFalse();
|
||||
}
|
||||
/// <summary>beta.15: the tray outlives a rebuilt window, and its menu was written once; a change of language relabels it.</summary>
|
||||
[Fact]
|
||||
public async Task AChangeOfLanguageRelabelsTheTraysMenu()
|
||||
{
|
||||
CultureInfo? previous = Strings.Culture;
|
||||
try
|
||||
{
|
||||
(IReadOnlyList<string> before, IReadOnlyList<string> after, IReadOnlyList<string> expected) = await PagesLoadTests.OnStaAsync(static () =>
|
||||
{
|
||||
Strings.Culture = CultureInfo.GetCultureInfo("en");
|
||||
var link = new FakeAgentLink();
|
||||
using var updates = new UpdateService(new FakeUpdateClient(), link, new RegisteredSettings(new MemorySettings()), new FakeUpdatePrompts(), new Shell(), new RecordingStrip());
|
||||
using var viewModel = new TrayViewModel(link, new Shell(), new Summaries(), new Navigation(), updates);
|
||||
using var tray = new TrayHost(viewModel, new WindowClosePolicy());
|
||||
tray.Create();
|
||||
IReadOnlyList<string> english = tray.MenuHeaders;
|
||||
Strings.Culture = CultureInfo.GetCultureInfo("vi");
|
||||
tray.FollowLanguage();
|
||||
return (english, tray.MenuHeaders, (IReadOnlyList<string>)[Strings.Tray_Open, viewModel.PauseText, Strings.Tray_AgentStatus, Strings.Tray_Exit]);
|
||||
});
|
||||
|
||||
before.Should().HaveCount(4);
|
||||
after.Should().Equal(expected);
|
||||
after[0].Should().NotBe(before[0], "the menu was written in English and the language is now Vietnamese");
|
||||
}
|
||||
finally
|
||||
{
|
||||
Strings.Culture = previous;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user