Merge pull request #781 from Flow-Launcher/translation_new_api

Add OnCultureInfoChanged to IPluginI18n
This commit is contained in:
Jeremy Wu 2021-11-03 06:36:45 +11:00 committed by GitHub
commit d0ceea089d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 26 additions and 10 deletions

View file

@ -10,6 +10,7 @@ using Flow.Launcher.Infrastructure.Logger;
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Plugin;
using System.Globalization;
using System.Threading.Tasks;
namespace Flow.Launcher.Core.Resource
{
@ -95,10 +96,13 @@ namespace Flow.Launcher.Core.Resource
{
LoadLanguage(language);
}
UpdatePluginMetadataTranslations();
Settings.Language = language.LanguageCode;
CultureInfo.CurrentCulture = new CultureInfo(language.LanguageCode);
CultureInfo.CurrentUICulture = CultureInfo.CurrentCulture;
Task.Run(() =>
{
UpdatePluginMetadataTranslations();
});
}
public bool PromptShouldUsePinyin(string languageCodeToSet)

View file

@ -1,4 +1,6 @@
namespace Flow.Launcher.Plugin
using System.Globalization;
namespace Flow.Launcher.Plugin
{
/// <summary>
/// Represent plugins that support internationalization
@ -8,5 +10,13 @@
string GetTranslatedPluginTitle();
string GetTranslatedPluginDescription();
/// <summary>
/// The method will be invoked when language of flow changed
/// </summary>
void OnCultureInfoChanged(CultureInfo newCulture)
{
}
}
}

View file

@ -9,7 +9,7 @@ namespace Flow.Plugin.WindowsSettings.Classes
/// <summary>
/// A windows setting
/// </summary>
internal class WindowsSetting
internal record WindowsSetting
{
/// <summary>
/// Initializes a new instance of the <see cref="WindowsSetting"/> class.

View file

@ -150,12 +150,8 @@ namespace Flow.Plugin.WindowsSettings.Helper
ProcessStartInfo processStartInfo;
var command = entry.Command;
if (command.Contains("%windir%", StringComparison.InvariantCultureIgnoreCase))
{
var windowsFolder = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
command = command.Replace("%windir%", windowsFolder, StringComparison.InvariantCultureIgnoreCase);
}
command = Environment.ExpandEnvironmentVariables(command);
if (command.Contains(' '))
{

View file

@ -80,7 +80,7 @@ namespace Flow.Plugin.WindowsSettings.Helper
}
}
var translatedSetting = new WindowsSetting
var translatedSetting = settings with
{
Area = area ?? settings.Area,
Name = name ?? settings.Name,

View file

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
using Flow.Launcher.Plugin;
using Flow.Plugin.WindowsSettings.Classes;
@ -106,6 +107,11 @@ namespace Flow.Plugin.WindowsSettings
}
public void OnCultureInfoChanged(CultureInfo newCulture)
{
_translatedSettingList = TranslationHelper.TranslateAllSettings(_settingsList);
}
/// <summary>
/// Return a list context menu entries for a given <see cref="Result"/> (shown at the right side of the result).
/// </summary>