Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
stefansjfw committed Sep 19, 2024
1 parent 500bceb commit 0ae036a
Show file tree
Hide file tree
Showing 21 changed files with 323 additions and 3 deletions.
28 changes: 27 additions & 1 deletion src/modules/imageresizer/ui/Views/EnumValueConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Windows.Data;

using ImageResizer.Properties;
using ManagedCommon;

namespace ImageResizer.Views
{
Expand Down Expand Up @@ -42,9 +43,34 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
.Append(parameter);
}

var languageTag = LanguageHelper.LoadLanguage();

CultureInfo overrideCulture = null;

if (!string.IsNullOrEmpty(languageTag))
{
try
{
overrideCulture = new CultureInfo(languageTag);
}
catch (CultureNotFoundException ex)
{
Logger.LogError("CultureNotFoundException: " + ex.Message);
}
}

// Fixes #16792 - Looks like culture defaults to en-US, so wrong resource is being fetched.
#pragma warning disable CA1304 // Specify CultureInfo
var targetValue = Resources.ResourceManager.GetString(builder.ToString());
string targetValue;

if (overrideCulture != null)
{
targetValue = Resources.ResourceManager.GetString(builder.ToString(), overrideCulture);
}
else
{
targetValue = Resources.ResourceManager.GetString(builder.ToString());
}
#pragma warning restore CA1304 // Specify CultureInfo

if (toLower)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,20 @@ public void Init(PluginInitContext context)
{
ArgumentNullException.ThrowIfNull(context);

var languageTag = LanguageHelper.LoadLanguage();

if (!string.IsNullOrEmpty(languageTag))
{
try
{
Properties.Resources.Culture = new System.Globalization.CultureInfo(languageTag);
}
catch (CultureNotFoundException ex)
{
Logger.LogError("CultureNotFoundException: " + ex.Message);
}
}

_context = context;
_context.API.ThemeChanged += OnThemeChanged;
UpdateIconPath(_context.API.GetCurrentTheme());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Linq;

using Community.PowerToys.Run.Plugin.VSCodeWorkspaces.Properties;
using Community.PowerToys.Run.Plugin.VSCodeWorkspaces.RemoteMachinesHelper;
using Community.PowerToys.Run.Plugin.VSCodeWorkspaces.VSCodeHelper;
using Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper;
using ManagedCommon;
using Wox.Plugin;

namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces
Expand All @@ -28,6 +30,20 @@ public class Main : IPlugin, IPluginI18n

public Main()
{
var languageTag = LanguageHelper.LoadLanguage();

if (!string.IsNullOrEmpty(languageTag))
{
try
{
Properties.Resources.Culture = new System.Globalization.CultureInfo(languageTag);
}
catch (CultureNotFoundException ex)
{
Logger.LogError("CultureNotFoundException: " + ex.Message);
}
}

VSCodeInstances.LoadVSCodeInstances();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows;
Expand Down Expand Up @@ -34,6 +35,20 @@ public void Init(PluginInitContext context)
{
context = context ?? throw new ArgumentNullException(paramName: nameof(context));

var languageTag = LanguageHelper.LoadLanguage();

if (!string.IsNullOrEmpty(languageTag))
{
try
{
Properties.Resources.Culture = new System.Globalization.CultureInfo(languageTag);
}
catch (CultureNotFoundException ex)
{
Logger.LogError("CultureNotFoundException: " + ex.Message);
}
}

_context = context;
_context.API.ThemeChanged += OnThemeChanged;
UpdateIconPath(_context.API.GetCurrentTheme());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,20 @@ bool IsURI(string input)

public void Init(PluginInitContext context)
{
var languageTag = LanguageHelper.LoadLanguage();

if (!string.IsNullOrEmpty(languageTag))
{
try
{
Properties.Resources.Culture = new System.Globalization.CultureInfo(languageTag);
}
catch (CultureNotFoundException ex)
{
Logger.LogError("CultureNotFoundException: " + ex.Message);
}
}

_context = context ?? throw new ArgumentNullException(nameof(context));
_context.API.ThemeChanged += OnThemeChanged;
UpdateIconPath(_context.API.GetCurrentTheme());
Expand Down
15 changes: 15 additions & 0 deletions src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO.Abstractions;
using System.Linq;
using System.Windows.Controls;
Expand Down Expand Up @@ -71,6 +72,20 @@ public List<Result> Query(Query query)

public void Init(PluginInitContext context)
{
var languageTag = LanguageHelper.LoadLanguage();

if (!string.IsNullOrEmpty(languageTag))
{
try
{
Properties.Resources.Culture = new System.Globalization.CultureInfo(languageTag);
}
catch (CultureNotFoundException ex)
{
Logger.LogError("CultureNotFoundException: " + ex.Message);
}
}

_context = context ?? throw new ArgumentNullException(nameof(context));
_contextMenuLoader = new ContextMenuLoader(context);

Expand Down
14 changes: 14 additions & 0 deletions src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,20 @@ public List<Result> Query(Query query)

public void Init(PluginInitContext context)
{
var languageTag = LanguageHelper.LoadLanguage();

if (!string.IsNullOrEmpty(languageTag))
{
try
{
Properties.Resources.Culture = new System.Globalization.CultureInfo(languageTag);
}
catch (CultureNotFoundException ex)
{
Logger.LogError("CultureNotFoundException: " + ex.Message);
}
}

// initialize the context of the plugin
_context = context;
_contextMenuLoader = new ContextMenuLoader(context);
Expand Down
15 changes: 15 additions & 0 deletions src/modules/launcher/Plugins/Microsoft.Plugin.Program/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;

Expand Down Expand Up @@ -105,6 +106,20 @@ private IEnumerable<Result> Query(string program, string programArguments)

public void Init(PluginInitContext context)
{
var languageTag = LanguageHelper.LoadLanguage();

if (!string.IsNullOrEmpty(languageTag))
{
try
{
Properties.Resources.Culture = new CultureInfo(languageTag);
}
catch (CultureNotFoundException)
{
// error
}
}

_context = context ?? throw new ArgumentNullException(nameof(context));
_context.API.ThemeChanged += OnThemeChanged;
_packageRepository = new PackageRepository(new PackageCatalogWrapper(), _context);
Expand Down
14 changes: 14 additions & 0 deletions src/modules/launcher/Plugins/Microsoft.Plugin.Shell/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,20 @@ private static bool ExistInPath(string filename)

public void Init(PluginInitContext context)
{
var languageTag = LanguageHelper.LoadLanguage();

if (!string.IsNullOrEmpty(languageTag))
{
try
{
Properties.Resources.Culture = new System.Globalization.CultureInfo(languageTag);
}
catch (CultureNotFoundException ex)
{
Logger.LogError("CultureNotFoundException: " + ex.Message);
}
}

this._context = context;
_context.API.ThemeChanged += OnThemeChanged;
UpdateIconPath(_context.API.GetCurrentTheme());
Expand Down
15 changes: 15 additions & 0 deletions src/modules/launcher/Plugins/Microsoft.Plugin.Uri/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System;
using System.Collections.Generic;
using System.Globalization;

using ManagedCommon;
using Microsoft.Plugin.Uri.UriHelper;
Expand All @@ -25,6 +26,20 @@ public class Main : IPlugin, IPluginI18n, IContextMenu, ISavable, IReloadable, I

public Main()
{
var languageTag = LanguageHelper.LoadLanguage();

if (!string.IsNullOrEmpty(languageTag))
{
try
{
Properties.Resources.Culture = new System.Globalization.CultureInfo(languageTag);
}
catch (CultureNotFoundException ex)
{
Logger.LogError("CultureNotFoundException: " + ex.Message);
}
}

_storage = new PluginJsonStorage<UriSettings>();
_uriSettings = _storage.Load();
_uriParser = new ExtendedUriParser();
Expand Down
15 changes: 15 additions & 0 deletions src/modules/launcher/Plugins/Microsoft.Plugin.WindowWalker/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Threading;
using System.Windows.Controls;

Expand Down Expand Up @@ -57,6 +58,20 @@ public List<ContextMenuResult> LoadContextMenus(Result selectedResult)

public void Init(PluginInitContext context)
{
var languageTag = LanguageHelper.LoadLanguage();

if (!string.IsNullOrEmpty(languageTag))
{
try
{
Properties.Resources.Culture = new System.Globalization.CultureInfo(languageTag);
}
catch (CultureNotFoundException ex)
{
Logger.LogError("CultureNotFoundException: " + ex.Message);
}
}

Context = context;
Context.API.ThemeChanged += OnThemeChanged;
UpdateIconPath(Context.API.GetCurrentTheme());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,20 @@ public List<Result> Query(Query query)

public void Init(PluginInitContext context)
{
var languageTag = LanguageHelper.LoadLanguage();

if (!string.IsNullOrEmpty(languageTag))
{
try
{
Properties.Resources.Culture = new System.Globalization.CultureInfo(languageTag);
}
catch (CultureNotFoundException ex)
{
Logger.LogError("CultureNotFoundException: " + ex.Message);
}
}

Context = context ?? throw new ArgumentNullException(paramName: nameof(context));

Context.API.ThemeChanged += OnThemeChanged;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;

using ManagedCommon;
Expand Down Expand Up @@ -158,6 +159,20 @@ private Result BuildResult(UserSelectedRecord.UserSelectedRecordItem historyItem

public void Init(PluginInitContext context)
{
var languageTag = LanguageHelper.LoadLanguage();

if (!string.IsNullOrEmpty(languageTag))
{
try
{
Properties.Resources.Culture = new System.Globalization.CultureInfo(languageTag);
}
catch (CultureNotFoundException ex)
{
Logger.LogError("CultureNotFoundException: " + ex.Message);
}
}

Context = context ?? throw new ArgumentNullException(paramName: nameof(context));

Context.API.ThemeChanged += OnThemeChanged;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Runtime.InteropServices;

using LazyCache;
Expand Down Expand Up @@ -71,6 +72,20 @@ public Main()
/// <param name="context">The <see cref="PluginInitContext"/> for this plugin</param>
public void Init(PluginInitContext context)
{
var languageTag = LanguageHelper.LoadLanguage();

if (!string.IsNullOrEmpty(languageTag))
{
try
{
Properties.Resources.Culture = new System.Globalization.CultureInfo(languageTag);
}
catch (CultureNotFoundException ex)
{
Logger.LogError("CultureNotFoundException: " + ex.Message);
}
}

_context = context ?? throw new ArgumentNullException(nameof(context));

try
Expand Down
Loading

1 comment on commit 0ae036a

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@check-spelling-bot Report

🔴 Please review

See the 📜action log or 📝 job summary for details.

Unrecognized words (2)

initlanguages
sublang

Previously acknowledged words that are now absent applayout appsfolder cswinrt SUBLANG systemsettings SYSTEMWOW USEPOSITION USESIZE 🫥
To accept these unrecognized words as correct and remove the previously acknowledged and now absent words, you could run the following commands

... in a clone of the [email protected]:microsoft/PowerToys.git repository
on the stefan/lang_override branch (ℹ️ how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.22/apply.pl' |
perl - 'https://github.com/microsoft/PowerToys/actions/runs/10937759627/attempts/1'
Available 📚 dictionaries could cover words (expected and unrecognized) not in the 📘 dictionary

This includes both expected items (1897) from .github/actions/spell-check/expect.txt and unrecognized words (2)

Dictionary Entries Covers Uniquely
cspell:r/src/r.txt 543 1 1
cspell:cpp/src/people.txt 23 1
cspell:cpp/src/ecosystem.txt 51 1

Consider adding them (in .github/workflows/spelling2.yml) for uses: check-spelling/[email protected] in its with:

      with:
        extra_dictionaries:
          cspell:r/src/r.txt
          cspell:cpp/src/people.txt
          cspell:cpp/src/ecosystem.txt

To stop checking additional dictionaries, add (in .github/workflows/spelling2.yml) for uses: check-spelling/[email protected] in its with:

check_extra_dictionaries: ''
Warnings (1)

See the 📜action log or 📝 job summary for details.

ℹ️ Warnings Count
ℹ️ non-alpha-in-dictionary 1

See ℹ️ Event descriptions for more information.

If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

Please sign in to comment.