-
Notifications
You must be signed in to change notification settings - Fork 3
Add i18n support for Control Widgets #5
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
Conversation
- Added localization keys to Localizable.xcstrings: - vpn_connected (已连接) - vpn_disconnected (已断开) - vpn_connect (连接) - vpn_disconnect (断开) - toggle_vpn (切换 VPN) - toggle_vpn_connection (切换 VPN 连接) - Updated ControlWidgetsControl.swift to use LocalizedStringResource Co-authored-by: chenx-dust <16610294+chenx-dust@users.noreply.github.com>
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 adds internationalization (i18n) support to Control Widgets by replacing hardcoded English strings with localized resources. The changes enable the widget to display text in the user's preferred language, currently supporting English and Simplified Chinese.
Changes:
- Added 6 localization keys to
Localizable.xcstringswith English and Simplified Chinese translations - Updated
ControlWidgetsControl.swiftto use localized strings instead of hardcoded English text - Applied localization to widget labels, action hints, descriptions, and intent parameters
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| EasyTier/Localizable.xcstrings | Added 6 new localization keys (vpn_connected, vpn_disconnected, vpn_connect, vpn_disconnect, toggle_vpn, toggle_vpn_connection) with English and Simplified Chinese translations |
| ControlWidgets/ControlWidgetsControl.swift | Replaced hardcoded English strings with localized string resources for widget labels, action hints, descriptions, and intent parameters |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Label(isOn ? LocalizedStringResource("vpn_connected") : LocalizedStringResource("vpn_disconnected"), systemImage: "network") | ||
| .controlWidgetActionHint(isOn ? LocalizedStringResource("vpn_disconnect") : LocalizedStringResource("vpn_connect")) |
Copilot
AI
Jan 14, 2026
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 LocalizedStringResource constructor should not be used to wrap localization keys. According to the pattern used elsewhere in the codebase (e.g., EasyTierShortcuts.swift), localization keys should be passed as string literals directly without wrapping them in LocalizedStringResource(). The compiler can automatically convert string literals to LocalizedStringResource.
Change from:
- LocalizedStringResource("vpn_connected")
- LocalizedStringResource("vpn_disconnected")
- LocalizedStringResource("vpn_disconnect")
- LocalizedStringResource("vpn_connect")
To:
- "vpn_connected"
- "vpn_disconnected"
- "vpn_disconnect"
- "vpn_connect"
| } | ||
| .displayName("EasyTier") | ||
| .description("Toggle VPN connection") | ||
| .description(LocalizedStringResource("toggle_vpn_connection")) |
Copilot
AI
Jan 14, 2026
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 LocalizedStringResource constructor should not be used to wrap the localization key. Following the pattern used elsewhere in the codebase, the localization key should be passed as a string literal directly without wrapping it in LocalizedStringResource().
Change from:
LocalizedStringResource("toggle_vpn_connection")
To:
"toggle_vpn_connection"
| .description(LocalizedStringResource("toggle_vpn_connection")) | |
| .description("toggle_vpn_connection") |
| static let title: LocalizedStringResource = "toggle_vpn" | ||
|
|
||
| @Parameter(title: "Connected") | ||
| @Parameter(title: LocalizedStringResource("vpn_connected")) |
Copilot
AI
Jan 14, 2026
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 @parameter title should not use "vpn_connected" as it represents a boolean parameter for the connection state (both connected and disconnected states), not just the connected state. Consider using a more neutral localization key like "toggle_vpn" or a new key such as "vpn_state" that better represents both states.
Additionally, the LocalizedStringResource constructor should not be used. The localization key should be passed as a string literal directly.
| @Parameter(title: LocalizedStringResource("vpn_connected")) | |
| @Parameter(title: "vpn_state") |
Control Widgets displayed hardcoded English strings. Added localization following the project's
.xcstringspattern.Changes
Added 6 localization keys to
Localizable.xcstringswith English and Simplified Chinese translations:vpn_connected,vpn_disconnected,vpn_connect,vpn_disconnecttoggle_vpn,toggle_vpn_connectionUpdated
ControlWidgetsControl.swiftto useLocalizedStringResource:Widget text now respects device language settings.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.