Implementation:3641397194 wq Gpt6 Astra ZhCnPlugin
| Knowledge Sources | |
|---|---|
| Domains | UI_Localization, Reverse_Engineering |
| Last Updated | 2026-10-26 14:00 GMT |
Overview
Concrete tool for runtime Chinese-language localization of the IDA Pro 9.x Qt5/PyQt5 interface, translating menus, labels, buttons, and dialogs without modifying any IDA files, provided by the ColdBrew Zero ida-zh-cn plugin.
Description
The ZhCnPlugin (`ida_zh_cn.py`) is an IDA Pro plugin that translates the IDA user interface into Simplified Chinese at runtime. It uses two complementary strategies to avoid breaking IDA's window/menu identity strings:
- Paint-layer translation (QProxyStyle): menu bars, menus, tab labels, and table headers are translated in `drawControl` by swapping the `QStyleOption.text` on a translated copy. The real control text stays English so `find_widget("Output window")` and `attach_action_to_menu("Edit/Plugins/")` lookups keep working.
- Direct text replacement: labels, buttons, group boxes, combo items, tooltips, and dialog titles are replaced with Chinese and the original English is stored as a Qt property for restoration on uninstall.
Translation uses a JSON dictionary (`zh_cn.json`) with exact English→Chinese matching, plus regex rules for dynamic text (e.g. `IDA View-A` → `IDA 视图-A`). A user override file (`zh_cn_user.json`) can supplement the base dictionary. Unmatched UI strings are logged to `ida_zh_cn_missing.txt` for later dictionary expansion. Uninstall is clean: delete the two plugin files and all English text is restored.
Usage
- One-click install: the ColdBrew Zero desktop app uses `ida-toolbox.js` to copy `ida_zh_cn.py` + `zh_cn.json` into the IDA plugins directory; IDA loads the plugin on next start.
- Toggle at runtime: run the plugin via Edit > Plugins > "中文界面 开/关" to switch between Chinese and English without restarting IDA.
- Hot-reload during development: `exec(open('ida_zh_cn.py').read())` in the IDAPython console calls `reload_and_enable()` for instant testing.
- Direct run: File > Script file... (Alt+F7) on `ida_zh_cn.py` enables localization immediately.
Code Reference
Source Location
- Repository: ColdBrew Zero
- File: tools/ida-zh-cn/plugin/ida_zh_cn.py
- Lines: 1-531
Signature
def load_dict() -> int
def translate(raw: str, mnemonic: bool = True) -> str | None
def translate_menu(text: str) -> str | None
def enable(save: bool = True) -> bool
def disable(save: bool = True) -> None
def toggle() -> None
def reload_and_enable() -> None
class ZhCnPlugin(ida_idaapi.plugin_t):
flags = ida_idaapi.PLUGIN_FIX
wanted_name = "中文界面 开/关"
def init(self) -> int
def run(self, arg: int) -> None
def term(self) -> None
def PLUGIN_ENTRY() -> ZhCnPlugin
Import
# Loaded by IDA Pro as a plugin — not imported as a module.
# In the IDAPython console for hot-reload:
# exec(open(r"path/to/ida_zh_cn.py").read())
# reload_and_enable()
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| zh_cn.json | JSON file | Yes | English→Chinese dictionary (exact match) |
| zh_cn_user.json | JSON file | No | User overrides/supplements for the base dictionary |
| ida_zh_cn.conf.json | JSON file | No | Persisted enabled/disabled state (defaults to enabled) |
| raw | string | Yes (translate) | English UI text to translate |
Outputs
| Name | Type | Description |
|---|---|---|
| translate returns | None | Chinese translation, or None if no match |
| ida_zh_cn_missing.txt | File | Logged unmatched UI strings for dictionary expansion |
| ida_zh_cn.conf.json | File | Persisted enabled/disabled toggle state |
Usage Examples
Enable / Disable / Toggle
# In the IDAPython console or via the Plugins menu:
import ida_zh_cn
ida_zh_cn.enable() # Turn on Chinese UI; persists to conf
ida_zh_cn.disable() # Turn off, restore English; persists to conf
ida_zh_cn.toggle() # Flip current state
Translate a String Programmatically
import ida_zh_cn
n = ida_zh_cn.load_dict()
print("loaded", n, "entries")
print(ida_zh_cn.translate("Abort")) # '中止(&A)'
print(ida_zh_cn.translate("IDA View-A")) # 'IDA 视图-A' (via regex rule)
print(ida_zh_cn.translate("nonexistent")) # None
Hot-Reload After Editing the Dictionary
# IDAPython console — reloads the plugin file and re-enables:
exec(open(r"/path/to/ida_zh_cn.py").read())
# reload_and_enable() runs automatically at the end