Skip to content

Commit 6eb8ef6

Browse files
authored
Merge pull request #2722 from Flow-Launcher/fix-decimal
Fix bug and typo in Calculator Plugin
2 parents ec26321 + e4621a5 commit 6eb8ef6

File tree

13 files changed

+28
-34
lines changed

13 files changed

+28
-34
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/DecimalSeparator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System.ComponentModel;
22
using Flow.Launcher.Core.Resource;
33

4-
namespace Flow.Launcher.Plugin.Caculator
4+
namespace Flow.Launcher.Plugin.Calculator
55
{
66
[TypeConverter(typeof(LocalizationConverter))]
77
public enum DecimalSeparator

Plugins/Flow.Launcher.Plugin.Calculator/Flow.Launcher.Plugin.Calculator.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
<TargetFramework>net7.0-windows</TargetFramework>
66
<ProjectGuid>{59BD9891-3837-438A-958D-ADC7F91F6F7E}</ProjectGuid>
77
<AppDesignerFolder>Properties</AppDesignerFolder>
8-
<RootNamespace>Flow.Launcher.Plugin.Caculator</RootNamespace>
9-
<AssemblyName>Flow.Launcher.Plugin.Caculator</AssemblyName>
8+
<RootNamespace>Flow.Launcher.Plugin.Calculator</RootNamespace>
9+
<AssemblyName>Flow.Launcher.Plugin.Calculator</AssemblyName>
1010
<UseWPF>true</UseWPF>
1111
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
1212
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
@@ -18,7 +18,7 @@
1818
<DebugSymbols>true</DebugSymbols>
1919
<DebugType>portable</DebugType>
2020
<Optimize>false</Optimize>
21-
<OutputPath>..\..\Output\Debug\Plugins\Flow.Launcher.Plugin.Caculator\</OutputPath>
21+
<OutputPath>..\..\Output\Debug\Plugins\Flow.Launcher.Plugin.Calculator\</OutputPath>
2222
<DefineConstants>DEBUG;TRACE</DefineConstants>
2323
<ErrorReport>prompt</ErrorReport>
2424
<WarningLevel>4</WarningLevel>
@@ -28,7 +28,7 @@
2828
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2929
<DebugType>pdbonly</DebugType>
3030
<Optimize>true</Optimize>
31-
<OutputPath>..\..\Output\Release\Plugins\Flow.Launcher.Plugin.Caculator\</OutputPath>
31+
<OutputPath>..\..\Output\Release\Plugins\Flow.Launcher.Plugin.Calculator\</OutputPath>
3232
<DefineConstants>TRACE</DefineConstants>
3333
<ErrorReport>prompt</ErrorReport>
3434
<WarningLevel>4</WarningLevel>

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
using System.Windows;
77
using System.Windows.Controls;
88
using Mages.Core;
9-
using Flow.Launcher.Plugin.Caculator.ViewModels;
10-
using Flow.Launcher.Plugin.Caculator.Views;
9+
using Flow.Launcher.Plugin.Calculator.ViewModels;
10+
using Flow.Launcher.Plugin.Calculator.Views;
1111

12-
namespace Flow.Launcher.Plugin.Caculator
12+
namespace Flow.Launcher.Plugin.Calculator
1313
{
1414
public class Main : IPlugin, IPluginI18n, ISettingProvider
1515
{
@@ -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/NumberTranslator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Text;
33
using System.Text.RegularExpressions;
44

5-
namespace Flow.Launcher.Plugin.Caculator
5+
namespace Flow.Launcher.Plugin.Calculator
66
{
77
/// <summary>
88
/// Tries to convert all numbers in a text from one culture format to another.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
namespace Flow.Launcher.Plugin.Caculator
2+
namespace Flow.Launcher.Plugin.Calculator
33
{
44
public class Settings
55
{

Plugins/Flow.Launcher.Plugin.Calculator/ViewModels/SettingsViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System.Collections.Generic;
22
using System.Linq;
33

4-
namespace Flow.Launcher.Plugin.Caculator.ViewModels
4+
namespace Flow.Launcher.Plugin.Calculator.ViewModels
55
{
66
public class SettingsViewModel : BaseModel
77
{

0 commit comments

Comments
 (0)