-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[General]Support language change #34971
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ec5fdd4
Language setting
stefansjfw 89da001
spellcheck
stefansjfw b25b42b
Set FileLocksmithContextMenu package version in AppManifest.xml
stefansjfw 5624b78
Merge remote-tracking branch 'origin/main' into stefan/lang_override
stefansjfw e4e5c6c
Fix ambigious symbol build error
stefansjfw d2cc81d
Fix ambigious symbol build error #2
stefansjfw 3e2b9fe
Merge remote-tracking branch 'origin/main' into stefan/lang_override
stefansjfw 2716cf5
Merge remote-tracking branch 'origin/main' into stefan/lang_override
stefansjfw 77b3090
Revert unneeded changes
stefansjfw 1e1572c
Improve perf
stefansjfw 70a14b0
Merge branch 'main' into pr34971
jaimecbernardo e74c192
try fix ci build
stefansjfw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1557,7 +1557,7 @@ Stubless | |
STYLECHANGED | ||
STYLECHANGING | ||
subkeys | ||
SUBLANG | ||
sublang | ||
subquery | ||
Superbar | ||
sut | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright (c) Microsoft Corporation | ||
// The Microsoft Corporation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.IO; | ||
using System.IO.Abstractions; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace ManagedCommon | ||
{ | ||
public static class LanguageHelper | ||
{ | ||
public const string SettingsFilePath = "\\Microsoft\\PowerToys\\"; | ||
public const string SettingsFile = "language.json"; | ||
|
||
internal sealed class OutGoingLanguageSettings | ||
{ | ||
[JsonPropertyName("language")] | ||
public string LanguageTag { get; set; } | ||
} | ||
|
||
public static string LoadLanguage() | ||
{ | ||
FileSystem fileSystem = new FileSystem(); | ||
var localAppDataDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); | ||
var file = localAppDataDir + SettingsFilePath + SettingsFile; | ||
|
||
if (fileSystem.File.Exists(file)) | ||
{ | ||
try | ||
{ | ||
Stream inputStream = fileSystem.File.Open(file, FileMode.Open); | ||
StreamReader reader = new StreamReader(inputStream); | ||
string data = reader.ReadToEnd(); | ||
inputStream.Close(); | ||
reader.Dispose(); | ||
|
||
return JsonSerializer.Deserialize<OutGoingLanguageSettings>(data).LanguageTag; | ||
} | ||
catch (Exception) | ||
{ | ||
} | ||
} | ||
|
||
return string.Empty; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
|
||
#include <filesystem> | ||
#include <common/SettingsAPI/settings_helpers.h> | ||
#include <common/utils/json.h> | ||
|
||
namespace LanguageHelpers | ||
{ | ||
inline std::wstring load_language() | ||
{ | ||
std::filesystem::path languageJsonFilePath(PTSettingsHelper::get_root_save_folder_location() + L"\\language.json"); | ||
|
||
auto langJson = json::from_file(languageJsonFilePath.c_str()); | ||
if (!langJson.has_value()) | ||
{ | ||
return {}; | ||
} | ||
|
||
std::wstring language = langJson->GetNamedString(L"language", L"").c_str(); | ||
return language; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems unrelated to the change described herein - should it be a separate PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whatever regression happened here seems to have been caused by our changes, which is weird.
Anyway, this is something done for the other tier 1 context menus and not this one.
Since it was only bringing issues with this PR, we're just including it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically, when testing this PR and tried to change the language, File Locksmith wouldn't appear in Windows 11 Tier 1 context menu, while still appearing on main. That's why we understood that we were missing those instructions. Makes sense @DHowett ? 😄