-
-
Notifications
You must be signed in to change notification settings - Fork 54
chore: refactor and add localization to Accelerator Service #680
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
base: main
Are you sure you want to change the base?
Conversation
…tiple modifiers add physical keyboards detection convert IsDesktop and IsXbox to readonly fields add localized strings for keys and modifiers
add touch present property
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.
Pull Request Overview
This PR refactors and adds localization support to the AcceleratorService
to enable proper keyboard accelerator display across different languages and locales. It moves the service to a more appropriate namespace, improves device detection capabilities, and adds comprehensive keyboard and modifier key localization.
- Moves
AcceleratorService
fromControls
toExtensions
folder for better organization - Adds comprehensive localization support for all VirtualKey and VirtualKeyModifiers values
- Improves Xbox device detection and adds keyboard/touch presence detection
- Converts helper properties to static readonly for better performance
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
Screenbox/Strings/en-US/KeyboardResources.resw |
Adds localized strings for all keyboard keys and modifiers |
Screenbox/Screenbox.csproj |
Moves AcceleratorService file location and adds new KeyboardAcceleratorHelper |
Screenbox/Pages/MainPage.xaml |
Updates namespace references from controls to extensions |
Screenbox/Helpers/KeyboardAcceleratorHelper.cs |
New helper class for converting keyboard accelerators to localized display names |
Screenbox/Helpers/GlobalizationHelper.cs |
Converts property to static readonly for performance |
Screenbox/Helpers/DeviceInfoHelper.cs |
Adds keyboard/touch detection and improves Xbox detection |
Screenbox/Extensions/AcceleratorService.cs |
Refactored service with proper localization and device detection |
Multiple XAML files | Updates namespace references from controls to extensions |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
/// </summary> | ||
/// <returns><see langword="true"/> if the device is an Xbox; otherwise, <see langword="false"/>.</returns> | ||
public static bool IsXbox => DeviceFamily == "Windows.Xbox"; | ||
public static readonly bool IsXbox = (DeviceFamily == "Windows.Xbox") || (DeviceFamily == "Windows.XBoxSRA") || (DeviceFamily == "Windows.XBoxERA"); |
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.
The device family names contain inconsistent capitalization. 'XBoxSRA' and 'XBoxERA' should likely be 'XboxSRA' and 'XboxERA' to match the standard Xbox naming convention used in 'Windows.Xbox'.
public static readonly bool IsXbox = (DeviceFamily == "Windows.Xbox") || (DeviceFamily == "Windows.XBoxSRA") || (DeviceFamily == "Windows.XBoxERA"); | |
public static readonly bool IsXbox = (DeviceFamily == "Windows.Xbox") || (DeviceFamily == "Windows.XboxSRA") || (DeviceFamily == "Windows.XboxERA"); |
Copilot uses AI. Check for mistakes.
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.
I took the values directly from the Microsoft UI Xaml repository:
move keyboard accelerator display name logic to a new helper file
2e088eb
to
44eb283
Compare
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 is impressive! Thank you!
What's the concern of pushing VirtualKey strings to Crowdin? Is it because they don't change across languages? |
Some keys don't change, but my main concern is that since they're on Crowdin we can’t validate or lock them. This risks inconsistencies, and translators don’t have straightforward access to all the key translations (not unless I release the above app). |
Also I probably shouldn't have moved the keyboard accelerator localization logic out of the |
I see. I agree with this comment. Let's move these strings on another file. Also release the above app! It looks useful! |
At this stage, it might be best to remove I can upload the repository, though I don't believe packaging it is necessary. |
I just removed |
Should I translate all of them as part of this PR? Shouldn't take too long. |
I was thinking you could remove all the translated |
Sure, but eventually I'd like to translate them, at least for the most widely spoken languages. |
fix zh-Hant KeyboardResources file inclusion
Improves the
AcceleratorService
to support localization. Additionally, it improves device information and globalization helpers to use static readonly properties for better performance and clarity.Controls
folder to theExtensions
folder for better code organizationTooltip
creation logic forKeyboardAccelerator
when using multiple modifiersKeyboardResources.resw
KeyboardAccelerator
localization supportP.S. I'm still unsure whether we should push the VirtualKey/VirtualKeyModifiers strings to Crowdin. We could create a separate file for them.
I've built a application to quickly verify, and export, their localized values.
Gravacao.2025-09-24.214732.mp4