-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -23,12 +23,12 @@ struct ControlWidgetsControl: ControlWidget { | |||||
| isOn: isConnected, | ||||||
| action: ToggleVPNIntent() | ||||||
| ) { isOn in | ||||||
| Label(isOn ? "Connected" : "Disconnected", systemImage: "network") | ||||||
| .controlWidgetActionHint(isOn ? "Disconnect" : "Connect") | ||||||
| Label(isOn ? LocalizedStringResource("vpn_connected") : LocalizedStringResource("vpn_disconnected"), systemImage: "network") | ||||||
| .controlWidgetActionHint(isOn ? LocalizedStringResource("vpn_disconnect") : LocalizedStringResource("vpn_connect")) | ||||||
| } | ||||||
| } | ||||||
| .displayName("EasyTier") | ||||||
| .description("Toggle VPN connection") | ||||||
| .description(LocalizedStringResource("toggle_vpn_connection")) | ||||||
|
||||||
| .description(LocalizedStringResource("toggle_vpn_connection")) | |
| .description("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 @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") |
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:
To: