Skip to content

Interactive 2D wave optics simulator. Turn any image into a refractive scene, add sources, watch waves refract, diffract and interfere. Probes, intensity maps, video export.

C#

Localisation: plural forms for the folder count, the last literals into the tables

Alexander Graef9cda7f9f3619
diff --git a/CLAUDE.md b/CLAUDE.md
index 127a718..1386998 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -254,7 +254,16 @@ WPF shell as it stands:
needed: the generator was a one-off script, the English block in `Strings.EN.xaml` is what the
attributes said on 2026-10-14. **Adding a model property means adding its keys to all four
tables** (the key-set check in the notes' verification list catches a missing one). Not
- localised: log messages.
+ localised: log messages. **Plurals** (2026-10-15, after "1 entries" in the folder view): a count goes through
+ `Converters/ItemCountConverter` with the keys `ItemCountZero` / `ItemCountOne` / `ItemCountMany` ("No
+ entries", "1 entry", "{0} entries"; French keeps the singular for zero), a `MultiBinding` with the language as
+ its second input so the words follow a switch; a `StringFormat` with a `StaticResource` never did. Use the
+ same three-key shape for any other count that gets words. The same sweep (2026-10-15) moved the last literals
+ into the tables: the dock pane headers' "Window position" / "Close" and the position menu (`Dock*` keys, read
+ by `Themes/Controls.xaml` as `DynamicResource`), the wavelength row's "(nominal)" (`WavelengthNominal`; the
+ source view's `MultiBinding` got the language as a fifth input) and the scene image row's "(unreadable)"
+ (`ImageUnreadable`; a value converter, so that rare word changes with the next value, not with the switch).
+ Only the two never-shown command names ("Show messages", "Copy all") stay English.
- **Probe graphs** (2026-10-14, the author's point 7, first half): every active probe's graph box is drawn
over the picture of its layer, as the author's app did (translucent dark box, axes with "nice" ticks,
yellow curve, title strip with the live readout "= value" / "max value"). The numbers live in the
diff --git a/WaveDude.WPF/Converters/ImageInfoConverter.cs b/WaveDude.WPF/Converters/ImageInfoConverter.cs
index c359d4e..77ad19e 100644
--- a/WaveDude.WPF/Converters/ImageInfoConverter.cs
+++ b/WaveDude.WPF/Converters/ImageInfoConverter.cs
@@ -1,5 +1,6 @@
using System.Globalization;
using System.IO;
+using System.Windows;
using System.Windows.Data;
using System.Windows.Media.Imaging;
@@ -26,7 +27,7 @@ public sealed class ImageInfoConverter : IValueConverter
}
catch (Exception ex) when (ex is NotSupportedException or FileFormatException or IOException)
{
- return "(unreadable)";
+ return Application.Current?.TryFindResource("ImageUnreadable") as string ?? "(unreadable)";
}
}
diff --git a/WaveDude.WPF/Converters/ItemCountConverter.cs b/WaveDude.WPF/Converters/ItemCountConverter.cs
new file mode 100644
index 0000000..6cb17b7
--- /dev/null
+++ b/WaveDude.WPF/Converters/ItemCountConverter.cs
@@ -0,0 +1,35 @@
+using System.Globalization;
+using System.Windows;
+using System.Windows.Data;
+
+namespace WaveDude.WPF.Converters;
+
+/// <summary>
+/// A folder's item count as words with the right plural (2026-10-15, after "1 entries"): the string table's
+/// <c>ItemCountZero</c> ("No entries"), <c>ItemCountOne</c> ("1 entry") or <c>ItemCountMany</c> ("{0} entries",
+/// the count formatted in the current culture). A multi-value converter whose first input is the count and
+/// whose second, the current language, only serves to re-read the words on a language switch.
+/// </summary>
+public sealed class ItemCountConverter : IMultiValueConverter
+{
+ /// <inheritdoc/>
+ public object? Convert(object[] values, Type targetType, object? parameter, CultureInfo culture)
+ {
+ if (values.Length == 0 || values[0] is not int count)
+ {
+ return null;
+ }
+ string key = count switch
+ {
+ 0 => "ItemCountZero",
+ 1 => "ItemCountOne",
+ _ => "ItemCountMany",
+ };
+ string format = Application.Current?.TryFindResource(key) as string ?? "{0}";
+ return string.Format(culture, format, count);
+ }
+
+ /// <inheritdoc/>
+ public object[] ConvertBack(object value, Type[] targetTypes, object? parameter, CultureInfo culture) =>
+ throw new NotSupportedException();
+}
diff --git a/WaveDude.WPF/Converters/WavelengthConverter.cs b/WaveDude.WPF/Converters/WavelengthConverter.cs
index 795af54..4e2c4db 100644
--- a/WaveDude.WPF/Converters/WavelengthConverter.cs
+++ b/WaveDude.WPF/Converters/WavelengthConverter.cs
@@ -1,4 +1,5 @@
using System.Globalization;
+using System.Windows;
using System.Windows.Data;
using WaveDude.Model;
@@ -25,7 +26,12 @@ public sealed class WavelengthConverter : IMultiValueConverter
return "\u2013";
}
string text = string.Format(culture, "\u2248 {0:0.0} px", wavelength);
- return fourthOrder ? text : text + " (nominal)";
+ if (fourthOrder)
+ {
+ return text;
+ }
+ // the 9-point stencil disperses: the word from the string table (a fifth input, the language, re-reads it on a switch)
+ return text + " " + (Application.Current?.TryFindResource("WavelengthNominal") as string ?? "(nominal)");
}
public object[] ConvertBack(object? value, Type[] targetTypes, object? parameter, CultureInfo culture) =>
diff --git a/WaveDude.WPF/Strings/Strings.DE.xaml b/WaveDude.WPF/Strings/Strings.DE.xaml
index 13e5267..3dcc8a6 100644
--- a/WaveDude.WPF/Strings/Strings.DE.xaml
+++ b/WaveDude.WPF/Strings/Strings.DE.xaml
@@ -23,6 +23,15 @@
<s:String x:Key="MenuFileExit">_Beenden</s:String>
<s:String x:Key="MenuView">_Ansicht</s:String>
<s:String x:Key="MenuViewPanes">_Fenster</s:String>
+ <s:String x:Key="DockWindowPosition">Fensterposition</s:String>
+ <s:String x:Key="DockMoveLeft">Nach _links</s:String>
+ <s:String x:Key="DockMoveRight">Nach _rechts</s:String>
+ <s:String x:Key="DockMoveTop">Nach _oben</s:String>
+ <s:String x:Key="DockMoveBottom">Nach _unten</s:String>
+ <s:String x:Key="DockCloseMenu">_Schließen</s:String>
+ <s:String x:Key="DockClose">Schließen</s:String>
+ <s:String x:Key="WavelengthNominal">(nominell)</s:String>
+ <s:String x:Key="ImageUnreadable">(nicht lesbar)</s:String>
<s:String x:Key="MenuViewTheme">_Design</s:String>
<s:String x:Key="MenuViewLanguage">_Sprache</s:String>
<s:String x:Key="MenuViewResolution">Vorschau_auflösung</s:String>
@@ -175,7 +184,9 @@
<s:String x:Key="SectionGraph">Diagramm</s:String>
<s:String x:Key="SectionAxes">Achsen</s:String>
<s:String x:Key="ButtonNewSeed">_Neuer Startwert</s:String>
- <s:String x:Key="ItemCountFormat">{0} Einträge</s:String>
+ <s:String x:Key="ItemCountZero">Keine Einträge</s:String>
+ <s:String x:Key="ItemCountOne">1 Eintrag</s:String>
+ <s:String x:Key="ItemCountMany">{0} Einträge</s:String>
<s:String x:Key="ButtonBrowse">Durchsuchen…</s:String>
<s:String x:Key="TipBrowseSceneImage">Bilddatei wählen; sie wird in das Projekt eingebettet</s:String>
diff --git a/WaveDude.WPF/Strings/Strings.EN.xaml b/WaveDude.WPF/Strings/Strings.EN.xaml
index 9b899fe..ddd59b5 100644
--- a/WaveDude.WPF/Strings/Strings.EN.xaml
+++ b/WaveDude.WPF/Strings/Strings.EN.xaml
@@ -23,6 +23,17 @@
<s:String x:Key="MenuFileExit">E_xit</s:String>
<s:String x:Key="MenuView">_View</s:String>
<s:String x:Key="MenuViewPanes">_Panes</s:String>
+ <!-- the dock panes' header buttons and the position menu -->
+ <s:String x:Key="DockWindowPosition">Window position</s:String>
+ <s:String x:Key="DockMoveLeft">Move to _Left</s:String>
+ <s:String x:Key="DockMoveRight">Move to _Right</s:String>
+ <s:String x:Key="DockMoveTop">Move to _Top</s:String>
+ <s:String x:Key="DockMoveBottom">Move to _Bottom</s:String>
+ <s:String x:Key="DockCloseMenu">_Close</s:String>
+ <s:String x:Key="DockClose">Close</s:String>
+ <!-- words the converters append: the wavelength row with the 9-point stencil, an embedded image that cannot be decoded -->
+ <s:String x:Key="WavelengthNominal">(nominal)</s:String>
+ <s:String x:Key="ImageUnreadable">(unreadable)</s:String>
<s:String x:Key="MenuViewTheme">_Theme</s:String>
<s:String x:Key="MenuViewLanguage">_Language</s:String>
<s:String x:Key="MenuViewResolution">Preview _resolution</s:String>
@@ -175,7 +186,9 @@
<s:String x:Key="SectionGraph">Graph</s:String>
<s:String x:Key="SectionAxes">Axes</s:String>
<s:String x:Key="ButtonNewSeed">_New seed</s:String>
- <s:String x:Key="ItemCountFormat">{0} items</s:String>
+ <s:String x:Key="ItemCountZero">No entries</s:String>
+ <s:String x:Key="ItemCountOne">1 entry</s:String>
+ <s:String x:Key="ItemCountMany">{0} entries</s:String>
<s:String x:Key="ButtonBrowse">Browse…</s:String>
<s:String x:Key="TipBrowseSceneImage">Pick an image file; it is embedded in the project</s:String>
diff --git a/WaveDude.WPF/Strings/Strings.FR.xaml b/WaveDude.WPF/Strings/Strings.FR.xaml
index 8497e4b..d738c85 100644
--- a/WaveDude.WPF/Strings/Strings.FR.xaml
+++ b/WaveDude.WPF/Strings/Strings.FR.xaml
@@ -23,6 +23,15 @@
<s:String x:Key="MenuFileExit">_Quitter</s:String>
<s:String x:Key="MenuView">_Affichage</s:String>
<s:String x:Key="MenuViewPanes">_Panneaux</s:String>
+ <s:String x:Key="DockWindowPosition">Position du panneau</s:String>
+ <s:String x:Key="DockMoveLeft">Déplacer à _gauche</s:String>
+ <s:String x:Key="DockMoveRight">Déplacer à _droite</s:String>
+ <s:String x:Key="DockMoveTop">Déplacer en _haut</s:String>
+ <s:String x:Key="DockMoveBottom">Déplacer en _bas</s:String>
+ <s:String x:Key="DockCloseMenu">_Fermer</s:String>
+ <s:String x:Key="DockClose">Fermer</s:String>
+ <s:String x:Key="WavelengthNominal">(nominale)</s:String>
+ <s:String x:Key="ImageUnreadable">(illisible)</s:String>
<s:String x:Key="MenuViewTheme">_Thème</s:String>
<s:String x:Key="MenuViewLanguage">_Langue</s:String>
<s:String x:Key="MenuViewResolution">_Résolution de l'aperçu</s:String>
@@ -175,7 +184,9 @@
<s:String x:Key="SectionGraph">Graphique</s:String>
<s:String x:Key="SectionAxes">Axes</s:String>
<s:String x:Key="ButtonNewSeed">_Nouvelle graine</s:String>
- <s:String x:Key="ItemCountFormat">{0} éléments</s:String>
+ <s:String x:Key="ItemCountZero">Aucune entrée</s:String>
+ <s:String x:Key="ItemCountOne">1 entrée</s:String>
+ <s:String x:Key="ItemCountMany">{0} entrées</s:String>
<s:String x:Key="ButtonBrowse">Parcourir…</s:String>
<s:String x:Key="TipBrowseSceneImage">Choisir un fichier image ; il est intégré au projet</s:String>
diff --git a/WaveDude.WPF/Strings/Strings.NL.xaml b/WaveDude.WPF/Strings/Strings.NL.xaml
index 0c19b3d..af13bfb 100644
--- a/WaveDude.WPF/Strings/Strings.NL.xaml
+++ b/WaveDude.WPF/Strings/Strings.NL.xaml
@@ -23,6 +23,15 @@
<s:String x:Key="MenuFileExit">A_fsluiten</s:String>
<s:String x:Key="MenuView">Beel_d</s:String>
<s:String x:Key="MenuViewPanes">_Panelen</s:String>
+ <s:String x:Key="DockWindowPosition">Positie van het paneel</s:String>
+ <s:String x:Key="DockMoveLeft">Naar _links</s:String>
+ <s:String x:Key="DockMoveRight">Naar _rechts</s:String>
+ <s:String x:Key="DockMoveTop">Naar _boven</s:String>
+ <s:String x:Key="DockMoveBottom">Naar _onder</s:String>
+ <s:String x:Key="DockCloseMenu">_Sluiten</s:String>
+ <s:String x:Key="DockClose">Sluiten</s:String>
+ <s:String x:Key="WavelengthNominal">(nominaal)</s:String>
+ <s:String x:Key="ImageUnreadable">(onleesbaar)</s:String>
<s:String x:Key="MenuViewTheme">_Thema</s:String>
<s:String x:Key="MenuViewLanguage">Taa_l</s:String>
<s:String x:Key="MenuViewResolution">Voorbeeld_resolutie</s:String>
@@ -175,7 +184,9 @@
<s:String x:Key="SectionGraph">Grafiek</s:String>
<s:String x:Key="SectionAxes">Assen</s:String>
<s:String x:Key="ButtonNewSeed">_Nieuwe seed</s:String>
- <s:String x:Key="ItemCountFormat">{0} items</s:String>
+ <s:String x:Key="ItemCountZero">Geen items</s:String>
+ <s:String x:Key="ItemCountOne">1 item</s:String>
+ <s:String x:Key="ItemCountMany">{0} items</s:String>
<s:String x:Key="ButtonBrowse">Bladeren…</s:String>
<s:String x:Key="TipBrowseSceneImage">Kies een afbeeldingsbestand; het wordt in het project ingebed</s:String>
diff --git a/WaveDude.WPF/Themes/Controls.xaml b/WaveDude.WPF/Themes/Controls.xaml
index 42475fd..373dc92 100644
--- a/WaveDude.WPF/Themes/Controls.xaml
+++ b/WaveDude.WPF/Themes/Controls.xaml
@@ -672,8 +672,8 @@
<DockPanel Margin="5,0,2,0">
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal" VerticalAlignment="Center">
<Button x:Name="PART_MenuButton" Style="{StaticResource DockHeaderButtonStyle}"
- Content="{StaticResource DropDownGeometry}" ToolTip="Window position"
- AutomationProperties.Name="Window position"
+ Content="{StaticResource DropDownGeometry}" ToolTip="{DynamicResource DockWindowPosition}"
+ AutomationProperties.Name="{DynamicResource DockWindowPosition}"
Foreground="{DynamicResource TitleBarInactiveForeground}"
Background="{DynamicResource TitleBarButtonHoverInactive}">
<Button.ContextMenu>
@@ -684,18 +684,18 @@
<Setter Property="CommandTarget" Value="{Binding PlacementTarget, RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}}" />
</Style>
</ContextMenu.Resources>
- <MenuItem Header="Move to _Left" Command="{x:Static docking:DockCommands.MoveToSide}" CommandParameter="{x:Static docking:DockSide.Left}" />
- <MenuItem Header="Move to _Right" Command="{x:Static docking:DockCommands.MoveToSide}" CommandParameter="{x:Static docking:DockSide.Right}" />
- <MenuItem Header="Move to _Top" Command="{x:Static docking:DockCommands.MoveToSide}" CommandParameter="{x:Static docking:DockSide.Top}" />
- <MenuItem Header="Move to _Bottom" Command="{x:Static docking:DockCommands.MoveToSide}" CommandParameter="{x:Static docking:DockSide.Bottom}" />
+ <MenuItem Header="{DynamicResource DockMoveLeft}" Command="{x:Static docking:DockCommands.MoveToSide}" CommandParameter="{x:Static docking:DockSide.Left}" />
+ <MenuItem Header="{DynamicResource DockMoveRight}" Command="{x:Static docking:DockCommands.MoveToSide}" CommandParameter="{x:Static docking:DockSide.Right}" />
+ <MenuItem Header="{DynamicResource DockMoveTop}" Command="{x:Static docking:DockCommands.MoveToSide}" CommandParameter="{x:Static docking:DockSide.Top}" />
+ <MenuItem Header="{DynamicResource DockMoveBottom}" Command="{x:Static docking:DockCommands.MoveToSide}" CommandParameter="{x:Static docking:DockSide.Bottom}" />
<Separator />
- <MenuItem Header="_Close" Command="{x:Static docking:DockCommands.Close}" />
+ <MenuItem Header="{DynamicResource DockCloseMenu}" Command="{x:Static docking:DockCommands.Close}" />
</ContextMenu>
</Button.ContextMenu>
</Button>
<Button x:Name="PART_CloseButton" Style="{StaticResource DockHeaderButtonStyle}"
- Content="{StaticResource CloseGeometry}" ToolTip="Close"
- AutomationProperties.Name="Close"
+ Content="{StaticResource CloseGeometry}" ToolTip="{DynamicResource DockClose}"
+ AutomationProperties.Name="{DynamicResource DockClose}"
Command="{x:Static docking:DockCommands.Close}"
Foreground="{DynamicResource TitleBarInactiveForeground}"
Background="{DynamicResource TitleBarButtonHoverInactive}"
diff --git a/WaveDude.WPF/Views/CollectionView.xaml b/WaveDude.WPF/Views/CollectionView.xaml
index f90f6bb..4963daa 100644
--- a/WaveDude.WPF/Views/CollectionView.xaml
+++ b/WaveDude.WPF/Views/CollectionView.xaml
@@ -1,11 +1,22 @@
<UserControl x:Class="WaveDude.WPF.Views.CollectionView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:converters="clr-namespace:WaveDude.WPF.Converters"
+ xmlns:localization="clr-namespace:WaveDude.WPF.Localization">
+ <UserControl.Resources>
+ <converters:ItemCountConverter x:Key="ItemCount" />
+ </UserControl.Resources>
- <!-- a folder node (Sources, Probes): just the name and the count for now -->
+ <!-- a folder node (Sources, Probes): just the name and the count for now; the count with its plural, re-read on a language switch -->
<StackPanel Margin="8">
<Label Style="{StaticResource FormSection}" Content="{Binding Label}" Margin="0,2,0,4" />
- <TextBlock Style="{StaticResource FormValue}" Margin="0"
- Text="{Binding Items.Count, StringFormat={StaticResource ItemCountFormat}}" />
+ <TextBlock Style="{StaticResource FormValue}" Margin="0" AutomationProperties.AutomationId="CollectionCount">
+ <TextBlock.Text>
+ <MultiBinding Converter="{StaticResource ItemCount}" Mode="OneWay">
+ <Binding Path="Items.Count" />
+ <Binding Path="Current" Source="{x:Static localization:LanguageController.Instance}" />
+ </MultiBinding>
+ </TextBlock.Text>
+ </TextBlock>
</StackPanel>
</UserControl>
diff --git a/WaveDude.WPF/Views/SourceView.xaml b/WaveDude.WPF/Views/SourceView.xaml
index ddbf4d6..315c109 100644
--- a/WaveDude.WPF/Views/SourceView.xaml
+++ b/WaveDude.WPF/Views/SourceView.xaml
@@ -5,6 +5,7 @@
xmlns:meta="clr-namespace:WaveDude.WPF.Markup"
xmlns:panes="clr-namespace:WaveDude.WPF.Panes"
xmlns:converters="clr-namespace:WaveDude.WPF.Converters"
+ xmlns:localization="clr-namespace:WaveDude.WPF.Localization"
xmlns:model="clr-namespace:WaveDude.Model;assembly=WaveDude">
<UserControl.Resources>
@@ -67,6 +68,8 @@
<Binding Path="Project.Simulation.WaveSpeed" RelativeSource="{RelativeSource AncestorType={x:Type panes:PropertiesPane}}" />
<Binding Path="Project.Simulation.SourceFrequencyScale" RelativeSource="{RelativeSource AncestorType={x:Type panes:PropertiesPane}}" />
<Binding Path="Project.Simulation.FourthOrderLaplacian" RelativeSource="{RelativeSource AncestorType={x:Type panes:PropertiesPane}}" />
+ <!-- the language, so "(nominal)" is re-read on a switch -->
+ <Binding Path="Current" Source="{x:Static localization:LanguageController.Instance}" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>