Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 14, 2026

Control Widgets displayed hardcoded English strings. Added localization following the project's .xcstrings pattern.

Changes

  • Added 6 localization keys to Localizable.xcstrings with English and Simplified Chinese translations:

    • vpn_connected, vpn_disconnected, vpn_connect, vpn_disconnect
    • toggle_vpn, toggle_vpn_connection
  • Updated ControlWidgetsControl.swift to use LocalizedStringResource:

    // Before
    Label(isOn ? "Connected" : "Disconnected", systemImage: "network")
        .controlWidgetActionHint(isOn ? "Disconnect" : "Connect")
    
    // After  
    Label(isOn ? LocalizedStringResource("vpn_connected") : LocalizedStringResource("vpn_disconnected"), systemImage: "network")
        .controlWidgetActionHint(isOn ? LocalizedStringResource("vpn_disconnect") : LocalizedStringResource("vpn_connect"))

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.

- 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>
Copilot AI changed the title [WIP] Fix shortcuts and control center issues Add i18n support for Control Widgets Jan 14, 2026
Copilot AI requested a review from chenx-dust January 14, 2026 05:18
@chenx-dust chenx-dust marked this pull request as ready for review January 14, 2026 05:34
Copilot AI review requested due to automatic review settings January 14, 2026 05:34
@chenx-dust chenx-dust merged commit 6030bb1 into shortcuts Jan 14, 2026
4 checks passed
Copy link

Copilot AI left a 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.xcstrings with English and Simplified Chinese translations
  • Updated ControlWidgetsControl.swift to 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.

Comment on lines +26 to +27
Label(isOn ? LocalizedStringResource("vpn_connected") : LocalizedStringResource("vpn_disconnected"), systemImage: "network")
.controlWidgetActionHint(isOn ? LocalizedStringResource("vpn_disconnect") : LocalizedStringResource("vpn_connect"))
Copy link

Copilot AI Jan 14, 2026

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"

Copilot uses AI. Check for mistakes.
}
.displayName("EasyTier")
.description("Toggle VPN connection")
.description(LocalizedStringResource("toggle_vpn_connection"))
Copy link

Copilot AI Jan 14, 2026

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"

Suggested change
.description(LocalizedStringResource("toggle_vpn_connection"))
.description("toggle_vpn_connection")

Copilot uses AI. Check for mistakes.
static let title: LocalizedStringResource = "toggle_vpn"

@Parameter(title: "Connected")
@Parameter(title: LocalizedStringResource("vpn_connected"))
Copy link

Copilot AI Jan 14, 2026

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.

Suggested change
@Parameter(title: LocalizedStringResource("vpn_connected"))
@Parameter(title: "vpn_state")

Copilot uses AI. Check for mistakes.
@chenx-dust chenx-dust deleted the copilot/sub-pr-3 branch January 14, 2026 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants