Dual Entry Points for Desktop AI Coding Tools: A Chinese Localization Approach
This article explains how to localize desktop AI coding tools into Chinese using two separate launch entry points and runtime injection. It covers why static app-package patching falls short, how a presentation-layer overlay handles UI text, placeholders, timestamps, and auto-generated titles, and how layered prompts keep answers and reasoning in Chinese. It also includes reliability, security, and rollback practices for a low-maintenance, reversible setup.
1. Background: Why a Single “Answer in Chinese” Rule Is Not Enough
Once a desktop AI coding tool becomes part of the daily workflow, localization quickly shifts from a nice-to-have to a frequent source of friction. The symptoms usually appear at four levels:
- UI copy remains in English, including the new-session welcome message, input placeholders, and relative timestamps.
- Session titles are generated automatically and often show up as short English phrases.
- Even with a global rule such as “always answer in Chinese,” the model’s internal reasoning still drifts back to English from time to time.
- Global rules are coarse-grained and can “pollute” technical workspaces that are supposed to stay in English.
Grouped together, these issues form two independent chains:
- Presentation layer: UI copy, placeholders, timestamps, and auto-generated titles. This is client-rendered text and has nothing to do with model capability.
- Generation layer: answer language and reasoning language, influenced by prompts, context, and the model’s default distribution.
The original attempt to “unpack and replace resources inside the application package” is a static rewrite of the presentation layer, and its drawbacks are clear: every minor version upgrade requires re-patching, and on some desktop systems modifying package contents breaks code signing, which triggers permission prompts and startup validation failures. A better direction is to move the rewrite from static modification at install time to dynamic injection at runtime, and to handle the two chains separately.
2. Overall Design: Dual Entry Points and Zero-Intrusion Injection
The goal can be stated precisely: on the desktop there are two independent launch entry points. One enters a fully Chinese environment (UI, runtime chain, timestamps, titles, reasoning), while the other keeps the original English environment. The two do not bleed into each other, and exiting the Chinese entry point automatically returns to the default state.
Four key design decisions make this work.
Entry isolation. The Chinese entry point is essentially a launcher with specific startup parameters; the English entry point is the original program entry. Both share the same installed artifacts, with no copying and no rewriting of the application package. Upgrades therefore only require replacing the installed artifacts, and the launcher needs no re-patching.
Runtime injection. Desktop apps are commonly built on a browser engine. At startup, enable a remote debugging port and inject scripts through the debugging protocol after the page finishes loading. This does not touch resource files inside the install directory, so it naturally avoids the code-signing problem.
Enhancement overlay. A basic word list only covers high-frequency static copy and tends to miss “edge cases” such as rotating welcome messages, compound placeholders, and relative times. An optional enhancement script layered on top of the word list fills these gaps using “text node matching + whitelist skipping.”
Rollback capability. All changes happen at the process-memory and startup-parameter level and expire when the process exits. Combined with install-time integrity checks and a one-click restore script, this forms a closed loop.
A schematic startup parameter structure (pseudocode, expressing the idea only):
# Chinese entry point: enable debugging port + load enhancement overlay scriptlauncher --remote-debugging-port=9222 --trust-external-overlay# English entry point: original launch method, no extra parameterslauncher
3. Presentation Layer: Filling the UI Gaps
The hard part of presentation-layer localization is not translation but locating the right text at the right time. A three-layer strategy is recommended.
The first layer is static copy mapping. Maintain a key-value word list that maps high-frequency UI strings to Chinese. Store the list in a structured format so it can be versioned, diffed, and proofread collaboratively.
The second layer is dynamic copy overriding. Rotating welcome messages, rotating placeholders, and automatically generated session titles are dynamic text that must be rescanned after DOM changes. A mutation-observer mechanism with throttling and deduplication is recommended to avoid performance loss from frequent redraws:
const seen = new WeakSet();const timer = { id: 0 };function scan() {for (const el of document.querySelectorAll('[data-i18n], .label, .placeholder')) {if (seen.has(el)) continue;const next = translate(el.textContent || el.getAttribute('placeholder'));if (next) { el.textContent = next; seen.add(el); }}}new MutationObserver(() => {clearTimeout(timer.id);timer.id = setTimeout(scan, 120);}).observe(document.body, { childList: true, subtree: true, characterData: true });
The third layer is a whitelist that prevents collateral damage. Code blocks, terminal output, user content, and diffs must never be rewritten. The recommended check order is: first look at ancestor-node markers, then node type, and only then text matching. Localizing relative times (such as “8m ago” or “Just now”) should be limited to toolbar and action-bar containers to avoid matching identical strings in body text.
The common approach for auto-generated titles is to take the first question in the session, truncate its length and normalize whitespace, generate a concise Chinese title, and write it back to the breadcrumb and history-list nodes. Add an idempotency check before writing to prevent the observer from triggering itself in a loop.
4. Generation Layer: Keeping Reasoning in Chinese
The generation layer cannot rely on a hard-coded global rule. Instructions should be organized in priority layers:
- Session-level temporary instructions: injected only in the Chinese entry point, with the smallest scope and no pollution of the English workspace.
- Project-level rule files: effective only within repository directories that need Chinese.
- Output structure constraints: require “Chinese conclusion first, then code, then Chinese explanation” to reduce the chance of drift in reasoning paragraphs.
It should be stated objectively that the language of a model’s reasoning is affected by sampling randomness, and no approach can promise 100% stability. The engineering goal should be “Chinese in the vast majority of cases, with occasional drift recoverable via one-click reinjection.” If drift is noticeable, the injection script can listen for session-switch events and replay the session-level instructions.
5. Reliability, Security, and Rollback Checklist
- Integrity verification: compare hashes of downloaded artifacts at install time and abort on mismatch to keep tampered binaries off the machine.
- Least privilege: bind the debugging port to the loopback address only, and close it when the process exits rather than leaving it open.
- No on-disk rewriting: do not write to the application install directory or modify package resources, so upgrades require zero maintenance.
- One-click restore: provide an uninstall script that removes the launcher and configuration and restores the original state.
- Observability: emit concise logs when injection fails to help determine whether the cause is a selector change or a permission issue.
6. Conclusion
Localizing desktop AI coding tools is essentially a combined engineering effort: runtime injection at the presentation layer plus layered prompts at the generation layer. Replacing static rewriting with dynamic injection, and a single global rule with scope-isolated dual entry points, delivers a complete Chinese experience while preserving the original English environment and keeping risk low when versions upgrade or system permission policies change. The same approach applies to localizing any desktop application built on a browser engine, with transferable, maintainable, and rollback-friendly engineering value.
