Skip to content

Commit fa2df93

Browse files
Fix calculator decimal separator bug
1 parent 3436c57 commit fa2df93

File tree

6 files changed

+11
-17
lines changed

6 files changed

+11
-17
lines changed

Flow.Launcher.Core/Resource/Internationalization.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,10 @@ public void ChangeLanguage(Language language)
9696
{
9797
LoadLanguage(language);
9898
}
99-
// Culture of this thread
100-
// Use CreateSpecificCulture to preserve possible user-override settings in Windows
99+
// Culture of main thread
100+
// Use CreateSpecificCulture to preserve possible user-override settings in Windows, if Flow's language culture is the same as Windows's
101101
CultureInfo.CurrentCulture = CultureInfo.CreateSpecificCulture(language.LanguageCode);
102102
CultureInfo.CurrentUICulture = CultureInfo.CurrentCulture;
103-
// App domain
104-
CultureInfo.DefaultThreadCurrentCulture = CultureInfo.CreateSpecificCulture(language.LanguageCode);
105-
CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.DefaultThreadCurrentCulture;
106103

107104
// Raise event after culture is set
108105
Settings.Language = language.LanguageCode;
@@ -193,7 +190,7 @@ private void UpdatePluginMetadataTranslations()
193190
{
194191
p.Metadata.Name = pluginI18N.GetTranslatedPluginTitle();
195192
p.Metadata.Description = pluginI18N.GetTranslatedPluginDescription();
196-
pluginI18N.OnCultureInfoChanged(CultureInfo.DefaultThreadCurrentCulture);
193+
pluginI18N.OnCultureInfoChanged(CultureInfo.CurrentCulture);
197194
}
198195
catch (Exception e)
199196
{

Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ values[2] is not string queryText ||
4444
// Check if Text will be larger than our QueryTextBox
4545
Typeface typeface = new Typeface(queryTextBox.FontFamily, queryTextBox.FontStyle, queryTextBox.FontWeight, queryTextBox.FontStretch);
4646
// TODO: Obsolete warning?
47-
var ft = new FormattedText(queryTextBox.Text, CultureInfo.DefaultThreadCurrentCulture, System.Windows.FlowDirection.LeftToRight, typeface, queryTextBox.FontSize, Brushes.Black);
47+
var ft = new FormattedText(queryTextBox.Text, CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight, typeface, queryTextBox.FontSize, Brushes.Black);
4848

4949
var offset = queryTextBox.Padding.Right;
5050

Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ namespace Flow.Launcher.SettingPages.ViewModels;
2121

2222
public partial class SettingsPaneThemeViewModel : BaseModel
2323
{
24-
private CultureInfo Culture => CultureInfo.DefaultThreadCurrentCulture;
25-
2624
public Settings Settings { get; }
2725

2826
public static string LinkHowToCreateTheme => @"https://flowlauncher.com/docs/#/how-to-create-a-theme";
@@ -136,9 +134,9 @@ public string DateFormat
136134
set => Settings.DateFormat = value;
137135
}
138136

139-
public string ClockText => DateTime.Now.ToString(TimeFormat, Culture);
137+
public string ClockText => DateTime.Now.ToString(TimeFormat, CultureInfo.CurrentCulture);
140138

141-
public string DateText => DateTime.Now.ToString(DateFormat, Culture);
139+
public string DateText => DateTime.Now.ToString(DateFormat, CultureInfo.CurrentCulture);
142140

143141
public double WindowWidthSize
144142
{

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,6 @@ public void CopyAlternative()
485485
public Settings Settings { get; }
486486
public string ClockText { get; private set; }
487487
public string DateText { get; private set; }
488-
public CultureInfo Culture => CultureInfo.DefaultThreadCurrentCulture;
489488

490489
private async Task RegisterClockAndDateUpdateAsync()
491490
{
@@ -494,9 +493,9 @@ private async Task RegisterClockAndDateUpdateAsync()
494493
while (await timer.WaitForNextTickAsync().ConfigureAwait(false))
495494
{
496495
if (Settings.UseClock)
497-
ClockText = DateTime.Now.ToString(Settings.TimeFormat, Culture);
496+
ClockText = DateTime.Now.ToString(Settings.TimeFormat, CultureInfo.CurrentCulture);
498497
if (Settings.UseDate)
499-
DateText = DateTime.Now.ToString(Settings.DateFormat, Culture);
498+
DateText = DateTime.Now.ToString(Settings.DateFormat, CultureInfo.CurrentCulture);
500499
}
501500
}
502501

Plugins/Flow.Launcher.Plugin.Calculator/Main.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public List<Result> Query(Query query)
6262
switch (_settings.DecimalSeparator)
6363
{
6464
case DecimalSeparator.Comma:
65-
case DecimalSeparator.UseSystemLocale when CultureInfo.DefaultThreadCurrentCulture.NumberFormat.NumberDecimalSeparator == ",":
65+
case DecimalSeparator.UseSystemLocale when CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator == ",":
6666
expression = query.Search.Replace(",", ".");
6767
break;
6868
default:
@@ -158,7 +158,7 @@ private string ChangeDecimalSeparator(decimal value, string newDecimalSeparator)
158158

159159
private string GetDecimalSeparator()
160160
{
161-
string systemDecimalSeperator = CultureInfo.DefaultThreadCurrentCulture.NumberFormat.NumberDecimalSeparator;
161+
string systemDecimalSeperator = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;
162162
switch (_settings.DecimalSeparator)
163163
{
164164
case DecimalSeparator.UseSystemLocale: return systemDecimalSeperator;

Plugins/Flow.Launcher.Plugin.Calculator/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"Name": "Calculator",
55
"Description": "Provide mathematical calculations.(Try 5*3-2 in Flow Launcher)",
66
"Author": "cxfksword",
7-
"Version": "3.1.0",
7+
"Version": "3.1.1",
88
"Language": "csharp",
99
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
1010
"ExecuteFileName": "Flow.Launcher.Plugin.Caculator.dll",

0 commit comments

Comments
 (0)