Skip to content

Commit 7350c1d

Browse files
committed
Use Flow.Launcher.Localization to improve code quality
1 parent d87650d commit 7350c1d

19 files changed

+129
-131
lines changed

Flow.Launcher.Core/Configuration/Portable.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void DisablePortableMode()
4545
#endif
4646
IndicateDeletion(DataLocation.PortableDataPath);
4747

48-
API.ShowMsgBox(API.GetTranslation("restartToDisablePortableMode"));
48+
API.ShowMsgBox(Localize.restartToDisablePortableMode());
4949

5050
UpdateManager.RestartApp(Constant.ApplicationFileName);
5151
}
@@ -68,7 +68,7 @@ public void EnablePortableMode()
6868
#endif
6969
IndicateDeletion(DataLocation.RoamingDataPath);
7070

71-
API.ShowMsgBox(API.GetTranslation("restartToEnablePortableMode"));
71+
API.ShowMsgBox(Localize.restartToEnablePortableMode());
7272

7373
UpdateManager.RestartApp(Constant.ApplicationFileName);
7474
}
@@ -152,7 +152,7 @@ public void PreStartCleanUpAfterPortabilityUpdate()
152152
{
153153
FilesFolders.RemoveFolderIfExists(roamingDataDir, (s) => API.ShowMsgBox(s));
154154

155-
if (API.ShowMsgBox(API.GetTranslation("moveToDifferentLocation"),
155+
if (API.ShowMsgBox(Localize.moveToDifferentLocation(),
156156
string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
157157
{
158158
FilesFolders.OpenPath(Constant.RootDirectory, (s) => API.ShowMsgBox(s));
@@ -166,7 +166,7 @@ public void PreStartCleanUpAfterPortabilityUpdate()
166166
{
167167
FilesFolders.RemoveFolderIfExists(portableDataDir, (s) => API.ShowMsgBox(s));
168168

169-
API.ShowMsgBox(API.GetTranslation("shortcutsUninstallerCreated"));
169+
API.ShowMsgBox(Localize.shortcutsUninstallerCreated());
170170
}
171171
}
172172

@@ -177,8 +177,7 @@ public bool CanUpdatePortability()
177177

178178
if (roamingLocationExists && portableLocationExists)
179179
{
180-
API.ShowMsgBox(string.Format(API.GetTranslation("userDataDuplicated"),
181-
DataLocation.PortableDataPath, DataLocation.RoamingDataPath, Environment.NewLine));
180+
API.ShowMsgBox(Localize.userDataDuplicated(DataLocation.PortableDataPath, DataLocation.RoamingDataPath, Environment.NewLine));
182181

183182
return false;
184183
}

Flow.Launcher.Core/ExternalPlugins/Environments/AbstractPluginEnvironment.cs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,10 @@ internal IEnumerable<PluginPair> Setup()
5858
return SetPathForPluginPairs(PluginsSettingsFilePath, Language);
5959
}
6060

61-
var noRuntimeMessage = string.Format(
62-
API.GetTranslation("runtimePluginInstalledChooseRuntimePrompt"),
63-
Language,
64-
EnvName,
65-
Environment.NewLine
66-
);
61+
var noRuntimeMessage = Localize.runtimePluginInstalledChooseRuntimePrompt(Language, EnvName, Environment.NewLine);
6762
if (API.ShowMsgBox(noRuntimeMessage, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.No)
6863
{
69-
var msg = string.Format(API.GetTranslation("runtimePluginChooseRuntimeExecutable"), EnvName);
64+
var msg = Localize.runtimePluginChooseRuntimeExecutable(EnvName);
7065

7166
var selectedFile = GetFileFromDialog(msg, FileDialogFilter);
7267

@@ -77,12 +72,7 @@ internal IEnumerable<PluginPair> Setup()
7772
// Nothing selected because user pressed cancel from the file dialog window
7873
else
7974
{
80-
var forceDownloadMessage = string.Format(
81-
API.GetTranslation("runtimeExecutableInvalidChooseDownload"),
82-
Language,
83-
EnvName,
84-
Environment.NewLine
85-
);
75+
var forceDownloadMessage = Localize.runtimeExecutableInvalidChooseDownload(Language, EnvName, Environment.NewLine);
8676

8777
// Let users select valid path or choose to download
8878
while (string.IsNullOrEmpty(selectedFile))
@@ -120,7 +110,7 @@ internal IEnumerable<PluginPair> Setup()
120110
}
121111
else
122112
{
123-
API.ShowMsgBox(string.Format(API.GetTranslation("runtimePluginUnableToSetExecutablePath"), Language));
113+
API.ShowMsgBox(Localize.runtimePluginUnableToSetExecutablePath(Language));
124114
API.LogError(ClassName,
125115
$"Not able to successfully set {EnvName} path, setting's plugin executable path variable is still an empty string.",
126116
$"{Language}Environment");

Flow.Launcher.Core/ExternalPlugins/Environments/PythonEnvironment.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ internal override void InstallEnvironment()
5151
}
5252
catch (System.Exception e)
5353
{
54-
API.ShowMsgError(API.GetTranslation("failToInstallPythonEnv"));
54+
API.ShowMsgError(Localize.failToInstallPythonEnv());
5555
API.LogException(ClassName, "Failed to install Python environment", e);
5656
}
5757
});

Flow.Launcher.Core/ExternalPlugins/Environments/TypeScriptEnvironment.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ internal override void InstallEnvironment()
4646
}
4747
catch (System.Exception e)
4848
{
49-
API.ShowMsgError(API.GetTranslation("failToInstallTypeScriptEnv"));
49+
API.ShowMsgError(Localize.failToInstallTypeScriptEnv());
5050
API.LogException(ClassName, "Failed to install TypeScript environment", e);
5151
}
5252
});

Flow.Launcher.Core/ExternalPlugins/Environments/TypeScriptV2Environment.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ internal override void InstallEnvironment()
4646
}
4747
catch (System.Exception e)
4848
{
49-
API.ShowMsgError(API.GetTranslation("failToInstallTypeScriptEnv"));
49+
API.ShowMsgError(Localize.failToInstallTypeScriptEnv());
5050
API.LogException(ClassName, "Failed to install TypeScript environment", e);
5151
}
5252
});

Flow.Launcher.Core/Flow.Launcher.Core.csproj

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>net9.0-windows</TargetFramework>
@@ -34,6 +34,7 @@
3434
<ErrorReport>prompt</ErrorReport>
3535
<WarningLevel>4</WarningLevel>
3636
<Prefer32Bit>false</Prefer32Bit>
37+
<NoWarn>$(NoWarn);FLSG0007</NoWarn>
3738
</PropertyGroup>
3839

3940
<ItemGroup>
@@ -55,13 +56,25 @@
5556

5657
<ItemGroup>
5758
<PackageReference Include="Droplex" Version="1.7.0" />
59+
<PackageReference Include="Flow.Launcher.Localization" Version="0.0.6" />
5860
<PackageReference Include="FSharp.Core" Version="9.0.303" />
5961
<PackageReference Include="Meziantou.Framework.Win32.Jobs" Version="3.4.4" />
6062
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.1" />
6163
<PackageReference Include="SemanticVersioning" Version="3.0.0" />
6264
<PackageReference Include="squirrel.windows" Version="1.5.2" NoWarn="NU1701" />
6365
<PackageReference Include="StreamJsonRpc" Version="2.22.11" />
6466
</ItemGroup>
67+
68+
<PropertyGroup>
69+
<FLLUseDependencyInjection>true</FLLUseDependencyInjection>
70+
</PropertyGroup>
71+
72+
<ItemGroup>
73+
<AdditionalFiles Remove="Languages\en.xaml" />
74+
<AdditionalFiles Include="..\Flow.Launcher\Languages\en.xaml">
75+
<Link>Languages\en.xaml</Link>
76+
</AdditionalFiles>
77+
</ItemGroup>
6578

6679
<ItemGroup>
6780
<ProjectReference Include="..\Flow.Launcher.Infrastructure\Flow.Launcher.Infrastructure.csproj" />

Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ public Control CreateSettingPanel()
285285
HorizontalAlignment = HorizontalAlignment.Left,
286286
VerticalAlignment = VerticalAlignment.Center,
287287
Margin = SettingPanelItemLeftMargin,
288-
Content = API.GetTranslation("select")
288+
Content = Localize.select()
289289
};
290290

291291
Btn.Click += (_, _) =>

0 commit comments

Comments
 (0)