Skip to content

armgit / Filee

Public Imported from GitHub
0

Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.

feat(i18n): show Portuguese demo recordings in the app and installer

BlackSpiritsa949f2856b50
diff --git a/src/Filee.App/Assets/WhatsNew/2.0.0/pt-BR/browser.webp b/src/Filee.App/Assets/WhatsNew/2.0.0/pt-BR/browser.webp
new file mode 100644
index 00000000..e60e3a14
Binary files /dev/null and b/src/Filee.App/Assets/WhatsNew/2.0.0/pt-BR/browser.webp differ
diff --git a/src/Filee.App/Assets/WhatsNew/2.0.0/pt-BR/crop.webp b/src/Filee.App/Assets/WhatsNew/2.0.0/pt-BR/crop.webp
new file mode 100644
index 00000000..7f81a31f
Binary files /dev/null and b/src/Filee.App/Assets/WhatsNew/2.0.0/pt-BR/crop.webp differ
diff --git a/src/Filee.App/Assets/WhatsNew/2.0.0/pt-BR/flip.webp b/src/Filee.App/Assets/WhatsNew/2.0.0/pt-BR/flip.webp
new file mode 100644
index 00000000..202c8eaa
Binary files /dev/null and b/src/Filee.App/Assets/WhatsNew/2.0.0/pt-BR/flip.webp differ
diff --git a/src/Filee.App/Assets/WhatsNew/2.0.0/pt-BR/formats.webp b/src/Filee.App/Assets/WhatsNew/2.0.0/pt-BR/formats.webp
new file mode 100644
index 00000000..a05340c5
Binary files /dev/null and b/src/Filee.App/Assets/WhatsNew/2.0.0/pt-BR/formats.webp differ
diff --git a/src/Filee.App/Assets/WhatsNew/2.0.0/pt-BR/more.webp b/src/Filee.App/Assets/WhatsNew/2.0.0/pt-BR/more.webp
new file mode 100644
index 00000000..c138ffe5
Binary files /dev/null and b/src/Filee.App/Assets/WhatsNew/2.0.0/pt-BR/more.webp differ
diff --git a/src/Filee.App/Assets/WhatsNew/2.0.0/pt-BR/theme.webp b/src/Filee.App/Assets/WhatsNew/2.0.0/pt-BR/theme.webp
new file mode 100644
index 00000000..c4887241
Binary files /dev/null and b/src/Filee.App/Assets/WhatsNew/2.0.0/pt-BR/theme.webp differ
diff --git a/src/Filee.App/Assets/WhatsNew/2.0.0/pt-PT/browser.webp b/src/Filee.App/Assets/WhatsNew/2.0.0/pt-PT/browser.webp
new file mode 100644
index 00000000..e850ba39
Binary files /dev/null and b/src/Filee.App/Assets/WhatsNew/2.0.0/pt-PT/browser.webp differ
diff --git a/src/Filee.App/Assets/WhatsNew/2.0.0/pt-PT/crop.webp b/src/Filee.App/Assets/WhatsNew/2.0.0/pt-PT/crop.webp
new file mode 100644
index 00000000..063aaa4f
Binary files /dev/null and b/src/Filee.App/Assets/WhatsNew/2.0.0/pt-PT/crop.webp differ
diff --git a/src/Filee.App/Assets/WhatsNew/2.0.0/pt-PT/flip.webp b/src/Filee.App/Assets/WhatsNew/2.0.0/pt-PT/flip.webp
new file mode 100644
index 00000000..1bce4037
Binary files /dev/null and b/src/Filee.App/Assets/WhatsNew/2.0.0/pt-PT/flip.webp differ
diff --git a/src/Filee.App/Assets/WhatsNew/2.0.0/pt-PT/formats.webp b/src/Filee.App/Assets/WhatsNew/2.0.0/pt-PT/formats.webp
new file mode 100644
index 00000000..a05340c5
Binary files /dev/null and b/src/Filee.App/Assets/WhatsNew/2.0.0/pt-PT/formats.webp differ
diff --git a/src/Filee.App/Assets/WhatsNew/2.0.0/pt-PT/more.webp b/src/Filee.App/Assets/WhatsNew/2.0.0/pt-PT/more.webp
new file mode 100644
index 00000000..1c423ecc
Binary files /dev/null and b/src/Filee.App/Assets/WhatsNew/2.0.0/pt-PT/more.webp differ
diff --git a/src/Filee.App/Assets/WhatsNew/2.0.0/pt-PT/theme.webp b/src/Filee.App/Assets/WhatsNew/2.0.0/pt-PT/theme.webp
new file mode 100644
index 00000000..aeebbc67
Binary files /dev/null and b/src/Filee.App/Assets/WhatsNew/2.0.0/pt-PT/theme.webp differ
diff --git a/src/Filee.App/Assets/WhatsNew/2.0.0/slides.json b/src/Filee.App/Assets/WhatsNew/2.0.0/slides.json
index 83291d4f..8418d39d 100644
--- a/src/Filee.App/Assets/WhatsNew/2.0.0/slides.json
+++ b/src/Filee.App/Assets/WhatsNew/2.0.0/slides.json
@@ -1,12 +1,111 @@
{
"version": "2.0.0",
"slides": [
- { "id": "browser", "media": "browser.webp", "poster": 52, "title": "whats_new.2_0_0.browser.title", "text": "whats_new.2_0_0.browser.text" },
- { "id": "flip", "media": "flip.webp", "poster": 75, "title": "whats_new.2_0_0.flip.title", "text": "whats_new.2_0_0.flip.text" },
- { "id": "formats", "media": "formats.webp", "title": "whats_new.2_0_0.formats.title", "text": "whats_new.2_0_0.formats.text" },
- { "id": "crop", "media": "crop.webp", "poster": 57, "title": "whats_new.2_0_0.crop.title", "text": "whats_new.2_0_0.crop.text" },
- { "id": "theme", "media": "theme.webp", "poster": 28, "title": "whats_new.2_0_0.theme.title", "text": "whats_new.2_0_0.theme.text" },
- { "id": "languages", "media": "languages.webp", "title": "whats_new.2_0_0.languages.title", "text": "whats_new.2_0_0.languages.text" },
- { "id": "more", "media": "more.webp", "title": "whats_new.2_0_0.more.title", "text": "whats_new.2_0_0.more.text" }
+ {
+ "id": "browser",
+ "media": "browser.webp",
+ "poster": 52,
+ "title": "whats_new.2_0_0.browser.title",
+ "text": "whats_new.2_0_0.browser.text",
+ "localizedMedia": {
+ "pt-PT": {
+ "media": "pt-PT/browser.webp",
+ "poster": 0
+ },
+ "pt-BR": {
+ "media": "pt-BR/browser.webp",
+ "poster": 0
+ }
+ }
+ },
+ {
+ "id": "flip",
+ "media": "flip.webp",
+ "poster": 75,
+ "title": "whats_new.2_0_0.flip.title",
+ "text": "whats_new.2_0_0.flip.text",
+ "localizedMedia": {
+ "pt-PT": {
+ "media": "pt-PT/flip.webp",
+ "poster": 0
+ },
+ "pt-BR": {
+ "media": "pt-BR/flip.webp",
+ "poster": 0
+ }
+ }
+ },
+ {
+ "id": "formats",
+ "media": "formats.webp",
+ "title": "whats_new.2_0_0.formats.title",
+ "text": "whats_new.2_0_0.formats.text",
+ "localizedMedia": {
+ "pt-PT": {
+ "media": "pt-PT/formats.webp",
+ "poster": 0
+ },
+ "pt-BR": {
+ "media": "pt-BR/formats.webp",
+ "poster": 0
+ }
+ }
+ },
+ {
+ "id": "crop",
+ "media": "crop.webp",
+ "poster": 57,
+ "title": "whats_new.2_0_0.crop.title",
+ "text": "whats_new.2_0_0.crop.text",
+ "localizedMedia": {
+ "pt-PT": {
+ "media": "pt-PT/crop.webp",
+ "poster": 57
+ },
+ "pt-BR": {
+ "media": "pt-BR/crop.webp",
+ "poster": 57
+ }
+ }
+ },
+ {
+ "id": "theme",
+ "media": "theme.webp",
+ "poster": 28,
+ "title": "whats_new.2_0_0.theme.title",
+ "text": "whats_new.2_0_0.theme.text",
+ "localizedMedia": {
+ "pt-PT": {
+ "media": "pt-PT/theme.webp",
+ "poster": 28
+ },
+ "pt-BR": {
+ "media": "pt-BR/theme.webp",
+ "poster": 28
+ }
+ }
+ },
+ {
+ "id": "languages",
+ "media": "languages.webp",
+ "title": "whats_new.2_0_0.languages.title",
+ "text": "whats_new.2_0_0.languages.text"
+ },
+ {
+ "id": "more",
+ "media": "more.webp",
+ "title": "whats_new.2_0_0.more.title",
+ "text": "whats_new.2_0_0.more.text",
+ "localizedMedia": {
+ "pt-PT": {
+ "media": "pt-PT/more.webp",
+ "poster": 0
+ },
+ "pt-BR": {
+ "media": "pt-BR/more.webp",
+ "poster": 0
+ }
+ }
+ }
]
}
diff --git a/src/Filee.App/Assets/i18n/pt-BR.json b/src/Filee.App/Assets/i18n/pt-BR.json
index 49c88639..5e872fe4 100644
--- a/src/Filee.App/Assets/i18n/pt-BR.json
+++ b/src/Filee.App/Assets/i18n/pt-BR.json
@@ -923,7 +923,7 @@
"whats_new.2_0_0.formats.title": "Mais formatos",
"whats_new.2_0_0.formats.text": "Páginas da Web arquivadas (MHTML), faturas eletrônicas OFD, mapas Shapefile, GeoJSON, KML e GPX, JPEG XR, modelos FBX e modelos POTM.",
"whats_new.2_0_0.crop.title": "Recorte antes de converter",
- "whats_new.2_0_0.crop.text": "Solte imagens no segmento Recortar. Pressione A sobre uma imagem para escolher uma proporção nesse local e, depois, Recortar e avançar.",
+ "whats_new.2_0_0.crop.text": "Solte imagens em \"Recortar\". Com o ponteiro sobre a imagem, pressione A para escolher a proporção. Depois, selecione \"Recortar e avançar\".",
"whats_new.2_0_0.theme.title": "Mais arredondada, com suas cores",
"whats_new.2_0_0.theme.text": "Escolha qualquer cor de destaque, suavize os cantos com Arredondamento e ajuste a transparência da barra circular.",
"whats_new.2_0_0.languages.title": "O Filee fala mais idiomas",
diff --git a/src/Filee.App/Assets/i18n/pt-PT.json b/src/Filee.App/Assets/i18n/pt-PT.json
index 2eb51a38..e0de4488 100644
--- a/src/Filee.App/Assets/i18n/pt-PT.json
+++ b/src/Filee.App/Assets/i18n/pt-PT.json
@@ -923,7 +923,7 @@
"whats_new.2_0_0.formats.title": "Mais formatos",
"whats_new.2_0_0.formats.text": "Páginas Web arquivadas (MHTML), faturas eletrónicas OFD, mapas Shapefile, GeoJSON, KML e GPX, JPEG XR, modelos FBX e modelos POTM.",
"whats_new.2_0_0.crop.title": "Recorta antes de converter",
- "whats_new.2_0_0.crop.text": "Larga imagens no segmento Recortar. Prime A sobre uma imagem para escolher uma proporção nesse local e, depois, Recortar e avançar.",
+ "whats_new.2_0_0.crop.text": "Larga imagens em «Recortar». Com o ponteiro sobre a imagem, prime A para escolheres a proporção. Depois, seleciona «Recortar e avançar».",
"whats_new.2_0_0.theme.title": "Mais arredondada, com as tuas cores",
"whats_new.2_0_0.theme.text": "Escolhe qualquer cor de destaque, suaviza os cantos com Arredondamento e ajusta a transparência da barra circular.",
"whats_new.2_0_0.languages.title": "O Filee fala mais idiomas",
diff --git a/src/Filee.App/Controls/SlideDeck.cs b/src/Filee.App/Controls/SlideDeck.cs
index 4dbc96c1..f33372de 100644
--- a/src/Filee.App/Controls/SlideDeck.cs
+++ b/src/Filee.App/Controls/SlideDeck.cs
@@ -10,6 +10,7 @@
// ]
// }
+using System.Collections.Frozen;
using System.Text.Json;
using Avalonia.Platform;
@@ -19,7 +20,20 @@ namespace Filee.App.Controls;
/// One slide: a picture or animation, a title and a line or two of text (i18n keys). <paramref name="PosterFrame"/> is
/// the frame shown with reduced motion (the first unless the manifest says <c>"poster"</c>).
/// </summary>
-public sealed record Slide(string Id, Uri Media, string TitleKey, string TextKey, int PosterFrame = 0);
+public sealed record Slide(string Id, Uri Media, string TitleKey, string TextKey, int PosterFrame = 0)
+{
+ /// <summary>Optional recordings of the same demonstration in particular UI languages.</summary>
+ public IReadOnlyDictionary<string, SlideMedia> LocalizedMedia { get; init; } =
+ FrozenDictionary<string, SlideMedia>.Empty;
+
+ /// <summary>Exact language match only: pt-PT must never borrow a pt-BR recording, or vice versa.</summary>
+ public SlideMedia MediaFor(string? language) =>
+ language is not null && LocalizedMedia.TryGetValue(language, out var localized)
+ ? localized : new SlideMedia(Media, PosterFrame);
+}
+
+/// <summary>A recording and its own reduced-motion frame; localized recordings can have different frame counts.</summary>
+public sealed record SlideMedia(Uri Source, int PosterFrame = 0);
/// <summary>The slides introducing <see cref="Version"/>.</summary>
public sealed record SlideDeck(Version Version, IReadOnlyList<Slide> Slides)
@@ -81,9 +95,18 @@ public sealed record SlideDeck(Version Version, IReadOnlyList<Slide> Slides)
if (Text(item, "id") is { } id && Text(item, "media") is { } media
&& Text(item, "title") is { } title && Text(item, "text") is { } text
&& IsPlainRelative(media))
- slides.Add(new Slide(id, new Uri(folder, media), title, text,
- item.TryGetProperty("poster", out var poster) && poster.ValueKind == JsonValueKind.Number
- && poster.TryGetInt32(out var frame) && frame > 0 ? frame : 0));
+ {
+ var localized = new Dictionary<string, SlideMedia>(StringComparer.OrdinalIgnoreCase);
+ if (item.TryGetProperty("localizedMedia", out var variants) && variants.ValueKind == JsonValueKind.Object)
+ foreach (var variant in variants.EnumerateObject())
+ if (Text(variant.Value, "media") is { } path && IsPlainRelative(path))
+ localized[variant.Name] = new SlideMedia(new Uri(folder, path), Poster(variant.Value));
+ slides.Add(new Slide(id, new Uri(folder, media), title, text, Poster(item))
+ {
+ LocalizedMedia = localized.Count == 0 ? FrozenDictionary<string, SlideMedia>.Empty
+ : localized.ToFrozenDictionary(StringComparer.OrdinalIgnoreCase),
+ });
+ }
}
return slides.Count == 0 ? null : new SlideDeck(version, slides);
}
@@ -113,6 +136,10 @@ public sealed record SlideDeck(Version Version, IReadOnlyList<Slide> Slides)
private static bool IsPlainRelative(string media) =>
!media.Contains("..", StringComparison.Ordinal) && !media.Contains(':') && media[0] is not ('/' or '\\');
+ private static int Poster(JsonElement item) =>
+ item.TryGetProperty("poster", out var poster) && poster.ValueKind == JsonValueKind.Number
+ && poster.TryGetInt32(out var frame) && frame > 0 ? frame : 0;
+
private static string? Text(JsonElement item, string name) =>
item.ValueKind == JsonValueKind.Object && item.TryGetProperty(name, out var value) && value.ValueKind == JsonValueKind.String
&& value.GetString() is { Length: > 0 } text ? text : null;
diff --git a/src/Filee.App/Controls/SlideShow.cs b/src/Filee.App/Controls/SlideShow.cs
index 3a5192bd..28007b07 100644
--- a/src/Filee.App/Controls/SlideShow.cs
+++ b/src/Filee.App/Controls/SlideShow.cs
@@ -35,6 +35,7 @@ public sealed class SlideShow : UserControl
private readonly List<(TextBlock Title, TextBlock Text, StackPanel Panel)> _slideTexts = [];
private IReadOnlyList<Slide> _slides = [];
private Func<string, string> _localize = key => key;
+ private Func<string?> _language = () => null;
private DispatcherTimer? _advance;
private int _index;
@@ -109,10 +110,11 @@ public sealed class SlideShow : UserControl
public event EventHandler? IndexChanged;
/// <summary>Shows <paramref name="slides"/> from the first, their texts looked up with <paramref name="localize"/>.</summary>
- public void Show(IReadOnlyList<Slide> slides, Func<string, string> localize)
+ public void Show(IReadOnlyList<Slide> slides, Func<string, string> localize, Func<string?>? language = null)
{
_slides = slides;
_localize = localize;
+ _language = language ?? (() => null);
_texts.Children.Clear();
_slideTexts.Clear();
foreach (var _ in slides)
@@ -151,6 +153,7 @@ public sealed class SlideShow : UserControl
_slideTexts[i].Title.Text = _localize(_slides[i].TitleKey);
_slideTexts[i].Text.Text = _localize(_slides[i].TextKey);
}
+ UpdateMedia();
}
public bool Next() => GoTo(_index + 1);
@@ -163,8 +166,7 @@ public sealed class SlideShow : UserControl
if (index < 0 || index >= _slides.Count || index == _index)
return false;
_index = index;
- _media.PosterFrame = _slides[index].PosterFrame;
- _media.Source = _slides[index].Media;
+ UpdateMedia();
for (var i = 0; i < _slideTexts.Count; i++)
{
var current = i == index;
@@ -192,6 +194,15 @@ public sealed class SlideShow : UserControl
}
}
+ private void UpdateMedia()
+ {
+ if (_index < 0 || _index >= _slides.Count)
+ return;
+ var media = _slides[_index].MediaFor(_language());
+ _media.PosterFrame = media.PosterFrame;
+ _media.Source = media.Source;
+ }
+
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
{
base.OnPropertyChanged(change);
diff --git a/src/Filee.App/Views/WhatsNewWindow.axaml.cs b/src/Filee.App/Views/WhatsNewWindow.axaml.cs
index 0ead33c1..bd46d8e5 100644
--- a/src/Filee.App/Views/WhatsNewWindow.axaml.cs
+++ b/src/Filee.App/Views/WhatsNewWindow.axaml.cs
@@ -23,7 +23,7 @@ public partial class WhatsNewWindow : Window
Motion.Track(this);
Slides.PlayAnimations = Motion.Enabled;
Slides.IndexChanged += (_, _) => UpdateButtons();
- Slides.Show(deck.Slides, key => loc[key]);
+ Slides.Show(deck.Slides, key => loc[key], () => loc.Language);
ShowTexts();
Motion.Changed += OnMotionChanged;
loc.LanguageChanged += OnLanguageChanged;
diff --git a/src/Filee.Setup/Views/SetupWindow.axaml.cs b/src/Filee.Setup/Views/SetupWindow.axaml.cs
index ddaa8b7c..54910104 100644
--- a/src/Filee.Setup/Views/SetupWindow.axaml.cs
+++ b/src/Filee.Setup/Views/SetupWindow.axaml.cs
@@ -118,6 +118,9 @@ public partial class SetupWindow : Window
case nameof(SetupViewModel.OptionsOpen):
FocusPrimary();
break;
+ case nameof(SetupViewModel.SelectedLanguage):
+ Find<SlideShow>("Slides")?.RefreshTexts();
+ break;
}
}
@@ -153,7 +156,7 @@ public partial class SetupWindow : Window
Avalonia.Threading.Dispatcher.UIThread.Post(() => slides.Media.Opacity = 1, Avalonia.Threading.DispatcherPriority.Render);
};
}
- slides.Show(deck.Slides, _model.Text);
+ slides.Show(deck.Slides, _model.Text, () => _model.SelectedLanguage.Code);
}
private void FocusPrimary()
diff --git a/tests/Filee.App.Tests/WhatsNewMedia.cs b/tests/Filee.App.Tests/WhatsNewMedia.cs
index cd664867..5be6e726 100644
--- a/tests/Filee.App.Tests/WhatsNewMedia.cs
+++ b/tests/Filee.App.Tests/WhatsNewMedia.cs
@@ -5,11 +5,13 @@
//
// dotnet build tests/Filee.App.Tests
// tests/Filee.App.Tests/bin/Debug/net10.0/Filee.App.Tests.exe -method "Filee.App.Tests.WhatsNewMedia.*" -explicit only
+// Set FILEE_WHATSNEW_LANGUAGE=pt-PT (or pt-BR) for localized recordings; shared English recordings stay unchanged.
//
// Each clip is drawn on a 768 × 432 canvas (16:9, shown at 496 × 279 in the window, sharp up to 150 % scaling) in the
// light theme. The first frame of each clip is what reduced motion shows, so every clip starts on a meaningful picture;
// a clip that marks a better one writes it into slides.json as the slide's "poster".
+using System.Text.Json.Nodes;
using System.Text.RegularExpressions;
using Avalonia.Controls;
using Avalonia.Headless;
@@ -60,28 +62,32 @@ public class WhatsNewMedia
[AvaloniaFact(Explicit = true)]
public void Generate_2_0_0()
{
- TestServices.EnsureInitialized("en");
- var folder = Folder("2.0.0");
+ var language = Environment.GetEnvironmentVariable("FILEE_WHATSNEW_LANGUAGE") ?? "en";
+ Assert.Contains(language, AppLanguages.All.Select(l => l.Code));
+ TestServices.EnsureInitialized(language);
+ var folder = language == "en" ? Folder("2.0.0") : Path.Combine(Folder("2.0.0"), language);
Directory.CreateDirectory(folder);
var theme = AppHost.Get<ThemeService>();
// Animations on whatever this machine prefers: every theme applied here says ReduceMotion = false, since
// ThemeService.Apply reads the setting again.
Motion.Set(true);
- // Times in the history as an English reader expects them, whatever the machine's region.
+ // The recording's region, independently of the machine that generates it.
var culture = System.Globalization.CultureInfo.CurrentCulture;
- System.Globalization.CultureInfo.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo("en-US");
+ System.Globalization.CultureInfo.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo(language == "en" ? "en-US" : language);
try
{
- theme.Apply(new ThemeSettings { ReduceMotion = false, Mode = ThemeMode.Light }, "en");
+ theme.Apply(new ThemeSettings { ReduceMotion = false, Mode = ThemeMode.Light }, language);
// browser.webp and flip.webp come from the demo-video generator (branch media/demo-videos: a scripted desktop
// with a browser and a file manager). These headless versions are written only when asked for by name
// (FILEE_WHATSNEW_ONLY=browser,flip).
- Write(folder, "browser.webp", BrowserDrop, onRequestOnly: true);
- Write(folder, "flip.webp", DonutFlip, onRequestOnly: true);
+ Write(folder, "browser.webp", BrowserDrop, onRequestOnly: language == "en");
+ Write(folder, "flip.webp", DonutFlip, onRequestOnly: language == "en");
Write(folder, "formats.webp", FormatDonuts);
Write(folder, "crop.webp", Crop);
Write(folder, "theme.webp", () => Theme("2.0.0"));
- Write(folder, "languages.webp", () => Languages("2.0.0"));
+ // This slide intentionally demonstrates several languages, rather than the reader's UI language.
+ if (language == "en")
+ Write(folder, "languages.webp", () => Languages("2.0.0"));
Write(folder, "more.webp", () => More("2.0.0"));
}
finally
@@ -432,13 +438,13 @@ public class WhatsNewMedia
private static Clip Theme(string version)
{
// 15 frames a second at a lower quality: every change of colour redraws the whole window.
- var clip = new Clip { Quality = 72 };
+ var clip = new Clip { Quality = AppHost.Get<ILocalizer>().Language == "en" ? 72U : 70U };
var store = AppHost.Get<UserDataStore>();
var theme = AppHost.Get<ThemeService>();
var (themeBefore, opacityBefore) = (store.Settings.Theme, store.Settings.Donut.Opacity);
store.Settings.Theme = new ThemeSettings { ReduceMotion = false, Mode = ThemeMode.Light };
store.Settings.Donut.Opacity = 1;
- theme.Apply(store.Settings.Theme, "en");
+ theme.Apply(store.Settings.Theme, AppHost.Get<ILocalizer>().Language);
var vm = new MainWindowViewModel(AppHost.Services, AppHost.Get<ILocalizer>(), AppHost.Get<UpdateService>());
var window = new MainWindow { DataContext = vm, Width = 1080, Height = 608 };
try
@@ -469,7 +475,7 @@ public class WhatsNewMedia
if (now != applied)
{
applied = now;
- theme.Apply(store.Settings.Theme, "en");
+ theme.Apply(store.Settings.Theme, AppHost.Get<ILocalizer>().Language);
}
});
Avalonia.Point Middle(Control control) =>
@@ -524,7 +530,7 @@ public class WhatsNewMedia
window.Close();
vm.Dispose();
(store.Settings.Theme, store.Settings.Donut.Opacity) = (themeBefore, opacityBefore);
- theme.Apply(new ThemeSettings { ReduceMotion = false, Mode = ThemeMode.Light }, "en");
+ theme.Apply(new ThemeSettings { ReduceMotion = false, Mode = ThemeMode.Light }, AppHost.Get<ILocalizer>().Language);
}
return clip;
@@ -543,7 +549,7 @@ public class WhatsNewMedia
private static Clip Languages(string version)
{
var clip = new Clip();
- foreach (var language in new[] { "es", "hi", "ja", "ru", "ar", "pt-BR", "en", "ko", "zh-CN", "pl" })
+ foreach (var language in AppLanguages.All.Select(l => l.Code))
{
TestServices.EnsureInitialized(language);
AppHost.Get<ThemeService>().Apply(new ThemeSettings { ReduceMotion = false, Mode = ThemeMode.Light }, language);
@@ -569,13 +575,14 @@ public class WhatsNewMedia
var clip = new Clip();
var store = AppHost.Get<UserDataStore>();
var loc = AppHost.Get<ILocalizer>();
+ var report = loc.Language.StartsWith("pt-", StringComparison.Ordinal) ? "relatório" : "report";
store.ClearHistory();
store.History.AddRange(Enumerable.Range(0, store.Settings.EffectiveHistoryLimit).Select(i => new Filee.Core.History.HistoryEntry
{
FinishedAt = DateTime.Now.AddMinutes(-7 * i - 3),
PresetName = i == 150 ? "PDF" : i % 3 == 0 ? "JPG" : "PNG",
State = Filee.Core.Conversion.JobState.Completed,
- Sources = i == 150 ? [@"C:\Work\Annual report.docx"] : [$@"C:\Photos\IMG_{4000 + i:0000}.heic"],
+ Sources = i == 150 ? [$@"C:\Work\{report}.docx"] : [$@"C:\Photos\IMG_{4000 + i:0000}.heic"],
}));
var profiles = store.Profiles.Select(p => p.Clone()).ToList();
try
@@ -587,15 +594,15 @@ public class WhatsNewMedia
Pump();
var home = (HomePageViewModel)vm.CurrentPage!;
// Frame 0: the old report found.
- home.Search = "report";
+ home.Search = report;
Pump();
clip.Add(Capture(window, version), 1400);
home.Search = "";
Pump();
clip.Add(Capture(window, version), 700);
- foreach (var typed in new[] { "r", "re", "rep", "repo", "repor", "report" })
+ for (var length = 1; length <= report.Length; length++)
{
- home.Search = typed;
+ home.Search = report[..length];
Pump();
clip.Add(Capture(window, version), 160);
}
@@ -1003,21 +1010,34 @@ public class WhatsNewMedia
&& only.Split(',', StringSplitOptions.TrimEntries).Contains(Path.GetFileNameWithoutExtension(name), StringComparer.OrdinalIgnoreCase);
if (onRequestOnly ? !named : !string.IsNullOrWhiteSpace(only) && !named)
return;
+ var language = AppHost.Get<ILocalizer>().Language;
+ Console.WriteLine($"Rendering {language}: {name}");
using (var clip = render())
{
var path = Path.Combine(folder, name);
clip.WriteWebP(path);
// The first frame next to the screenshots, for review.
- clip.SaveFirstFrame(Path.Combine(TestServices.ScreenshotDirectory, "whatsnew-" + Path.ChangeExtension(name, ".png")));
+ clip.SaveFirstFrame(Path.Combine(TestServices.ScreenshotDirectory, $"whatsnew-{language}-" + Path.ChangeExtension(name, ".png")));
Assert.InRange(new FileInfo(path).Length, 1, 400 * 1024);
- if (clip.Poster is { } poster)
- SetPoster(folder, name, poster);
+ if (language != "en" || clip.Poster is not null)
+ SetPoster(folder, name, clip.Poster ?? 0);
}
}
/// <summary>Writes the frame a clip marked as its <c>poster</c> into the slide of slides.json that shows it.</summary>
private static void SetPoster(string folder, string media, int frame)
{
+ var language = AppHost.Get<ILocalizer>().Language;
+ if (language != "en")
+ {
+ var manifest = Path.Combine(Path.GetDirectoryName(folder)!, "slides.json");
+ var root = JsonNode.Parse(File.ReadAllText(manifest))!;
+ var item = root["slides"]!.AsArray().Single(s => s!["media"]!.GetValue<string>() == media)!;
+ item["localizedMedia"] ??= new JsonObject();
+ item["localizedMedia"]![language] = new JsonObject { ["media"] = $"{language}/{media}", ["poster"] = frame };
+ File.WriteAllText(manifest, root.ToJsonString(new System.Text.Json.JsonSerializerOptions { WriteIndented = true }) + "\n");
+ return;
+ }
var path = Path.Combine(folder, "slides.json");
var text = File.ReadAllText(path);
var slide = Regex.Match(text, $$"""\{[^{}]*"media": "{{Regex.Escape(media)}}"[^{}]*\}""");
diff --git a/tests/Filee.App.Tests/WhatsNewTests.cs b/tests/Filee.App.Tests/WhatsNewTests.cs
index 8ea98b70..893ec40e 100644
--- a/tests/Filee.App.Tests/WhatsNewTests.cs
+++ b/tests/Filee.App.Tests/WhatsNewTests.cs
@@ -60,7 +60,79 @@ public class WhatsNewTests
.Where(f => !f.EndsWith(".json", StringComparison.OrdinalIgnoreCase)).Select(f => new FileInfo(f)).ToList();
Assert.NotEmpty(media);
Assert.All(media, f => Assert.True(f.Length <= 400 * 1024, $"{f.Name} is {f.Length / 1024} KB"));
- Assert.True(media.Sum(f => f.Length) <= 2 * 1024 * 1024, "the slides' media add up to more than 2 MB");
+ foreach (var pack in media.GroupBy(f => f.DirectoryName))
+ Assert.True(pack.Sum(f => f.Length) <= 2 * 1024 * 1024, $"{pack.Key} adds up to more than 2 MB");
+ Assert.True(media.Sum(f => f.Length) <= 6 * 1024 * 1024, "the shared and Portuguese media exceed 6 MB");
+ }
+
+ [Theory]
+ [InlineData("pt-PT", "pt-PT/crop.webp", 4)]
+ [InlineData("PT-br", "pt-BR/crop.webp", 7)]
+ [InlineData("pt", "crop.webp", 2)]
+ [InlineData("fr", "crop.webp", 2)]
+ [InlineData(null, "crop.webp", 2)]
+ public void Localized_media_use_an_exact_variant_and_their_own_poster(string? language, string path, int poster)
+ {
+ var folder = new Uri("avares://Filee/Assets/WhatsNew/2.0.0/");
+ var deck = SlideDeck.Parse("""
+ { "version": "2.0.0", "slides": [
+ { "id": "crop", "media": "crop.webp", "poster": 2, "title": "t", "text": "x",
+ "localizedMedia": {
+ "pt-PT": { "media": "pt-PT/crop.webp", "poster": 4 },
+ "pt-BR": { "media": "pt-BR/crop.webp", "poster": 7 },
+ "fr": { "media": "../../secret.webp" },
+ "es": { "media": "https://example.com/crop.webp" },
+ "de": "bad entry"
+ } }
+ ] }
+ """, folder)!;
+ var slide = Assert.Single(deck.Slides);
+ Assert.Equal(2, slide.LocalizedMedia.Count);
+ Assert.Equal(new SlideMedia(new Uri(folder, path), poster), slide.MediaFor(language));
+ }
+
+ [AvaloniaTheory]
+ [InlineData("pt-PT")]
+ [InlineData("pt-BR")]
+ public void Portuguese_recordings_ship_for_every_single_language_demonstration(string language)
+ {
+ TestServices.EnsureInitialized(language);
+ var deck = Assert.Single(SlideDeck.LoadAll("Filee"), d => d.Version == V2);
+ foreach (var slide in deck.Slides)
+ {
+ var media = slide.MediaFor(language);
+ Assert.True(AssetLoader.Exists(media.Source), $"{media.Source} is missing");
+ if (slide.Id == "languages")
+ Assert.Equal(slide.Media, media.Source);
+ else
+ Assert.Contains($"/{language}/", media.Source.AbsolutePath);
+ }
+ }
+
+ [AvaloniaFact]
+ public void Changing_language_refreshes_the_current_recording_without_resetting_the_slide()
+ {
+ var window = Open("pt-PT");
+ var loc = AppHost.Get<LocalizationService>();
+ try
+ {
+ var slides = window.SlideShow;
+ slides.GoTo(3);
+ foreach (var language in new[] { "pt-PT", "pt-BR", "en", "pt-PT" })
+ {
+ loc.SetLanguage(language);
+ Pump();
+ Assert.Equal(3, slides.Index);
+ Assert.Equal(slides.Slides[3].MediaFor(language).Source, slides.Media.Source);
+ Assert.True(slides.Media.HasPicture);
+ Assert.Equal(slides.Slides[3].MediaFor(language).PosterFrame, slides.Media.PosterFrame);
+ }
+ }
+ finally
+ {
+ window.Close();
+ TestServices.EnsureInitialized("en");
+ }
}
[Fact]
@@ -310,10 +382,13 @@ public class WhatsNewTests
}
}
- [AvaloniaFact]
- public void Arrow_keys_move_and_escape_closes()
+ [AvaloniaTheory]
+ [InlineData("en")]
+ [InlineData("pt-PT")]
+ [InlineData("pt-BR")]
+ public void Arrow_keys_move_and_escape_closes(string language)
{
- var window = Open();
+ var window = Open(language);
try
{
Press(window, Key.Right);
@@ -372,22 +447,40 @@ public class WhatsNewTests
}
}
- [AvaloniaFact]
- public void Reduced_motion_shows_each_slides_poster_frame()
+ [AvaloniaTheory]
+ [InlineData("en")]
+ [InlineData("pt-PT")]
+ [InlineData("pt-BR")]
+ public void Reduced_motion_shows_each_slides_poster_frame(string language)
{
var before = Motion.Enabled;
- var window = Open(beforeOpening: () => Motion.Set(false)); // after the theme, which applies the setting
+ var window = Open(language, beforeOpening: () => Motion.Set(false)); // after the theme, which applies the setting
try
{
var media = window.SlideShow.Media;
Assert.False(window.SlideShow.PlayAnimations);
Assert.True(media.HasPicture);
Assert.True(media.FrameCount > 1);
- // The first slide names a poster frame: the donut open over the browser, not an empty desktop.
- var poster = window.SlideShow.Slides[0].PosterFrame;
- Assert.True(poster > 0);
+ // Each recording has its own meaningful poster: the localized ones open with the donut already visible.
+ var poster = window.SlideShow.Slides[0].MediaFor(language).PosterFrame;
+ if (language == "en")
+ Assert.True(poster > 0);
Assert.Equal(poster, media.CurrentFrame);
Assert.False(media.IsPlaying);
+ for (var i = 0; i < window.SlideShow.Slides.Count; i++)
+ {
+ window.SlideShow.GoTo(i);
+ Pump();
+ var expected = window.SlideShow.Slides[i].MediaFor(language).PosterFrame;
+ Assert.InRange(expected, 0, media.FrameCount - 1);
+ Assert.Equal(expected, media.CurrentFrame);
+ Assert.True(media.HasPicture);
+ Assert.False(media.IsPlaying);
+ if (language is "pt-PT" or "pt-BR")
+ RenderTests.Save(window, $"whatsnew-poster-{language}-{window.SlideShow.Slides[i].Id}.png");
+ }
+ window.SlideShow.GoTo(0);
+ Pump();
Motion.Set(true);
Pump();
diff --git a/tests/Filee.Setup.Tests/SetupWindowTests.cs b/tests/Filee.Setup.Tests/SetupWindowTests.cs
index 45a67922..fc7ee140 100644
--- a/tests/Filee.Setup.Tests/SetupWindowTests.cs
+++ b/tests/Filee.Setup.Tests/SetupWindowTests.cs
@@ -108,6 +108,10 @@ public class SetupWindowTests
var slides = window.GetVisualDescendants().OfType<SlideShow>().Single();
Assert.True(slides.IsEffectivelyVisible);
Assert.Equal(model.Deck!.Slides.Count, slides.Slides.Count);
+ Assert.Equal(model.Deck.Slides[0].MediaFor(language).Source, slides.Media.Source);
+ Assert.True(slides.Media.HasPicture);
+ if (language is "pt-PT" or "pt-BR")
+ Assert.Contains($"/{language}/", slides.Media.Source!.AbsolutePath);
Check(window, $"setup-3-installing-{language}.png");
runner.Result = new InstallResult(new LaunchRequest(@"C:\Program Files\Filee\Filee.exe", "--install-engines=pandoc"),