Add OnCultureInfoChanged to IPluginI18n to allow plugin do action when culture change

This commit is contained in:
Kevin Zhang 2021-10-29 22:16:13 -05:00
parent 582e29658b
commit 255f8091a5
3 changed files with 19 additions and 2 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,10 @@
string GetTranslatedPluginTitle();
string GetTranslatedPluginDescription();
void OnCultureInfoChanged(CultureInfo newCulture)
{
}
}
}

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>