From 62d7256db43d03eb56084fe82e21641ef8fa1ceb Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sat, 24 May 2025 16:07:15 +0800 Subject: [PATCH] Support transaltion for preview information --- .../Flow.Launcher.Plugin.Explorer/Languages/en.xaml | 8 ++++++++ .../Views/PreviewPanel.xaml.cs | 11 +++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml index ca994455a..eefd6f4eb 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml @@ -167,4 +167,12 @@ Display native context menu (experimental) Below you can specify items you want to include in the context menu, they can be partial (e.g. 'pen wit') or complete ('Open with'). Below you can specify items you want to exclude from context menu, they can be partial (e.g. 'pen wit') or complete ('Open with'). + + + Today + {0} days ago + 1 month ago + {0} months ago + 1 year ago + {0} years ago diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml.cs index eabe1ad41..e1a957199 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml.cs @@ -103,19 +103,22 @@ public partial class PreviewPanel : UserControl, INotifyPropertyChanged var difference = now - fileDateTime; if (difference.TotalDays < 1) - return "Today"; + return Main.Context.API.GetTranslation("Today"); if (difference.TotalDays < 30) - return $"{(int)difference.TotalDays} days ago"; + return string.Format(Main.Context.API.GetTranslation("DaysAgo"), (int)difference.TotalDays); var monthsDiff = (now.Year - fileDateTime.Year) * 12 + now.Month - fileDateTime.Month; + if (monthsDiff == 1) + return Main.Context.API.GetTranslation("OneMonthAgo"); if (monthsDiff < 12) - return monthsDiff == 1 ? "1 month ago" : $"{monthsDiff} months ago"; + return string.Format(Main.Context.API.GetTranslation("MonthsAgo"), monthsDiff); var yearsDiff = now.Year - fileDateTime.Year; if (now.Month < fileDateTime.Month || (now.Month == fileDateTime.Month && now.Day < fileDateTime.Day)) yearsDiff--; - return yearsDiff == 1 ? "1 year ago" : $"{yearsDiff} years ago"; + return yearsDiff == 1 ? Main.Context.API.GetTranslation("OneYearAgo") : + string.Format(Main.Context.API.GetTranslation("YearsAgo"), yearsDiff); } public event PropertyChangedEventHandler? PropertyChanged;