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.

fix(i18n): give compact donut actions contextual Portuguese labels

BlackSpirits357c87d31a99
diff --git a/src/Filee.App/Assets/i18n/ar.json b/src/Filee.App/Assets/i18n/ar.json
index 1967ed1a..f4d3b5ee 100644
--- a/src/Filee.App/Assets/i18n/ar.json
+++ b/src/Filee.App/Assets/i18n/ar.json
@@ -199,6 +199,7 @@
"crop.state_skipped": "تم التخطي",
"crop.state_failed": "فشل",
"preset.half_size": "نصف الحجم",
+ "preset.half_size.donut": "نصف الحجم",
"preset.grayscale": "تدرّج رمادي",
"preset.remove_background": "إزالة الخلفية",
"preset.group_rotate": "تدوير",
@@ -224,7 +225,9 @@
"preset.zip_all": "ZIP واحد",
"preset.extract_subtitles": "استخراج الترجمة",
"preset.trace_svg": "تتبّع إلى SVG",
+ "preset.trace_svg.donut": "تتبّع إلى SVG",
"preset.trace_line_art": "رسم خطي إلى SVG",
+ "preset.trace_line_art.donut": "رسم خطي إلى SVG",
"preset.extract_frames_png": "استخراج الإطارات (PNG)",
"preset.extract_frames_jpg": "استخراج الإطارات (JPG)",
"preset.extract_motion": "استخراج فيديو Live Photo",
diff --git a/src/Filee.App/Assets/i18n/en.json b/src/Filee.App/Assets/i18n/en.json
index 74d5f0ad..f6d6649c 100644
--- a/src/Filee.App/Assets/i18n/en.json
+++ b/src/Filee.App/Assets/i18n/en.json
@@ -209,6 +209,7 @@
"crop.state_failed": "Failed",
"preset.half_size": "Half size",
+ "preset.half_size.donut": "Half size",
"preset.grayscale": "Grayscale",
"preset.remove_background": "Remove background",
"preset.group_rotate": "Rotate",
@@ -234,7 +235,9 @@
"preset.zip_all": "One ZIP",
"preset.extract_subtitles": "Extract subtitles",
"preset.trace_svg": "Trace to SVG",
+ "preset.trace_svg.donut": "Trace",
"preset.trace_line_art": "Line art to SVG",
+ "preset.trace_line_art.donut": "Line art",
"preset.extract_frames_png": "Extract frames (PNG)",
"preset.extract_frames_jpg": "Extract frames (JPG)",
"preset.extract_motion": "Extract Live Photo video",
diff --git a/src/Filee.App/Assets/i18n/es.json b/src/Filee.App/Assets/i18n/es.json
index c3a7a66e..e2d681ea 100644
--- a/src/Filee.App/Assets/i18n/es.json
+++ b/src/Filee.App/Assets/i18n/es.json
@@ -199,6 +199,7 @@
"crop.state_skipped": "Omitido",
"crop.state_failed": "Error",
"preset.half_size": "Reducir 50 %",
+ "preset.half_size.donut": "Reducir 50 %",
"preset.grayscale": "Grises",
"preset.remove_background": "Quitar fondo",
"preset.group_rotate": "Rotar",
@@ -224,7 +225,9 @@
"preset.zip_all": "Un solo ZIP",
"preset.extract_subtitles": "Extraer subtítulos",
"preset.trace_svg": "Trazar a SVG",
+ "preset.trace_svg.donut": "Trazar a SVG",
"preset.trace_line_art": "Líneas a SVG",
+ "preset.trace_line_art.donut": "Líneas a SVG",
"preset.extract_frames_png": "Extraer fotogramas (PNG)",
"preset.extract_frames_jpg": "Extraer fotogramas (JPG)",
"preset.extract_motion": "Extraer vídeo de Live Photo",
diff --git a/src/Filee.App/Assets/i18n/hi.json b/src/Filee.App/Assets/i18n/hi.json
index a18f2919..5abe78d9 100644
--- a/src/Filee.App/Assets/i18n/hi.json
+++ b/src/Filee.App/Assets/i18n/hi.json
@@ -199,6 +199,7 @@
"crop.state_skipped": "छोड़ा गया",
"crop.state_failed": "विफल",
"preset.half_size": "आधा आकार",
+ "preset.half_size.donut": "आधा आकार",
"preset.grayscale": "ग्रेस्केल",
"preset.remove_background": "बैकग्राउंड हटाएँ",
"preset.group_rotate": "घुमाएँ",
@@ -224,7 +225,9 @@
"preset.zip_all": "एक ZIP",
"preset.extract_subtitles": "सबटाइटल निकालें",
"preset.trace_svg": "SVG में ट्रेस करें",
+ "preset.trace_svg.donut": "SVG में ट्रेस करें",
"preset.trace_line_art": "लाइन आर्ट को SVG में",
+ "preset.trace_line_art.donut": "लाइन आर्ट को SVG में",
"preset.extract_frames_png": "फ़्रेम निकालें (PNG)",
"preset.extract_frames_jpg": "फ़्रेम निकालें (JPG)",
"preset.extract_motion": "लाइव फ़ोटो वीडियो निकालें",
diff --git a/src/Filee.App/Assets/i18n/ja.json b/src/Filee.App/Assets/i18n/ja.json
index 6866c772..4bd095db 100644
--- a/src/Filee.App/Assets/i18n/ja.json
+++ b/src/Filee.App/Assets/i18n/ja.json
@@ -199,6 +199,7 @@
"crop.state_skipped": "スキップ",
"crop.state_failed": "失敗",
"preset.half_size": "縮小 50%",
+ "preset.half_size.donut": "縮小 50%",
"preset.grayscale": "グレースケール",
"preset.remove_background": "背景を削除",
"preset.group_rotate": "回転",
@@ -224,7 +225,9 @@
"preset.zip_all": "1つに",
"preset.extract_subtitles": "字幕抽出",
"preset.trace_svg": "SVG化",
+ "preset.trace_svg.donut": "SVG化",
"preset.trace_line_art": "線画",
+ "preset.trace_line_art.donut": "線画",
"preset.extract_frames_png": "フレームを抽出(PNG)",
"preset.extract_frames_jpg": "フレームを抽出(JPG)",
"preset.extract_motion": "Live Photoの動画を抽出",
diff --git a/src/Filee.App/Assets/i18n/ko.json b/src/Filee.App/Assets/i18n/ko.json
index 67b57893..961e8a9a 100644
--- a/src/Filee.App/Assets/i18n/ko.json
+++ b/src/Filee.App/Assets/i18n/ko.json
@@ -209,6 +209,7 @@
"crop.state_failed": "실패",
"preset.half_size": "50% 축소",
+ "preset.half_size.donut": "50% 축소",
"preset.grayscale": "흑백",
"preset.remove_background": "배경 제거",
"preset.group_rotate": "회전",
@@ -234,7 +235,9 @@
"preset.zip_all": "ZIP 하나로",
"preset.extract_subtitles": "자막 추출",
"preset.trace_svg": "벡터화",
+ "preset.trace_svg.donut": "벡터화",
"preset.trace_line_art": "흑백 선화",
+ "preset.trace_line_art.donut": "흑백 선화",
"preset.extract_frames_png": "프레임 추출 (PNG)",
"preset.extract_frames_jpg": "프레임 추출 (JPG)",
"preset.extract_motion": "라이브 포토 동영상 추출",
diff --git a/src/Filee.App/Assets/i18n/pl.json b/src/Filee.App/Assets/i18n/pl.json
index 81f0dc24..d16927f1 100644
--- a/src/Filee.App/Assets/i18n/pl.json
+++ b/src/Filee.App/Assets/i18n/pl.json
@@ -209,6 +209,7 @@
"crop.state_failed": "Błąd",
"preset.half_size": "Połowa rozmiaru",
+ "preset.half_size.donut": "Połowa rozmiaru",
"preset.grayscale": "Skala szarości",
"preset.remove_background": "Usuń tło",
"preset.group_rotate": "Obróć",
@@ -234,7 +235,9 @@
"preset.zip_all": "Jeden ZIP",
"preset.extract_subtitles": "Wyodrębnij napisy",
"preset.trace_svg": "Wektoryzuj do SVG",
+ "preset.trace_svg.donut": "Wektoryzuj do SVG",
"preset.trace_line_art": "Rysunek do SVG",
+ "preset.trace_line_art.donut": "Rysunek do SVG",
"preset.extract_frames_png": "Wyodrębnij klatki (PNG)",
"preset.extract_frames_jpg": "Wyodrębnij klatki (JPG)",
"preset.extract_motion": "Wyodrębnij wideo z Live Photo",
diff --git a/src/Filee.App/Assets/i18n/pt-BR.json b/src/Filee.App/Assets/i18n/pt-BR.json
index f25040b8..49c88639 100644
--- a/src/Filee.App/Assets/i18n/pt-BR.json
+++ b/src/Filee.App/Assets/i18n/pt-BR.json
@@ -209,6 +209,7 @@
"crop.state_failed": "Falhou",
"preset.half_size": "Metade do tamanho",
+ "preset.half_size.donut": "Tamanho 50 %",
"preset.grayscale": "Escala de cinza",
"preset.remove_background": "Remover fundo",
"preset.group_rotate": "Girar",
@@ -234,7 +235,9 @@
"preset.zip_all": "Um só ZIP",
"preset.extract_subtitles": "Extrair legendas",
"preset.trace_svg": "Vetorizar para SVG",
+ "preset.trace_svg.donut": "Vetorizar",
"preset.trace_line_art": "Traços para SVG",
+ "preset.trace_line_art.donut": "Traços",
"preset.extract_frames_png": "Extrair quadros (PNG)",
"preset.extract_frames_jpg": "Extrair quadros (JPG)",
"preset.extract_motion": "Extrair vídeo da Live Photo",
diff --git a/src/Filee.App/Assets/i18n/pt-PT.json b/src/Filee.App/Assets/i18n/pt-PT.json
index 5310c9b4..2eb51a38 100644
--- a/src/Filee.App/Assets/i18n/pt-PT.json
+++ b/src/Filee.App/Assets/i18n/pt-PT.json
@@ -209,6 +209,7 @@
"crop.state_failed": "Falhou",
"preset.half_size": "Metade do tamanho",
+ "preset.half_size.donut": "Tamanho 50 %",
"preset.grayscale": "Escala de cinzentos",
"preset.remove_background": "Remover fundo",
"preset.group_rotate": "Rodar",
@@ -234,7 +235,9 @@
"preset.zip_all": "Um só ZIP",
"preset.extract_subtitles": "Extrair legendas",
"preset.trace_svg": "Vetorizar para SVG",
+ "preset.trace_svg.donut": "Vetorizar",
"preset.trace_line_art": "Traços para SVG",
+ "preset.trace_line_art.donut": "Traços",
"preset.extract_frames_png": "Extrair fotogramas (PNG)",
"preset.extract_frames_jpg": "Extrair fotogramas (JPG)",
"preset.extract_motion": "Extrair vídeo da Live Photo",
diff --git a/src/Filee.App/Assets/i18n/ru.json b/src/Filee.App/Assets/i18n/ru.json
index fe94522c..00ec49f0 100644
--- a/src/Filee.App/Assets/i18n/ru.json
+++ b/src/Filee.App/Assets/i18n/ru.json
@@ -209,6 +209,7 @@
"crop.state_failed": "Ошибка",
"preset.half_size": "Вдвое меньше",
+ "preset.half_size.donut": "Вдвое меньше",
"preset.grayscale": "Оттенки серого",
"preset.remove_background": "Убрать фон",
"preset.group_rotate": "Повернуть",
@@ -234,7 +235,9 @@
"preset.zip_all": "Один ZIP",
"preset.extract_subtitles": "Извлечь субтитры",
"preset.trace_svg": "Обвести в SVG",
+ "preset.trace_svg.donut": "Обвести в SVG",
"preset.trace_line_art": "Линии в SVG",
+ "preset.trace_line_art.donut": "Линии в SVG",
"preset.extract_frames_png": "Кадры в картинки (PNG)",
"preset.extract_frames_jpg": "Кадры в картинки (JPG)",
"preset.extract_motion": "Видео из Live Photo",
diff --git a/src/Filee.App/Assets/i18n/zh-CN.json b/src/Filee.App/Assets/i18n/zh-CN.json
index 20566b72..bf00434d 100644
--- a/src/Filee.App/Assets/i18n/zh-CN.json
+++ b/src/Filee.App/Assets/i18n/zh-CN.json
@@ -209,6 +209,7 @@
"crop.state_failed": "失败",
"preset.half_size": "缩小 50%",
+ "preset.half_size.donut": "缩小 50%",
"preset.grayscale": "灰度",
"preset.remove_background": "去除背景",
"preset.group_rotate": "旋转",
@@ -234,7 +235,9 @@
"preset.zip_all": "打包成一个 ZIP",
"preset.extract_subtitles": "提取字幕",
"preset.trace_svg": "描摹",
+ "preset.trace_svg.donut": "描摹",
"preset.trace_line_art": "黑白描摹",
+ "preset.trace_line_art.donut": "黑白描摹",
"preset.extract_frames_png": "提取帧 (PNG)",
"preset.extract_frames_jpg": "提取帧 (JPG)",
"preset.extract_motion": "提取实况/动态照片视频",
diff --git a/src/Filee.App/ViewModels/RadialViewModel.cs b/src/Filee.App/ViewModels/RadialViewModel.cs
index 9e6705cc..067e0d03 100644
--- a/src/Filee.App/ViewModels/RadialViewModel.cs
+++ b/src/Filee.App/ViewModels/RadialViewModel.cs
@@ -238,7 +238,7 @@ public sealed partial class RadialViewModel(UserDataStore store, ILocalizer loc,
{
Id = p.Id,
// On a group's ring the group's name gives the context: "Rotate" → Left / Right / 180°.
- Label = caption ? loc.DisplayName(p) : loc.RingName(p),
+ Label = caption ? loc.DonutName(p) : loc.RingName(p),
Caption = !caption ? null
: p.TargetFormat == BuiltInData.SameAsSource
? string.Join("/", formats.Select(f => f.DisplayName).Take(2))
diff --git a/src/Filee.Core/Localization/ILocalizer.cs b/src/Filee.Core/Localization/ILocalizer.cs
index d1186b88..72e8525e 100644
--- a/src/Filee.Core/Localization/ILocalizer.cs
+++ b/src/Filee.Core/Localization/ILocalizer.cs
@@ -30,6 +30,16 @@ public static class LocalizerExtensions
: preset.NameKey is not null ? loc[preset.NameKey]
: preset.TargetFormat.ToUpperInvariant();
+ /// <summary>A compact name on the donut, where the target format is already shown underneath.</summary>
+ public static string DonutName(this ILocalizer loc, Preset preset)
+ {
+ if (!string.IsNullOrWhiteSpace(preset.Name) || preset.NameKey is null)
+ return loc.DisplayName(preset);
+ var key = preset.NameKey + ".donut";
+ var text = loc[key];
+ return text == key ? loc.DisplayName(preset) : text;
+ }
+
/// <summary>
/// The name on a slice of a group's ring, where the group's name already says what it is about: a built-in
/// preset's short name (its <see cref="Preset.NameKey"/> + <c>.short</c>, "Left" for "Rotate left") when it has one,
diff --git a/tests/Filee.App.Tests/DonutLabelPlacementTests.cs b/tests/Filee.App.Tests/DonutLabelPlacementTests.cs
index 27b44c8e..6b3c999d 100644
--- a/tests/Filee.App.Tests/DonutLabelPlacementTests.cs
+++ b/tests/Filee.App.Tests/DonutLabelPlacementTests.cs
@@ -8,8 +8,12 @@ using Avalonia.Controls;
using Avalonia.Headless;
using Avalonia.Headless.XUnit;
using Avalonia.Media;
+using Avalonia.Media.TextFormatting;
using Avalonia.Threading;
using Filee.App.Controls;
+using Filee.App.Services;
+using Filee.Core.Localization;
+using Filee.Core.Presets;
namespace Filee.App.Tests;
@@ -103,6 +107,30 @@ public class DonutLabelPlacementTests
Assert.Equal("Merge PDF", DonutMenu.KeepKoreanWords("Merge PDF"));
}
+ [AvaloniaTheory]
+ [InlineData("pt-PT", "preset.half_size")]
+ [InlineData("pt-BR", "preset.half_size")]
+ [InlineData("pt-PT", "preset.trace_line_art")]
+ [InlineData("pt-BR", "preset.trace_line_art")]
+ [InlineData("pt-PT", "preset.trace_svg")]
+ [InlineData("pt-BR", "preset.trace_svg")]
+ public void Portuguese_image_actions_fit_the_two_line_slice_label(string language, string key)
+ {
+ TestServices.EnsureInitialized(language);
+ var loc = AppHost.Get<LocalizationService>();
+ var preset = BuiltInData.CreatePresets().Single(p => p.NameKey == key);
+ var label = loc.DonutName(preset);
+ Assert.Equal(loc[key], loc.DisplayName(preset));
+ preset.Name = "My custom action";
+ Assert.Equal(preset.Name, loc.DonutName(preset));
+ var typeface = new Typeface(SoftPalette.FontFamilyFor(language), FontStyle.Normal, FontWeight.SemiBold);
+ var donut = new DonutMenu();
+ // Compact image donuts leave roughly 50 px for an action, over at most two lines.
+ using var text = new TextLayout(label, typeface, donut.LabelSize(label, typeface, 50), Brushes.Black,
+ textWrapping: TextWrapping.Wrap, textTrimming: TextTrimming.CharacterEllipsis, maxWidth: 50, maxLines: 2);
+ Assert.All(text.TextLines, line => Assert.False(line.HasCollapsed, $"{language}: {label} is truncated"));
+ }
+
private static (byte[] Pixels, int Width, int Height) Read(Avalonia.Media.Imaging.WriteableBitmap bitmap)
{
using var buffer = bitmap.Lock();