mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #1568 from VictoriousRaptor/FixNewCultureInfo
[Dev] Fix new culture info
This commit is contained in:
commit
5b2990cbe9
6 changed files with 32 additions and 23 deletions
|
|
@ -96,9 +96,16 @@ namespace Flow.Launcher.Core.Resource
|
|||
{
|
||||
LoadLanguage(language);
|
||||
}
|
||||
Settings.Language = language.LanguageCode;
|
||||
CultureInfo.CurrentCulture = new CultureInfo(language.LanguageCode);
|
||||
// Culture of this thread
|
||||
// Use CreateSpecificCulture to preserve possible user-override settings in Windows
|
||||
CultureInfo.CurrentCulture = CultureInfo.CreateSpecificCulture(language.LanguageCode);
|
||||
CultureInfo.CurrentUICulture = CultureInfo.CurrentCulture;
|
||||
// App domain
|
||||
CultureInfo.DefaultThreadCurrentCulture = CultureInfo.CreateSpecificCulture(language.LanguageCode);
|
||||
CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.DefaultThreadCurrentCulture;
|
||||
|
||||
// Raise event after culture is set
|
||||
Settings.Language = language.LanguageCode;
|
||||
_ = Task.Run(() =>
|
||||
{
|
||||
UpdatePluginMetadataTranslations();
|
||||
|
|
@ -186,7 +193,7 @@ namespace Flow.Launcher.Core.Resource
|
|||
{
|
||||
p.Metadata.Name = pluginI18N.GetTranslatedPluginTitle();
|
||||
p.Metadata.Description = pluginI18N.GetTranslatedPluginDescription();
|
||||
pluginI18N.OnCultureInfoChanged(CultureInfo.CurrentCulture);
|
||||
pluginI18N.OnCultureInfoChanged(CultureInfo.DefaultThreadCurrentCulture);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ using System.Text.Json.Serialization;
|
|||
using System.Windows;
|
||||
using Flow.Launcher.Plugin;
|
||||
using Flow.Launcher.Plugin.SharedModels;
|
||||
using Flow.Launcher;
|
||||
using Flow.Launcher.ViewModel;
|
||||
|
||||
namespace Flow.Launcher.Infrastructure.UserSettings
|
||||
|
|
|
|||
|
|
@ -52,7 +52,8 @@ namespace Flow.Launcher.Converters
|
|||
|
||||
// Check if Text will be larger then our QueryTextBox
|
||||
System.Windows.Media.Typeface typeface = new Typeface(QueryTextBox.FontFamily, QueryTextBox.FontStyle, QueryTextBox.FontWeight, QueryTextBox.FontStretch);
|
||||
System.Windows.Media.FormattedText ft = new FormattedText(QueryTextBox.Text, System.Globalization.CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight, typeface, QueryTextBox.FontSize, Brushes.Black);
|
||||
// TODO: Obsolete warning?
|
||||
System.Windows.Media.FormattedText ft = new FormattedText(QueryTextBox.Text, System.Globalization.CultureInfo.DefaultThreadCurrentCulture, System.Windows.FlowDirection.LeftToRight, typeface, QueryTextBox.FontSize, Brushes.Black);
|
||||
|
||||
var offset = QueryTextBox.Padding.Right;
|
||||
|
||||
|
|
@ -75,4 +76,4 @@ namespace Flow.Launcher.Converters
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,9 +65,10 @@ namespace Flow.Launcher.ViewModel
|
|||
Settings = settings;
|
||||
Settings.PropertyChanged += (_, args) =>
|
||||
{
|
||||
if (args.PropertyName == nameof(Settings.WindowSize))
|
||||
{
|
||||
OnPropertyChanged(nameof(MainWindowWidth));
|
||||
switch (args.PropertyName) {
|
||||
case nameof(Settings.WindowSize):
|
||||
OnPropertyChanged(nameof(MainWindowWidth));
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -334,8 +335,8 @@ namespace Flow.Launcher.ViewModel
|
|||
public Settings Settings { get; }
|
||||
public string ClockText { get; private set; }
|
||||
public string DateText { get; private set; }
|
||||
public CultureInfo Culture => CultureInfo.DefaultThreadCurrentCulture;
|
||||
|
||||
public CultureInfo cultureInfo => new CultureInfo(Settings.Language);
|
||||
private async Task RegisterClockAndDateUpdateAsync()
|
||||
{
|
||||
var timer = new PeriodicTimer(TimeSpan.FromSeconds(1));
|
||||
|
|
@ -343,11 +344,12 @@ namespace Flow.Launcher.ViewModel
|
|||
while (await timer.WaitForNextTickAsync().ConfigureAwait(false))
|
||||
{
|
||||
if (Settings.UseClock)
|
||||
ClockText = DateTime.Now.ToString(Settings.TimeFormat, cultureInfo);
|
||||
ClockText = DateTime.Now.ToString(Settings.TimeFormat, Culture);
|
||||
if (Settings.UseDate)
|
||||
DateText = DateTime.Now.ToString(Settings.DateFormat, cultureInfo);
|
||||
DateText = DateTime.Now.ToString(Settings.DateFormat, Culture);
|
||||
}
|
||||
}
|
||||
|
||||
public ResultsViewModel Results { get; private set; }
|
||||
|
||||
public ResultsViewModel ContextMenu { get; private set; }
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ namespace Flow.Launcher.ViewModel
|
|||
break;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public Settings Settings { get; set; }
|
||||
|
|
@ -84,7 +85,7 @@ namespace Flow.Launcher.ViewModel
|
|||
}
|
||||
}
|
||||
|
||||
public CultureInfo cultureInfo => new CultureInfo(Settings.Language);
|
||||
public CultureInfo Culture => CultureInfo.DefaultThreadCurrentCulture;
|
||||
|
||||
public bool StartFlowLauncherOnSystemStartup
|
||||
{
|
||||
|
|
@ -496,20 +497,19 @@ namespace Flow.Launcher.ViewModel
|
|||
|
||||
public string TimeFormat
|
||||
{
|
||||
get { return Settings.TimeFormat; }
|
||||
set { Settings.TimeFormat = value; }
|
||||
get => Settings.TimeFormat;
|
||||
set => Settings.TimeFormat = value;
|
||||
}
|
||||
|
||||
public string DateFormat
|
||||
{
|
||||
get { return Settings.DateFormat; }
|
||||
set { Settings.DateFormat = value; }
|
||||
get => Settings.DateFormat;
|
||||
set => Settings.DateFormat = value;
|
||||
}
|
||||
|
||||
public string ClockText => DateTime.Now.ToString(TimeFormat, cultureInfo);
|
||||
|
||||
public string DateText => DateTime.Now.ToString(DateFormat, cultureInfo);
|
||||
public string ClockText => DateTime.Now.ToString(TimeFormat, Culture);
|
||||
|
||||
public string DateText => DateTime.Now.ToString(DateFormat, Culture);
|
||||
|
||||
public double WindowWidthSize
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Runtime.InteropServices;
|
||||
|
|
@ -61,7 +61,7 @@ namespace Flow.Launcher.Plugin.Caculator
|
|||
switch (_settings.DecimalSeparator)
|
||||
{
|
||||
case DecimalSeparator.Comma:
|
||||
case DecimalSeparator.UseSystemLocale when CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator == ",":
|
||||
case DecimalSeparator.UseSystemLocale when CultureInfo.DefaultThreadCurrentCulture.NumberFormat.NumberDecimalSeparator == ",":
|
||||
expression = query.Search.Replace(",", ".");
|
||||
break;
|
||||
default:
|
||||
|
|
@ -157,7 +157,7 @@ namespace Flow.Launcher.Plugin.Caculator
|
|||
|
||||
private string GetDecimalSeparator()
|
||||
{
|
||||
string systemDecimalSeperator = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;
|
||||
string systemDecimalSeperator = CultureInfo.DefaultThreadCurrentCulture.NumberFormat.NumberDecimalSeparator;
|
||||
switch (_settings.DecimalSeparator)
|
||||
{
|
||||
case DecimalSeparator.UseSystemLocale: return systemDecimalSeperator;
|
||||
|
|
|
|||
Loading…
Reference in a new issue