Skip to content

Commit 62d7256

Browse files
committed
Support transaltion for preview information
1 parent 0f718e5 commit 62d7256

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,12 @@
167167
<system:String x:Key="plugin_explorer_native_context_menu_display_context_menu">Display native context menu (experimental)</system:String>
168168
<system:String x:Key="plugin_explorer_native_context_menu_include_patterns_guide">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').</system:String>
169169
<system:String x:Key="plugin_explorer_native_context_menu_exclude_patterns_guide">Below you can specify items you want to exclude from context menu, they can be partial (e.g. 'pen wit') or complete ('Open with').</system:String>
170+
171+
<!-- Preview Info -->
172+
<system:String x:Key="Today">Today</system:String>
173+
<system:String x:Key="DaysAgo">{0} days ago</system:String>
174+
<system:String x:Key="OneMonthAgo">1 month ago</system:String>
175+
<system:String x:Key="MonthsAgo">{0} months ago</system:String>
176+
<system:String x:Key="OneYearAgo">1 year ago</system:String>
177+
<system:String x:Key="YearsAgo">{0} years ago</system:String>
170178
</ResourceDictionary>

Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,19 +103,22 @@ private static string GetFileAge(DateTime fileDateTime)
103103
var difference = now - fileDateTime;
104104

105105
if (difference.TotalDays < 1)
106-
return "Today";
106+
return Main.Context.API.GetTranslation("Today");
107107
if (difference.TotalDays < 30)
108-
return $"{(int)difference.TotalDays} days ago";
108+
return string.Format(Main.Context.API.GetTranslation("DaysAgo"), (int)difference.TotalDays);
109109

110110
var monthsDiff = (now.Year - fileDateTime.Year) * 12 + now.Month - fileDateTime.Month;
111+
if (monthsDiff == 1)
112+
return Main.Context.API.GetTranslation("OneMonthAgo");
111113
if (monthsDiff < 12)
112-
return monthsDiff == 1 ? "1 month ago" : $"{monthsDiff} months ago";
114+
return string.Format(Main.Context.API.GetTranslation("MonthsAgo"), monthsDiff);
113115

114116
var yearsDiff = now.Year - fileDateTime.Year;
115117
if (now.Month < fileDateTime.Month || (now.Month == fileDateTime.Month && now.Day < fileDateTime.Day))
116118
yearsDiff--;
117119

118-
return yearsDiff == 1 ? "1 year ago" : $"{yearsDiff} years ago";
120+
return yearsDiff == 1 ? Main.Context.API.GetTranslation("OneYearAgo") :
121+
string.Format(Main.Context.API.GetTranslation("YearsAgo"), yearsDiff);
119122
}
120123

121124
public event PropertyChangedEventHandler? PropertyChanged;

0 commit comments

Comments
 (0)