Skip to content

Commit ff2d5e8

Browse files
authored
Merge pull request #3849 from Flow-Launcher/translations
Add Translations for All Messages and Message Boxes
2 parents d3824f2 + d71d3a5 commit ff2d5e8

File tree

22 files changed

+96
-68
lines changed

22 files changed

+96
-68
lines changed

Flow.Launcher.Core/Configuration/Portable.cs

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

48-
API.ShowMsgBox("Flow Launcher needs to restart to finish disabling portable mode, " +
49-
"after the restart your portable data profile will be deleted and roaming data profile kept");
48+
API.ShowMsgBox(API.GetTranslation("restartToDisablePortableMode"));
5049

5150
UpdateManager.RestartApp(Constant.ApplicationFileName);
5251
}
@@ -69,8 +68,7 @@ public void EnablePortableMode()
6968
#endif
7069
IndicateDeletion(DataLocation.RoamingDataPath);
7170

72-
API.ShowMsgBox("Flow Launcher needs to restart to finish enabling portable mode, " +
73-
"after the restart your roaming data profile will be deleted and portable data profile kept");
71+
API.ShowMsgBox(API.GetTranslation("restartToEnablePortableMode"));
7472

7573
UpdateManager.RestartApp(Constant.ApplicationFileName);
7674
}
@@ -154,9 +152,8 @@ public void PreStartCleanUpAfterPortabilityUpdate()
154152
{
155153
FilesFolders.RemoveFolderIfExists(roamingDataDir, (s) => API.ShowMsgBox(s));
156154

157-
if (API.ShowMsgBox("Flow Launcher has detected you enabled portable mode, " +
158-
"would you like to move it to a different location?", string.Empty,
159-
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
155+
if (API.ShowMsgBox(API.GetTranslation("moveToDifferentLocation"),
156+
string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
160157
{
161158
FilesFolders.OpenPath(Constant.RootDirectory, (s) => API.ShowMsgBox(s));
162159

@@ -169,8 +166,7 @@ public void PreStartCleanUpAfterPortabilityUpdate()
169166
{
170167
FilesFolders.RemoveFolderIfExists(portableDataDir, (s) => API.ShowMsgBox(s));
171168

172-
API.ShowMsgBox("Flow Launcher has detected you disabled portable mode, " +
173-
"the relevant shortcuts and uninstaller entry have been created");
169+
API.ShowMsgBox(API.GetTranslation("shortcutsUninstallerCreated"));
174170
}
175171
}
176172

@@ -181,9 +177,8 @@ public bool CanUpdatePortability()
181177

182178
if (roamingLocationExists && portableLocationExists)
183179
{
184-
API.ShowMsgBox(string.Format("Flow Launcher detected your user data exists both in {0} and " +
185-
"{1}. {2}{2}Please delete {1} in order to proceed. No changes have occurred.",
186-
DataLocation.PortableDataPath, DataLocation.RoamingDataPath, Environment.NewLine));
180+
API.ShowMsgBox(string.Format(API.GetTranslation("userDataDuplicated"),
181+
DataLocation.PortableDataPath, DataLocation.RoamingDataPath, Environment.NewLine));
187182

188183
return false;
189184
}

Flow.Launcher.Core/ExternalPlugins/PluginsManifest.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ public static class PluginsManifest
2222
private static DateTime lastFetchedAt = DateTime.MinValue;
2323
private static readonly TimeSpan fetchTimeout = TimeSpan.FromMinutes(2);
2424

25+
// We should not initialize API in static constructor because it will create another API instance
26+
private static IPublicAPI api = null;
27+
private static IPublicAPI API => api ??= Ioc.Default.GetRequiredService<IPublicAPI>();
28+
2529
public static List<UserPlugin> UserPlugins { get; private set; }
2630

2731
public static async Task<bool> UpdateManifestAsync(bool usePrimaryUrlOnly = false, CancellationToken token = default)
@@ -46,7 +50,7 @@ public static async Task<bool> UpdateManifestAsync(bool usePrimaryUrlOnly = fals
4650
}
4751
catch (Exception e)
4852
{
49-
Ioc.Default.GetRequiredService<IPublicAPI>().LogException(ClassName, "Http request failed", e);
53+
API.LogException(ClassName, "Http request failed", e);
5054
}
5155
finally
5256
{

Flow.Launcher.Core/Plugin/PluginManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ internal static async Task<bool> UninstallPluginAsync(PluginMetadata plugin, boo
719719
catch (Exception e)
720720
{
721721
API.LogException(ClassName, $"Failed to delete plugin settings folder for {plugin.Name}", e);
722-
API.ShowMsg(API.GetTranslation("failedToRemovePluginSettingsTitle"),
722+
API.ShowMsgError(API.GetTranslation("failedToRemovePluginSettingsTitle"),
723723
string.Format(API.GetTranslation("failedToRemovePluginSettingsMessage"), plugin.Name));
724724
}
725725
}
@@ -735,7 +735,7 @@ internal static async Task<bool> UninstallPluginAsync(PluginMetadata plugin, boo
735735
catch (Exception e)
736736
{
737737
API.LogException(ClassName, $"Failed to delete plugin cache folder for {plugin.Name}", e);
738-
API.ShowMsg(API.GetTranslation("failedToRemovePluginCacheTitle"),
738+
API.ShowMsgError(API.GetTranslation("failedToRemovePluginCacheTitle"),
739739
string.Format(API.GetTranslation("failedToRemovePluginCacheMessage"), plugin.Name));
740740
}
741741
Settings.RemovePluginSettings(plugin.ID);

Flow.Launcher.Core/Plugin/PluginsLoader.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,15 @@ private static IEnumerable<PluginPair> DotNetPlugins(List<PluginMetadata> source
120120
{
121121
var errorPluginString = string.Join(Environment.NewLine, erroredPlugins);
122122

123-
var errorMessage = "The following "
124-
+ (erroredPlugins.Count > 1 ? "plugins have " : "plugin has ")
125-
+ "errored and cannot be loaded:";
123+
var errorMessage = erroredPlugins.Count > 1 ?
124+
API.GetTranslation("pluginsHaveErrored") :
125+
API.GetTranslation("pluginHasErrored");
126126

127127
_ = Task.Run(() =>
128128
{
129-
Ioc.Default.GetRequiredService<IPublicAPI>().ShowMsgBox($"{errorMessage}{Environment.NewLine}{Environment.NewLine}" +
129+
API.ShowMsgBox($"{errorMessage}{Environment.NewLine}{Environment.NewLine}" +
130130
$"{errorPluginString}{Environment.NewLine}{Environment.NewLine}" +
131-
$"Please refer to the logs for more information", "",
131+
API.GetTranslation("referToLogs"), string.Empty,
132132
MessageBoxButton.OK, MessageBoxImage.Warning);
133133
});
134134
}

Flow.Launcher.Core/Resource/Internationalization.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public bool PromptShouldUsePinyin(string languageCodeToSet)
214214
// "Do you want to search with pinyin?"
215215
string text = languageToSet == AvailableLanguages.Chinese ? "是否启用拼音搜索?" : "是否啓用拼音搜索?" ;
216216

217-
if (Ioc.Default.GetRequiredService<IPublicAPI>().ShowMsgBox(text, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.No)
217+
if (API.ShowMsgBox(text, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.No)
218218
return false;
219219

220220
return true;

Flow.Launcher.Core/Updater.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public async Task UpdateAppAsync(bool silentUpdate = true)
111111
}
112112

113113
if (!silentUpdate)
114-
_api.ShowMsg(_api.GetTranslation("update_flowlauncher_fail"),
114+
_api.ShowMsgError(_api.GetTranslation("update_flowlauncher_fail"),
115115
_api.GetTranslation("update_flowlauncher_check_connection"));
116116
}
117117
finally

Flow.Launcher.Infrastructure/Http/Http.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ public static class Http
2020

2121
private static readonly HttpClient client = new();
2222

23+
// We should not initialize API in static constructor because it will create another API instance
24+
private static IPublicAPI api = null;
25+
private static IPublicAPI API => api ??= Ioc.Default.GetRequiredService<IPublicAPI>();
26+
2327
static Http()
2428
{
2529
// need to be added so it would work on a win10 machine
@@ -78,7 +82,7 @@ var userName when string.IsNullOrEmpty(userName) =>
7882
}
7983
catch (UriFormatException e)
8084
{
81-
Ioc.Default.GetRequiredService<IPublicAPI>().ShowMsg("Please try again", "Unable to parse Http Proxy");
85+
API.ShowMsgError(API.GetTranslation("pleaseTryAgain"), API.GetTranslation("parseProxyFailed"));
8286
Log.Exception(ClassName, "Unable to parse Uri", e);
8387
}
8488
}

Flow.Launcher/App.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ private static void AutoStartup()
267267
// but if it fails (permissions, etc) then don't keep retrying
268268
// this also gives the user a visual indication in the Settings widget
269269
_settings.StartFlowLauncherOnSystemStartup = false;
270-
API.ShowMsg(API.GetTranslation("setAutoStartFailed"), e.Message);
270+
API.ShowMsgError(API.GetTranslation("setAutoStartFailed"), e.Message);
271271
}
272272
}
273273
}

Flow.Launcher/Languages/en.xaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,22 @@
1818
<system:String x:Key="failedToInitializePluginsTitle">Fail to Init Plugins</system:String>
1919
<system:String x:Key="failedToInitializePluginsMessage">Plugins: {0} - fail to load and would be disabled, please contact plugin creator for help</system:String>
2020

21+
<!-- Portable -->
22+
<system:String x:Key="restartToDisablePortableMode">Flow Launcher needs to restart to finish disabling portable mode, after the restart your portable data profile will be deleted and roaming data profile kept</system:String>
23+
<system:String x:Key="restartToEnablePortableMode">Flow Launcher needs to restart to finish enabling portable mode, after the restart your roaming data profile will be deleted and portable data profile kept</system:String>
24+
<system:String x:Key="moveToDifferentLocation">Flow Launcher has detected you enabled portable mode, would you like to move it to a different location?</system:String>
25+
<system:String x:Key="shortcutsUninstallerCreated">Flow Launcher has detected you disabled portable mode, the relevant shortcuts and uninstaller entry have been created</system:String>
26+
<system:String x:Key="userDataDuplicated">Flow Launcher detected your user data exists both in {0} and {1}. {2}{2}Please delete {1} in order to proceed. No changes have occurred.</system:String>
27+
28+
<!-- Plugin Loader -->
29+
<system:String x:Key="pluginHasErrored">The following plugin has errored and cannot be loaded:</system:String>
30+
<system:String x:Key="pluginsHaveErrored">The following plugins have errored and cannot be loaded:</system:String>
31+
<system:String x:Key="referToLogs">Please refer to the logs for more information</system:String>
32+
33+
<!-- Http -->
34+
<system:String x:Key="pleaseTryAgain">Please try again</system:String>
35+
<system:String x:Key="parseProxyFailed">Unable to parse Http Proxy</system:String>
36+
2137
<!-- MainWindow -->
2238
<system:String x:Key="registerHotkeyFailed">Failed to register hotkey "{0}". The hotkey may be in use by another program. Change to a different hotkey, or exit another program.</system:String>
2339
<system:String x:Key="unregisterHotkeyFailed">Failed to unregister hotkey "{0}". Please try again or see log for details</system:String>
@@ -140,6 +156,8 @@
140156
<system:String x:Key="KoreanImeOpenLinkButton">Open</system:String>
141157
<system:String x:Key="KoreanImeRegistry">Use Previous Korean IME</system:String>
142158
<system:String x:Key="KoreanImeRegistryTooltip">You can change the Previous Korean IME settings directly from here</system:String>
159+
<system:String x:Key="KoreanImeSettingChangeFailTitle">Failed to change Korean IME setting</system:String>
160+
<system:String x:Key="KoreanImeSettingChangeFailSubTitle">Please check your system registry access or contact support.</system:String>
143161
<system:String x:Key="homePage">Home Page</system:String>
144162
<system:String x:Key="homePageToolTip">Show home page results when query text is empty.</system:String>
145163
<system:String x:Key="historyResultsForHomePage">Show History Results in Home Page</system:String>

Flow.Launcher/Resources/Pages/WelcomePage5.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ private void ChangeAutoStartup(bool value)
5959
}
6060
catch (Exception e)
6161
{
62-
App.API.ShowMsg(App.API.GetTranslation("setAutoStartFailed"), e.Message);
62+
App.API.ShowMsgError(App.API.GetTranslation("setAutoStartFailed"), e.Message);
6363
}
6464
}
6565

0 commit comments

Comments
 (0)