Skip to content

Implement English language support#28

Merged
PhoenixNil merged 6 commits into
mainfrom
net10
May 23, 2026
Merged

Implement English language support#28
PhoenixNil merged 6 commits into
mainfrom
net10

Conversation

@PhoenixNil
Copy link
Copy Markdown
Owner

Summary

  • Add WinAppSDK resource localization infrastructure with Strings/en-US and Strings/zh-CN.
  • Add typed string helpers and persisted language selection, including “Follow System”.
  • Localize main views, windows, dialogs, tooltips, and accessibility labels.
  • Decouple routing/proxy business values from localized display strings.
  • Pin WindowsAppSDK AI package versions to avoid restore-time mismatches.

PhoenixNil and others added 5 commits May 23, 2026 09:09
Lays groundwork for runtime UI localization. WinAppSDK requires a process
restart to apply a new PrimaryLanguageOverride, so the flow is "change
in Personalize, restart to see effect".

- LanguageHelper: single (Tag?, DisplayName) table. Index 0 is "follow
  system" (Tag=null -> no override -> WinAppSDK uses the OS locale, then
  the <DefaultLanguage>en-US</DefaultLanguage> fallback in csproj).
- ApplyPersistedLanguageOverride: JsonDocument-parses settings.json
  before InitializeComponent, avoiding the impossible read of
  PrimaryLanguageOverride in unpackaged apps.
- App.Restart: AppInstance.Restart + manual fallback after cleanup,
  necessary because xray.exe is not in our job object.
- Personalize ComboBox: data-driven (ItemsSource + DataTemplate); adding
  a language is a one-line edit in LanguageHelper.
- Restart InfoBar tracks divergence from the loaded value -- flipping
  back to the initial choice clears it.
- Done command persists Language too (parity with Theme / Backdrop).

UI text remains hardcoded Chinese -- extraction lands in a later commit.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
… versions

Switching from "2.0.*" to exact pins (2.0.185 / 2.0.300) eliminates an
intermittent restore-time conflict where the floating versions could
transitively pull in Foundation 2.0.21 / InteractiveExperiences 2.0.13,
mismatching Microsoft.WindowsAppSDK 2.0.1's expected 2.0.20 / 2.0.12.

Bump deliberately when WindowsAppSDK itself is upgraded.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…ay strings

Mode state and persistence now use stable codes; display goes through a
derived *Text getter. Same UI behavior, but the data flow stops piggybacking
on translated Chinese strings -- which broke the moment i18n is introduced.

- ControlPanelViewModel.RoutingMode is now "smart" | "global" (matches
  AppSettings.RoutingMode exactly, so the persistence layer is the identity
  function). Display goes through RoutingModeText.
- SetProxyMode takes "system" | "manual" instead of the localized labels.
- XAML RadioMenuFlyoutItem.CommandParameter switched to the business codes;
  the status-bar and mini-view TextBlocks now bind RoutingModeText.
- Drops the noise three-way in MainViewModel.InitializeAsync that mapped
  business codes to business codes through Chinese labels.

The Chinese in RoutingModeText / MenuFlyoutItem.Text stays for now -- it's
display text, not a code. String extraction lands in the next commit.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Wires the runtime localization from commit 1 through the highest-traffic
surfaces. ServerList, ServerDetail, MainWindow chrome and assorted minor
dialogs are still hardcoded Chinese and land in a follow-up.

- L.cs grows into a strongly-typed accessor for ~80 keys grouped by surface
  (dialog buttons, edit-server fields, error / startup / update / DNS /
  chain proxy / preset-replace dialogs, control panel state).
- DialogService: every dialog now reads from L.* / Loc.Format. The
  ShowConfirmationAsync default args (which can't be properties) switch
  to nullable + ??= fallback inside the method body; IDialogService matches.
- ControlPanelViewModel state strings (Start/Stop button, StatusText,
  RoutingModeText, error and update flows) go through L.*; UpdateMenuText
  uses Loc.Format. MainViewModel.ActiveServerName / MiniStatusText too.
- ControlPanelControl.xaml gains x:Uid on every MenuFlyoutItem / Routing /
  TUN label so PRI injects the localized .Text at build time; the original
  Chinese stays as design-time fallback.
- resw files: ~280 keys. New ChainProxy / DNS / preset-replace keys cover
  surfaces the original i18n stash never touched.

Debug.WriteLine and internal-only strings stay Chinese on purpose --
they're developer-facing.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Covers the second wave of i18n work — the main user surface and the
secondary dialogs. Static XAML labels move to x:Uid + .Text/.Content
resw entries; attached properties (AutomationProperties.Name,
ToolTipService.ToolTip) and Window.Title get wired up via code-behind
because x:Uid is awkward for those.

Files touched:
- ServerList / ServerDetail (controls + view models)
- MainWindow (title bar + tray menu)
- LogWindow (toolbar + status + privacy dialog)
- CustomRulesWindow + CustomRulesViewModel + AddRuleDialog
- PersonalizeControl remaining labels + import/export feedback
- AddChainProxyDialog, TunConfirmationDialog, ManageSubscriptionsDialog
- SubscriptionEntry.LastUpdatedText relative-time strings
- UpdateService progress + exception messages (surface in dialogs)
- ControlPanelControl Personalize tooltip

Out of scope (Chinese strings deliberately preserved):
- Debug.WriteLine / dev logs in XrayService / TunService /
  SystemProxyService / ControlPanelViewModel
- LanguageHelper.SupportedLanguages DisplayName (endonym convention)

zh-CN/Resources.resw diff is inflated by the .NET ResX writer
reformatting compact <data> entries to the standard multi-line shape;
content is preserved.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b25fbfe7db

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Helpers/LanguageHelper.cs Outdated
@PhoenixNil PhoenixNil merged commit d20596d into main May 23, 2026
1 of 2 checks passed
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.

1 participant