Skip to content

fix(i18n): keep the macOS "Local Network" wording searchable in every locale - #10536

Merged
brennanb2025 merged 1 commit into
mainfrom
brennanb2025/p2-lan-search-zh-alias
Jul 25, 2026
Merged

brennanb2025 merged 1 commit into
mainfrom
brennanb2025/p2-lan-search-zh-alias

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The Developer Permissions row is titled LAN, USB, and Bluetooth, but macOS System Settings labels the underlying privacy toggle Local Network. Search covered that mismatch with English-only aliases on the LAN keyword:

...translateSearchKeyword('…search.fa3239cd42', 'lan', {
  aliases: ['local network', 'local-network']
})

Those aliases are English. zh.json had the value for that key changed to 局域网 (LAN), so a Simplified-Chinese user who searches the wording macOS actually shows them — 本地网络 — got no hit. ja/ko/es still happened to hold Local-Network wording and kept working.

The key hash gives away how it drifted: fa3239cd42 is sha1("…developer-permissions-search.ts:local network"). The key was minted for local network; the fallback was later reworded to lan in code and in en/zh, while the other locales kept the original translation.

Fix

Carry both wordings in the catalogs instead of as English-only aliases in code, each on its own content-derived key:

key text en es ja ko zh
87620e6416 lan (new) lan LAN LAN LAN 局域网
fa3239cd42 local network local network red local ローカルネットワーク 로컬 네트워크 本地网络

Only zh's fa3239cd42 changes value; the other locales already matched macOS and just gain the LAN key. local-network stays an English alias — it's a typing convenience, not a macOS string.

No translated copy was invented. LAN terms are lifted from this repo's own translations of the row title (3363889768: LAN, USB y Bluetooth / LAN、USB、Bluetooth / LAN, USB 및 블루투스 / 局域网、USB 和蓝牙). Local-Network terms are the literal values macOS 26.5.1 ships in SecurityPrivacyExtension.appex/Contents/Resources/Localizable.loctable, key LOCAL_NETWORK:

en: 'Local Network' | zh_CN: '本地网络' | ja: 'ローカルネットワーク' | ko: '로컬 네트워크' | es: 'Red local'

Tests

New developer-permissions-search.test.ts drives the real matchesSettingsSearch path against the real catalogs across all five locales.

Revert-check (git apply -R of the source+catalog diff, test file kept):

 ❯ developer-permissions-search.test.ts (8 tests | 2 failed)
   × finds the LAN row from the macOS Local Network wording in zh
   × indexes both wordings as distinct Chinese keywords

AssertionError: expected false to be true
AssertionError: expected [ Array(14) ] to deeply equal ArrayContaining ["局域网", "本地网络"]

Restored: Test Files 1 passed (1) / Tests 8 passed (8).

Gates

  • npx vitest run --config config/vitest.config.ts on the new file plus settings-search-keywords, settings-search, appearance-status-bar-search, accounts-search, src/renderer/src/i18n — 9 files, 37 tests, all pass
  • npm run typecheck — clean
  • npm run lint — exit 0 (includes verify:localization-catalog and verify:localization-coverage; parity 11155 keys × 4 locales)
  • Locale values confirmed present per file after editing — the sync tooling only backfills missing keys with the English string, so all values were hand-placed and re-read back.

Static + test verification only; not exercised in a running app.

Screenshots

No visual change. This PR only changes what the settings-search index matches on; no rendered copy, layout, or component changes. The row title (3363889768, "LAN, USB, and Bluetooth") is untouched in all five locales.

Testing

  • pnpm lint — exit 0 (includes verify:localization-catalog + verify:localization-coverage)
  • pnpm typecheck — clean
  • pnpm test — settings/ + i18n/ scope: 113 files, 717 tests pass
  • Added tests that would catch the regression (revert-check below)

AI Review Report

Reviewed with Claude Opus (reviewer subagents + independent verification). Risks checked and how they were resolved:

  • Key-hash correctness. Derivation scheme confirmed in config/scripts/localize-renderer-strings.mjs: sha1(${filePath}:${text}).slice(0, 10). Recomputed independently: 87620e6416 == lan ✅ and fa3239cd42 == local network ✅, with untouched pre-existing keys as controls (c4a4a02ea4 == usb, e3fbc48083 == bluetooth) proving the scheme. The re-key restores key/content integrity that drifted in Rename 'Local Network' to 'LAN' across mobile and settings UI #10216; it does not invent one.
  • No orphans / duplicates. Both keys are referenced exactly once in code and present in all five catalogs. verify:localization-catalog reports parity at 11155 keys for es/ja/ko/zh and 10336 verified references.
  • Localized copy not invented. Verified against the real OS file, not the PR author's claim: /System/Library/ExtensionKit/Extensions/SecurityPrivacyExtension.appex/Contents/Resources/Localizable.loctable, key LOCAL_NETWORK → en Local Network, zh_CN 本地网络, ja ローカルネットワーク, ko 로컬 네트워크, es Red local — exact match. LAN terms match this repo's own title translations (3363889768).
  • No regression for existing users. Empirical keyword-array dump, base vs head:
    • en — byte-identical: ["lan","local network","local-network","usb",…]
    • zh — gains 本地网络 (base had only 局域网) → this is the fix
    • es/ja/ko — each gains LAN, lose nothing
  • Perf. createLocalizedCatalog caches per locale and invalidates only on language change, so entries are built once per locale, not per keystroke. One extra keyword on one entry; no measurable cost.
  • Cross-platform (macOS / Linux / Windows). Explicitly checked and not applicable to behavior: the change is renderer-side catalog data and a keyword array, with no paths, shell invocation, keyboard shortcuts, accelerators, or Electron platform APIs touched. The Local Network wording describes a macOS System Settings label, but indexing it is inert on Linux/Windows — it only ever adds a search term. Equally unaffected by SSH, folder-workspace vs git-worktree, and git-provider differences.

Security Audit

No security-relevant surface. No input handling, command execution, path handling, auth, secrets, IPC, or dependency changes. The diff adds two static translation strings to JSON catalogs and one entry to an in-memory keyword array; all values are compile-time constants rendered as search text, never interpolated into a shell, path, or query. No follow-up needed.

Notes

  • Root cause of the drift is Rename 'Local Network' to 'LAN' across mobile and settings UI #10216 ("Rename 'local network' to 'LAN' across the UI"), which reworded the fa3239cd42 value in en/zh while its content hash still encoded local network, and left ja/ko/es on the original translation. This PR realigns keys to content so the two wordings can no longer drift apart.
  • local-network intentionally stays an English-only alias — it's a hyphen-typing convenience, not a string macOS ships, so it doesn't warrant a catalog key.
  • Verified static + tests only; not exercised in a running app.

… locale

Settings search indexed the macOS privacy-toggle name as English-only
aliases on the LAN keyword, so a Chinese user typing the term macOS
System Settings actually shows them (本地网络) got no hit — zh's catalog
value had been changed to 局域网 (LAN).

Split the two wordings onto their own catalog keys so each locale carries
both: 87620e6416 = LAN, fa3239cd42 = Local Network (its true content
hash). Localized values come from the repo's own LAN title translations
and from macOS 26's SecurityPrivacyExtension Localizable.loctable
(LOCAL_NETWORK), so nothing is invented. ja/ko/es already matched macOS
and are unchanged apart from gaining the LAN key.
@coderabbitai

coderabbitai Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Updates developer-permissions search indexing for LAN and macOS “Local Network” terminology, including localized catalog entries across English, Spanish, Japanese, Korean, and Chinese. The LAN search entry now uses localized keywords with a local-network alias. A Vitest suite verifies locale-specific labels, English aliases across locales, selected localized terms, and separate Chinese keyword indexing.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: making macOS Local Network wording searchable across locales.
Description check ✅ Passed The description is mostly complete, covering summary/problem, screenshots, testing, AI review, security, and notes, though its headings differ from the template.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review-agent response to CodeRabbit

CodeRabbit reported "No actionable comments" on the diff itself, and 0 inline comments. Its two failed pre-merge checks are addressed below — one actioned, one declined with reasoning.

1. Description check — ✅ ACTIONED

The description was missing the template's Screenshots, AI Review Report, Security Audit, and Notes sections. The PR body has been updated to add all four, including the explicit macOS/Linux/Windows cross-platform confirmation the check asked for.

2. Docstring Coverage (0.00%, threshold 80.00%) — ❌ DECLINED

Declined deliberately, for three reasons:

It conflicts with this repo's own written style rule. AGENTS.md states, under Style → Concise/Brief Non-obvious comments ONLY:

  • DO NOT: be verbose, explain the obvious, walk through the code ("WHY not HOW")
  • DO: BE CONCISE. 1 LINE if possible

Adding docstrings to satisfy a percentage would produce exactly the "explain the obvious" comments AGENTS.md prohibits. The repo rule wins over a generic bot threshold.

There is nothing here that warrants a docstring. The diff adds (a) two static string values to JSON catalogs, (b) one translateSearchKeyword(...) spread inside an existing keyword array, and (c) a test file whose two local helpers — getLanEntry() and searchInLocale(locale, query) — are self-describing five-liners. The only genuinely non-obvious thing in the change is why both wordings must be indexed, and that is already captured in the existing inline // Why: comment, which this PR extends:

// Why: UI says LAN (aligned with mobile), but macOS System Settings still
// labels the privacy toggle "Local Network" — index both through the
// catalogs so every locale keeps the wording macOS actually shows it.

That is the WHY-not-HOW comment the codebase asks for. A docstring restating "returns the LAN entry" would add zero information.

It would expand the scope. This PR is deliberately one concern: keep the macOS Local Network wording searchable in every locale. Adding docstrings to hit a coverage bar is unrelated churn, and this PR is being held to a strict single-concern bar.

No repo lint gate enforces docstring coverage — pnpm lint passes at exit 0, including verify:localization-catalog and verify:localization-coverage.


Independent verification performed

Beyond CodeRabbit, this PR was verified against the two highest-risk claims rather than taken on trust:

  • Key re-keying is correct, not invented. Derivation confirmed in config/scripts/localize-renderer-strings.mjs as sha1(${filePath}:${text}).slice(0, 10), then recomputed: 87620e6416 == lan and fa3239cd42 == local network, with untouched keys c4a4a02ea4 == usb and e3fbc48083 == bluetooth as controls. The re-key restores integrity that drifted in Rename 'Local Network' to 'LAN' across mobile and settings UI #10216.
  • Localized copy verified against the real macOS source, not the PR description: /System/Library/ExtensionKit/Extensions/SecurityPrivacyExtension.appex/Contents/Resources/Localizable.loctable, key LOCAL_NETWORK → en Local Network, zh_CN 本地网络, ja ローカルネットワーク, ko 로컬 네트워크, es Red local. Exact match.
  • Tests are not vacuous. With the source + catalog changes reverted and the test file kept, 2 of 8 tests fail (expected false to be true; keyword array missing 本地网络); restored, 8/8 pass.
  • No regression for existing users. Empirical base-vs-head keyword dump: en is byte-identical, zh gains 本地网络, and es/ja/ko each gain LAN while losing nothing.

@brennanb2025
brennanb2025 merged commit 5faf3b2 into main Jul 25, 2026
2 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
… locale (stablyai#10536)

Settings search indexed the macOS privacy-toggle name as English-only
aliases on the LAN keyword, so a Chinese user typing the term macOS
System Settings actually shows them (本地网络) got no hit — zh's catalog
value had been changed to 局域网 (LAN).

Split the two wordings onto their own catalog keys so each locale carries
both: 87620e6416 = LAN, fa3239cd42 = Local Network (its true content
hash). Localized values come from the repo's own LAN title translations
and from macOS 26's SecurityPrivacyExtension Localizable.loctable
(LOCAL_NETWORK), so nothing is invented. ja/ko/es already matched macOS
and are unchanged apart from gaining the LAN key.
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