Skip to content

Commit af1d11a

Browse files
committed
Use Flow.Launcher.Localization to improve code quality
1 parent dad5f5a commit af1d11a

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

Plugins/Flow.Launcher.Plugin.Url/Flow.Launcher.Plugin.Url.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<ErrorReport>prompt</ErrorReport>
3434
<WarningLevel>4</WarningLevel>
3535
<Prefer32Bit>false</Prefer32Bit>
36+
<NoWarn>$(NoWarn);FLSG0007</NoWarn>
3637
</PropertyGroup>
3738

3839
<ItemGroup>
@@ -56,4 +57,8 @@
5657
</Content>
5758
</ItemGroup>
5859

60+
<ItemGroup>
61+
<PackageReference Include="Flow.Launcher.Localization" Version="0.0.6" />
62+
</ItemGroup>
63+
5964
</Project>

Plugins/Flow.Launcher.Plugin.Url/Main.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class Main : IPlugin, IPluginI18n
4040
"(?:/\\S*)?" +
4141
"$";
4242
Regex reg = new Regex(urlPattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
43-
private PluginInitContext context;
43+
internal static PluginInitContext Context { get; private set; }
4444
private Settings _settings;
4545

4646
public List<Result> Query(Query query)
@@ -53,7 +53,7 @@ public List<Result> Query(Query query)
5353
new Result
5454
{
5555
Title = raw,
56-
SubTitle = string.Format(context.API.GetTranslation("flowlauncher_plugin_url_open_url"),raw),
56+
SubTitle = Localize.flowlauncher_plugin_url_open_url(raw),
5757
IcoPath = "Images/url.png",
5858
Score = 8,
5959
Action = _ =>
@@ -64,13 +64,13 @@ public List<Result> Query(Query query)
6464
}
6565
try
6666
{
67-
context.API.OpenUrl(raw);
67+
Context.API.OpenUrl(raw);
6868

6969
return true;
7070
}
7171
catch(Exception)
7272
{
73-
context.API.ShowMsgError(string.Format(context.API.GetTranslation("flowlauncher_plugin_url_cannot_open_url"), raw));
73+
Context.API.ShowMsgError(Localize.flowlauncher_plugin_url_cannot_open_url(raw));
7474
return false;
7575
}
7676
}
@@ -99,19 +99,19 @@ public bool IsURL(string raw)
9999

100100
public void Init(PluginInitContext context)
101101
{
102-
this.context = context;
102+
Context = context;
103103

104104
_settings = context.API.LoadSettingJsonStorage<Settings>();
105105
}
106106

107107
public string GetTranslatedPluginTitle()
108108
{
109-
return context.API.GetTranslation("flowlauncher_plugin_url_plugin_name");
109+
return Localize.flowlauncher_plugin_url_plugin_name();
110110
}
111111

112112
public string GetTranslatedPluginDescription()
113113
{
114-
return context.API.GetTranslation("flowlauncher_plugin_url_plugin_description");
114+
return Localize.flowlauncher_plugin_url_plugin_description();
115115
}
116116
}
117117
}

0 commit comments

Comments
 (0)