Skip to content

Commit

Permalink
try fix
Browse files Browse the repository at this point in the history
  • Loading branch information
stefansjfw committed Sep 18, 2024
1 parent 947a95b commit bda8ac5
Showing 1 changed file with 35 additions and 14 deletions.
49 changes: 35 additions & 14 deletions src/common/utils/resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@
// Get a string from the resource file
inline std::wstring get_resource_string(UINT resource_id, HINSTANCE instance, const wchar_t* fallback)
{
// Try to load en-us string as the first fallback.
WORD english_language = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US);
BOOL english_string_loaded = TRUE;
ATL::CStringW english_string;
try
{
if (!english_string.LoadStringW(instance, resource_id, english_language))
{
english_string_loaded = FALSE;
}
}
catch (...)
{
english_string_loaded = FALSE;
}

std::wstring language = LanguageHelpers::load_language();
unsigned lang = LANG_ENGLISH;
unsigned sublang = SUBLANG_ENGLISH_US;
Expand Down Expand Up @@ -127,19 +143,32 @@ inline std::wstring get_resource_string(UINT resource_id, HINSTANCE instance, co
}


// Try to load en-us string as the first fallback.
WORD languageID = MAKELANGID(lang, sublang);
ATL::CStringW result;
try
{
if (!result.LoadStringW(instance, resource_id, languageID))
{
return fallback;
if (english_string_loaded)
{
return std::wstring(english_string);
}
else
{
return fallback;
}
}
}
catch (...)
{
return fallback;
if (english_string_loaded)
{
return std::wstring(english_string);
}
else
{
return fallback;
}
}

if (!result.IsEmpty())
Expand All @@ -152,22 +181,14 @@ inline std::wstring get_resource_string(UINT resource_id, HINSTANCE instance, co
auto length = LoadStringW(instance, resource_id, reinterpret_cast<wchar_t*>(&text_ptr), 0);
if (length == 0)
{
// Try to load en-us string as the first fallback.
WORD english_language = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US);
ATL::CStringW english_string;
try
if (english_string_loaded)
{
if (!english_string.LoadStringW(instance, resource_id, english_language))
{
return fallback;
}
return std::wstring(english_string);
}
catch (...)
else
{
return fallback;
}

return std::wstring(english_string);
}
else
{
Expand Down

1 comment on commit bda8ac5

@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/10929870831/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.