Skip to content

fix(rime): register 中州韻 under the Traditional Chinese locale (#481) - #1021

Open
asdf80730 wants to merge 5 commits into
EasyIME:masterfrom
asdf80730:pr/rime-locale-481
Open

asdf80730 wants to merge 5 commits into
EasyIME:masterfrom
asdf80730:pr/rime-locale-481

Conversation

@asdf80730

@asdf80730 asdf80730 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

fix(rime): register 中州韻 under both Chinese locales (#481)

Fixes #481

中州韻輸入法 registers its TSF language profile from registration data:
langProfileFromJson (PIMETextService/DllEntry.cpp) reads locale and
fallbackLocale from the IME's ime.json, and libIME2
(ImeModule.cpp:registerLangProfiles) converts them with LocaleNameToLCID —
retrying the RFC 1766 fallback only when the RFC 4646 name does not convert —
then calls AddLanguageProfile under LANGIDFROMLCID. The rime profile
shipped zh-Hans-CN / zh-CN, so the profile only appeared for users who had
Simplified Chinese enabled; every other PIME input method declares
zh-Hant-TW / zh-TW.

Per your two notes, the original one-manifest-per-profile layout is kept and
the engine is shared:

  • python/input_methods/rime/ime.json (zh-Hant-TW / zh-TW) and
    python/input_methods/rime-cn/ime.json (zh-CN / zh-CN), one Windows
    input language per folder, each with its own profile GUID, so
    DllRegisterServer issues two AddLanguageProfile calls and neither locale
    loses the engine. The go twin pairs the same way under
    go-backend/input_methods/.
  • The engine lives once in python/rimebase (librime.py,
    rime_keyevent.py, rime_service.py, rime.dll, data/, icons/), next
    to cinbase; each input_methods/ folder carries only its ime.json and a
    thin rime_ime.py wrapper that re-exports the one RimeTextService, so
    data/PIME.yaml and the icon set exist once. icon is now
    ../rimebase/icon.ico, which the C++ reader resolves relative to the
    manifest's own directory.
  • With one profile per manifest, every dispatcher is back to comparing the
    flat guid: langProfileFromJson returns the single profile it read,
    python/serviceManager.py, go-backend/server.go (case "rime", "rime-cn"),
    node/loadServices.js and PIMETextService/PIMEImeModule.cpp each match one
    guid, and the header-only PIMETextService/ImeProfileGuids.h helper drops
    the array walk. No manifest carries additionalProfiles any more.
  • installer/installer.nsi stages python\rimebase (engine, data, opencc)
    plus the two IME folders; the PYTHON_CHS_SECTION_GROUP entry is the
    installer's own grouping and is unchanged.

Validation on 08df868, run on the Windows box:

  • python, bundled python/python3/python.exe:
    python/python3/python.exe -m unittest discover -s tests -p "test_rime_registration_locale.py"
    → Ran 8 tests ... OK (both folders per backend, one named GUID each, the
    pair each folder answers, twins agree on the locale pair);
    ... -p "test_service_manager.py" → Ran 12 tests ... OK (the two shipped
    python manifests resolve by their own GUID to two infos over one engine
    class); ... -p "test_rime_log_bounds.py" → Ran 9 tests ... OK.
  • go: go.exe test -count=1 ./... (with APPDATA cleared) → ok for
    github.com/EasyIME/pime-go, input_methods/meow, input_methods/rime;
    the root package's two profile cases now read both folders.
  • node: node.exe test\loadServices.test.js passes on a fixture with two
    folders (demo, demo-cn, distinct markers) plus a guid-less manifest that
    registers no key.
  • C++: g++.exe -std=c++17 -O1 -static compiles and runs
    tests/ime_profile_guids_test.cpp (each folder hits its own GUID, the
    folders do not answer for each other, case-insensitive in both directions,
    miss, missing guid key, empty guid, non-string guid, null document).
  • DllEntry.cpp, PIMEImeModule.cpp and the rest of the TSF layer are
    compiled by the build-and-sign job; this box's vendored mingw carries no
    Windows SDK headers.

Architecture and design by asdf80730. Implementation generated with AI
assistance from omp (tensorfold/Qwen3.8-Flash-Next).

@PCMan

PCMan commented Nov 6, 2026

Copy link
Copy Markdown
Member

Replacing "locale": "zh-Hans-CN" / "fallbackLocale": "zh-CN" with "zh-Hant-TW" / "zh-TW" directly in ime.json will remove Rime from the Simplified Chinese (zh-CN) language profile (note that Rime is also currently listed under PYTHON_CHS_SECTION_GROUP in installer/installer.nsi).

Instead of replacing zh-CN with zh-TW, Rime should provide both zh-CN and zh-TW variants (with distinct language profile GUIDs) so both Simplified Chinese and Traditional Chinese users can register and use Rime under their respective Windows input locales.

(Review comment generated on behalf of @PCMan with AI assistance from Google Antigravity + Gemini 3.1 Pro)

@asdf80730

Copy link
Copy Markdown
Contributor Author

Both buckets are registered on 75e3299, per your note:

  • locale/fallbackLocale stay the Traditional pair (zh-Hant-TW / zh-TW → 0x0404) for the primary profile.
  • one additionalProfiles entry adds the Simplified pair (zh-CN / zh-CN → 0x0804) under its own profile GUID, so DllRegisterServer calls AddLanguageProfile twice for the one CLSID and neither locale loses the engine.
  • langProfileFromJson returns the profiles it read (std::vector) and parses that array; the flat keys remain the first profile, so every other ime.json registers exactly as before. The python and go twins carry the same three keys, and installer/installer.nsi needs no edit — its PYTHON_CHS_SECTION_GROUP entry is the installer section grouping, not the TSF profile.

(Comment generated with assistance from omp (tensorfold/Qwen3.8-Flash-Next))

@asdf80730

Copy link
Copy Markdown
Contributor Author

Heads are rewritten (9157da5), so the workflow runs are queued again (check-suites is empty, i.e. action_required). A maintainer approval of the first run would give the merge-state check its CI evidence; the local evidence is in the body.

(Comment generated with assistance from omp (tensorfold/Qwen3.8-Flash-Next))

@PCMan

PCMan commented Nov 8, 2026

Copy link
Copy Markdown
Member

Thank you for updating DllEntry.cpp and ime.json to register additionalProfiles!

However, there is still a runtime bug when the user actually selects the additionalProfiles (zh-CN) profile in Windows:

  • When TSF activates the zh-CN Rime profile, PIMEClient::init sends the profile GUID from additionalProfiles ({53c15256-7a5f-4b54-86e8-0636e0745c3e} for Python, {9882e350-9462-4d42-9882-7847044ea725} for Go) as "id" in the init IPC request.
  • Currently, none of the runtime service dispatchers or config loaders check additionalProfiles:
    1. python/serviceManager.py (TextServiceInfo.loadFromJson / TextServiceManager.load) only registers json_data["guid"].lower() ({9c2d6c68-9ea6-4cfb-a769-7e619db7f267}). When a client connects with {53c15256-7a5f-4b54-86e8-0636e0745c3e}, serviceManager.createService() returns None and Rime fails to initialize under zh-CN.
    2. go-backend/server.go (newClient) only matches {3f6b5a12-8d44-4e71-9a2e-6b4f9c1d2a30}, so Go Rime also fails to initialize when activated via {9882e350-9462-4d42-9882-7847044ea725}.
    3. PIMETextService/PIMEImeModule.cpp (ImeModule::loadImeInfo) only compares content["guid"], so onConfigure will not find ime.json when invoked on an additionalProfiles GUID.

Please update python/serviceManager.py, go-backend/server.go, and PIMETextService/PIMEImeModule.cpp (and node/loadServices.js if additionalProfiles is part of the ime.json contract) so that activating or configuring an additionalProfiles GUID resolves to the text service.

(Review comment generated on behalf of @PCMan with AI assistance from Google Antigravity + Gemini 3.1 Pro)

asdf80730 added a commit to asdf80730/PIME that referenced this pull request Nov 9, 2026
EasyIME#481, follow-up to the review on EasyIME#1021: the rime ime.json now
carries an additionalProfiles entry (the zh-CN twin of the zh-Hant-TW
profile), but only the flat guid was known to the dispatchers, so a client
that activates the second profile got no service.

- python/serviceManager.py: TextServiceInfo gains additionalGuids, filled
  from additionalProfiles (each entry's guid, lowercased; an entry without a
  usable guid is skipped, as the flat keys already fall back), and
  TextServiceManager.load() registers the same info under each of them.
- go-backend/server.go: additionalProfileGuids(imeConfig) reads the array and
  both the meow and the rime case register the factory for the primary and
  every profile GUID, so newClient finds one for the second profile too.
- PIMETextService/PIMEImeModule.cpp: ImeModule::loadImeInfo matches the flat
  guid, then walks additionalProfiles, so onConfigure finds the ime.json from
  either profile GUID.
- node/loadServices.js: loadServiceById compares the primary guid or any
  additionalProfiles[].guid.

Validation on this tree:

- python/python3/python.exe -m unittest discover -s tests -p
  "test_service_manager.py": Ran 10 tests ... OK. The new case asserts both
  keys are registered, that they map to the same TextServiceInfo, and that
  createService() on the additional GUID returns an instance.
- go.exe test -count=1 ./... with APPDATA cleared (as tests/verify_windows.sh
  runs it): ok for pime-go, meow, rime and pime. Two new tests read the
  shipped go-backend/input_methods/rime/ime.json — the profile GUID is exactly
  {9882e350-9462-4d42-9882-7847044ea725} and differs from the primary
  {3f6b5a12-8d44-4e71-9a2e-6b4f9c1d2a30} — and a manifest with a missing or
  non-string guid and a non-object entry yields only the usable lowercased one.
- node.exe test\loadServices.test.js passes with the fixture extended by
  additionalProfiles (one real profile, one entry without a guid, one null):
  lookup by the additional GUID returns the same module as the primary.
- PIMEImeModule.cpp is compiled by the build-and-sign job; this box's vendored
  mingw carries no Windows SDK headers, so only the two pure C++ helpers build
  locally.
@asdf80730

Copy link
Copy Markdown
Contributor Author

All four dispatchers now resolve the additionalProfiles GUIDs, so activating or configuring 中州韻 under the second locale reaches the service:

  • python/serviceManager.py: TextServiceInfo gains additionalGuids, filled from json_data["additionalProfiles"] (each entry's guid, lowercased; entries without a usable guid are skipped, matching how the flat keys fall back), and TextServiceManager.load() registers the same TextServiceInfo under each of them. A client that connects with {53c15256-…} therefore gets the Rime service from createService().
  • go-backend/server.go: a new additionalProfileGuids(imeConfig) helper reads the array, and both the meow and the rime case register the factory for the primary GUID and every profile GUID, so newClient finds a factory for {9882e350-…} too.
  • PIMETextService/PIMEImeModule.cpp: ImeModule::loadImeInfo matches the flat guid first, then walks additionalProfiles (content.find("additionalProfiles"), is_array(), jsonValueOr<std::string>(profile, "guid", "")), so onConfigure finds the ime.json from either profile GUID.
  • node/loadServices.js: loadServiceById compares the primary guid or any additionalProfiles[].guid.

Evidence on 9157da5 + this commit:

  • Go: go.exe test -count=1 ./... (with APPDATA cleared, as the local harness does) — ok github.com/EasyIME/pime-go and the other three packages. Two new tests: the shipped go-backend/input_methods/rime/ime.json yields exactly ["{9882e350-9462-4d42-9882-7847044ea725}"] and that differs from the primary {3f6b5a12-…}, and a manifest with a missing/non-string guid and a non-object entry yields only the one usable lowercased GUID.
  • Python: python/python3/python.exe -m unittest discover -s tests -p "test_service_manager.py" → Ran 10 tests … OK; the new case asserts both keys are registered, that they map to the same TextServiceInfo, and that createService() on the additional GUID returns an instance.
  • Node: node.exe test\loadServices.test.js passes with the fixture extended by additionalProfiles (one real profile, one entry without a guid, one null) — lookup by the additional GUID returns the same module as the primary.
  • PIMEImeModule.cpp is compiled by the build-and-sign job; this box's vendored mingw carries no Windows SDK headers, so only the two pure C++ helpers build locally.

@PCMan PCMan self-assigned this Nov 9, 2026
@PCMan

PCMan commented Nov 9, 2026

Copy link
Copy Markdown
Member

Actually, the original design of ime.json was one ime.json per language profile. Won't it be simipler to just create multiple ime json files one per profile?

@asdf80730

Copy link
Copy Markdown
Contributor Author

Tip: 8dee501 (3 commits on upstream/master 50bf6cb). The new commit is the shared PIMETextService/ImeProfileGuids.h for the loadImeInfo match plus its local test; the two product files are all the diff adds. Answers to the open points: (1) the per-backend profile GUIDs stay per backend because each dispatcher reads only its own tree, so a per-profile ime.json would be scanned as a second IME while both profiles share one CLSID — recorded as GUIDs distinct within one file, never compared across twins, with the locale/fallbackLocale pair as the only cross-twin invariant; (2) the root go package still does not build its test binary at this base (server_integration_test.go imports input_methods/fcitx5, absent from that tree), which is pre-existing and independent of this diff.

asdf80730 added a commit to asdf80730/PIME that referenced this pull request Nov 9, 2026
The EasyIME#1021 review round found the second language profile registered but not
resolvable, and no layer went red: the round-one cases read the manifests
(locale pairs, one extra entry, distinct GUID) and probed `LocaleNameToLCID`,
so they proved the data while each backend's own fixture proved only what that
fixture literally said. Three pins close the gap, each with a negative control.

- `tests/test_service_manager.py`: `test_shipped_rime_manifest_registers_both_profiles`
  drives `TextServiceManager.load()` over the product tree instead of the
  synthetic one, asserts both GUIDs are keys, that they map to the same
  `TextServiceInfo`, and pins the two literals `DllRegisterServer` hands to
  `AddLanguageProfile`. Stubbing the registration loop in `python/serviceManager.py`
  reddens 2 cases (11 pass as-is).
- `node/test/loadServices.test.js`: the fixture already carried
  `additionalProfiles` but asserted nothing on it. Now the extra GUID resolves
  to the same module as the primary, the lookup is case-insensitive on both
  sides, and a locale-only or null entry registers no key. Deleting the match
  arm in `node/loadServices.js` fails with `actual: null` (exit 1).
- `tests/test_rime_registration_locale.py`:
  `test_every_profile_entry_carries_a_registration_guid` walks every backend's
  `input_methods/*/ime.json` and demands a flat guid, an object entry with its
  own guid per additional profile, and no guid naming two profiles — the shape
  `DllRegisterServer` and all four dispatchers read. 7 cases pass.

The per-backend GUIDs stay unequal by design (`{9c2d6c68-…}` python,
`{3f6b5a12-…}` go for rime, `{7a1c2e93-…}` for the go 喵喵 copy): each backend
registers its own CLSID, so only the locale pair is a cross-twin invariant and
that is what `test_twins_agree_on_one_locale_per_ime` compares.

`go.exe test -count=1 ./...` with `APPDATA` cleared, as `tests/verify_windows.sh`
runs it: ok for `pime-go`, `meow`, `rime` and `pime`; stubbing
`additionalProfileGuids` fails both of its cases.
asdf80730 added a commit to asdf80730/PIME that referenced this pull request Nov 9, 2026
The EasyIME#1021 round-2 review settled the rule inside the PR thread only, so the next
agent comparing twins "fixes" the unequal GUIDs and breaks registration:
`DllRegisterServer` hands each `input_methods/*/ime.json` its own `guid` to
`AddLanguageProfile`, and each backend's dispatcher matches only its own tree,
so the unit that must be distinct is the pair inside one file — the flat `guid`
plus each `additionalProfiles[].guid` — not the value shared across twins.

- `docs/adr/0004-per-backend-profile-guids.md` (new): the within-file /
  cross-file rule, why the locale pair is the only cross-twin invariant (one IME
  once per language-list bucket, while the CLSID to profile map is per backend),
  the two consumers that must agree per file (`PIMETextService/DllEntry.cpp`
  `langProfileFromJson` plus that backend's own dispatcher), and the shipped
  manifest literals as the pinned exhibit.
- `tests/test_rime_registration_locale.py`: the two adjudicating tests name the
  ADR in their comments, cited by heading, so the reasoning is one jump away.

Validation on this tree:

- `bash tests/check_line_citations.sh`: `checked 274 citation(s)`, rc 0.
- `bash tests/check_tracker_layout.sh`: `checked 5 feature directories`, rc 0;
  125 inside the linked worktree, where the gitignored `.scratch` does not live.
- `bash tests/check_ai_declarations.sh`: `checked 4 added file(s)`, rc 0, and the
  staged form plus `check_sh_exec_bits.sh staged` also exit 0.
- `python/python3/python.exe -m unittest discover -s tests -p "test_agent_docs.py"`:
  OK, 5 cases; `... -p "test_rime_registration_locale.py"`: OK, 7 cases, the edit
  being comment-only. The whole suite runs `OK (skipped=4)` over 301 tests; the
  pre-commit hook was stepped through by hand because its log path
  `$root/.git/pime-pre-commit-suite.log` is unusable where `.git` is a gitdir file.

Fully generated by omp (Qwen3.8-Flash-Next) without human intervention.
@asdf80730

Copy link
Copy Markdown
Contributor Author

CI is green on this head (8dee501): ci / build-and-sign = success, release = skipped, so the four dispatchers (python/serviceManager.py, go-backend/server.go, node/loadServices.js, PIMETextService/PIMEImeModule.cpp) are CI-verified. One pre-existing base gap, not from this diff: the root Go package does not build its test binary at this base because server_integration_test.go imports input_methods/fcitx5, absent there.

(Comment generated with assistance from omp (tensorfold/Qwen3.8-Flash-Next))

@PCMan

PCMan commented Nov 13, 2026

Copy link
Copy Markdown
Member

Thanks for looking into this! However, I prefer to stick to the original design: one ime.json per language profile, where each input method profile resides in its own folder under input_methods/. Adding additionalProfiles requires changing the manifest schema and updating profile lookup/registration logic across C++, Python, Node.js, and Go backends, which adds unnecessary complexity.

If multiple input method profiles largely share the same implementation and data, the common module/engine can be moved to a shared package at the top level of the backend directory (next to cinbase, e.g., python/rimebase or similar), and each folder under input_methods/ can just contain its own ime.json and a thin wrapper.

Let me also think a bit more about whether we can further streamline how shared modules/profiles are structured.

(Review comment generated with assistance from Antigravity + Gemini 4 Argon)

@asdf80730

Copy link
Copy Markdown
Contributor Author

Recut on 08df868 to the layout you asked for — one ime.json per language profile, engine shared:

  • python/input_methods/rime/ime.json (zh-Hant-TW/zh-TW) and python/input_methods/rime-cn/ime.json (zh-CN/zh-CN); the go pair mirrors it under go-backend/input_methods/. Each manifest is one Windows input language with one profile GUID, so DllRegisterServer still issues two AddLanguageProfile calls and both locales keep the engine.
  • The engine moved once into python/rimebase (librime.py, rime_keyevent.py, rime_service.py, rime.dll, data/, icons/), beside cinbase; each IME folder keeps only ime.json plus a thin rime_ime.py that re-exports the one RimeTextService, so data/PIME.yaml and the icons exist once.
  • No additionalProfiles key anywhere: langProfileFromJson returns the single profile, and python/serviceManager.py, go-backend/server.go (case "rime", "rime-cn"), node/loadServices.js and PIMEImeModule.cpp compare the flat guid again; the shared ImeProfileGuids.h helper lost its array walk. The installer stages python\rimebase plus the two folders.

Local evidence for this head is in the body (python 8/12/9 tests OK on the bundled interpreter, go ./... ok, node fixture with two folders, the C++ helper test for both GUIDs).

(Comment generated with assistance from omp (tensorfold/Qwen3.8-Flash-Next))

@asdf80730

Copy link
Copy Markdown
Contributor Author

Head is 7782c4e (the two header lines for the added files were folded into the same commit; no behaviour change). Local gates on that head: PR scope PASS (33 files, 4 commits), commit claims PASS, AI declarations PASS (4 added files), ruff clean, and the layers named in the body.

@asdf80730

Copy link
Copy Markdown
Contributor Author

ci / build-and-sign is green on 0c1cb91 (8m2s, run 43496091328). Two things settled since the first push:

  • The one real failure was makensis at installer/installer.nsi line 374: File: "..\python\rimebase\brise\*.txt" -> no files found. The brise submodule is pinned at python/input_methods/rime/brise in .gitmodules while the shared engine folder is python/rimebase, so the five File lines written after the folder rename matched nothing. They now name the pinned submodule path; the SetOutPath destinations stay $INSTDIR\python\rimebase\data, which python/rimebase/rime_service.py:39-40 reads as shared_dir, and the two per-language folders stay input_methods/rime and input_methods/rime-cn. Sources checked against the initialized submodule: brise/*.txt 1, brise/*.yaml 2, brise/preset/*.yaml 16, brise/supplement/*.yaml 27, brise/extra/*.yaml 7.
  • continuous-integration/appveyor/pr fails in 37-49 s with 0 compilation errors and 0 tests on this and on every other open PR today (fix(cinbase): give each input method its own config instance #1014 55082825, fix(chewing): let the user-phrase editor finish deletes and report the truth (#393 #417 #456) #1022 55082826, fix(cinbase): confirm a lone candidate with space (#890) #1026 55082899, refactor(cinbase): give wildcard candidates one owner (#627) #1036 55082824), while the last successful AppVeyor job (54999596, 2026-10-30) ran 14m15s. Same abort, same window, five branches → [INFERENCE] the AppVeyor job dies in its init/install phase (rustup-init plus the pinned cmake 4.3.0 zip) before build.bat produces anything, not on these files; the per-step log is not exposed by the tokenless API (both /api/jobs/{id} forms answer 404).

Local Windows gate for this branch: bash tests/verify_windows.sh → 55 passed / 0 failed, Ran 406 tests ... OK (skipped=1), ruff, cargo fmt --check and clippy clean, and the python, node (both harnesses), go and rust suites green against the one tests/wire-fixtures.json.

@s793016

s793016 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

中州韻的註冊語系建議改成「安裝時選擇」
Proposal: let users choose Rime’s registered locale at install time

背景
Background

中州韻的語系問題由來已久。#481 在 2018 年就有人回報,當時的處理方式是自己改 registry,把 LanguageProfile\0x00000804 改成 0x00000404(見該 issue 中的 prime-0404.zip)。這個作法最早是從修改 CPatch 日文 IME 註冊語系的經驗沿用過來的。2019 年也有簡中使用者反過來,把其他 PIME 輸入法從 0x0404 改成 0x0804。可見兩邊的使用者都有需求,而且都是自己動手改 registry 解決。

The locale problem with Rime goes back a long way. It was reported in #481 back in 2018. The workaround then was to edit the registry by hand and change LanguageProfile\0x00000804 to 0x00000404 (see prime-0404.zip in that issue). The approach itself came from earlier experience changing the registered locale of the CPatch Japanese IME. In 2019, a Simplified Chinese user did the reverse and moved other PIME input methods from 0x0404 to 0x0804. Users on both sides need this, and all of them have been working around it by editing the registry themselves.

為什麼語系不只是「列在哪個語言清單」
Why the locale is more than “which language list it appears in”

Windows 會依目前的輸入語言決定不少行為。語系選錯,影響的是實際輸出的結果:

Windows decides a number of behaviors based on the current input language. Picking the wrong locale changes what actually gets output:

非 Unicode 程式:送出的字會依輸入語言的 code page 轉換。0x0404 用 CP950(Big5),0x0804 用 CP936(GBK)。語系不對,舊程式收到的字就可能變成問號或亂碼。

Non-Unicode applications: committed text is converted using the code page of the input language: CP950 (Big5) for 0x0404, CP936 (GBK) for 0x0804. With the wrong locale, legacy applications may receive question marks or garbled text.

主控台和舊式程式:切換輸入語言時會帶出對應的字元集(WM_INPUTLANGCHANGE)。

Console and legacy applications: switching the input language reports the matching character set (WM_INPUTLANGCHANGE).

Office 等會看輸入語言的程式:會依輸入語言自動切換字型、校對和拼字檢查的語言。#481 中簡中 Office 使用者遇到的就是這個問題。

Office and other applications that follow the input language: they switch fonts and the proofing and spell-check language automatically. This is exactly what the Simplified Chinese Office user in #481 ran into.

所以繁中使用者需要 zh-TW,簡中使用者需要 zh-CN。寫死任何一邊,都會讓另一邊的使用者在實際使用時出問題,而不只是清單裡找不到輸入法。

So Traditional Chinese users need zh-TW and Simplified Chinese users need zh-CN. Hard-coding either one causes real problems in daily use for the other group, not just a missing entry in the language list.

建議:在安裝程式裡選語系,維持一份 ime.json 對應一個語系

Proposal: choose the locale in the installer, keeping one ime.json per locale

這也是目前常見輸入法安裝程式的作法,例如小狼毫在安裝時就是讓使用者在繁體和簡體之間選一個。

This is also what common IME installers do today. Weasel (小狼毫), for example, asks the user to pick Traditional or Simplified Chinese at install time.

在安裝程式的 Rime 選項加一個「註冊語系:繁體中文 (zh-TW) / 簡體中文 (zh-CN)」。預設值跟著安裝程式的介面語言走,使用者可以自己改。

Add a “Registered locale: Traditional Chinese (zh-TW) / Simplified Chinese (zh-CN)” option to the installer’s Rime section. The default follows the installer’s UI language, and the user can change it.

套件裡附 ime.zh-TW.json 和 ime.zh-CN.json 兩份,安裝時依選擇複製成 ime.json。

Ship both ime.zh-TW.json and ime.zh-CN.json, and have the installer copy the chosen one to ime.json.

profile GUID 維持原本的 {9C2D6C68-9EA6-4CFB-A769-7E619DB7F267} 不變(Go 版為 {3F6B5A12-…}),兩種語系都用這一個 GUID。

Keep the existing profile GUID {9C2D6C68-9EA6-4CFB-A769-7E619DB7F267} unchanged ({3F6B5A12-…} for the Go backend), and use it for both locales.

這樣做的好處
Benefits

維持「一份 ime.json 一個語系」的設計,不改 manifest 格式,C++、Python、Node、Go 的派送邏輯都不用動。

It keeps the “one ime.json per locale” design. The manifest format does not change, and the dispatch logic in C++, Python, Node and Go stays as it is.

引擎不用搬家,也不用多開 rime-cn 資料夾。PIME 執行時跟現在完全一樣,只有安裝程式要改。

The engine does not move and no rime-cn folder is needed. PIME runs exactly as it does now; only the installer changes.

GUID 不變,原本在簡中使用中州韻的人升級時只要選 zh-CN,使用者設定和詞庫都不受影響。

Because the GUID does not change, existing Simplified Chinese Rime users only need to pick zh-CN when upgrading. Their settings and user dictionaries are not affected.

繁中、簡中使用者都不必再自己改 registry。

Neither Traditional nor Simplified Chinese users have to edit the registry by hand anymore.

後續可以再考慮的方向
Possible follow-up

這個開關之後可以擴大到所有 PIME 輸入法(#481 中 2026-10-30 的留言有提過)。讓使用者在安裝時統一選擇註冊語系,也能順便解決簡中使用者想在簡中環境用新酷音等輸入法的需求。

This option could later be extended to every PIME input method (suggested in the 2026-10-30 comment on #481). Letting users choose the registered locale for all input methods at install time would also cover Simplified Chinese users who want to use Chewing and other PIME input methods in a Simplified Chinese environment.

(Comment generated with assistance from Claude Code + Claude Opus 5.5)

中州韻輸入法 registers its TSF language profile from registration data:
langProfileFromJson (PIMETextService/DllEntry.cpp) reads locale and
fallbackLocale from the IME's ime.json, and libIME2
(ImeModule.cpp:registerLangProfiles) converts them with LocaleNameToLCID
— retrying the RFC 1766 name only when the RFC 4646 one fails to
convert — then calls AddLanguageProfile under LANGIDFROMLCID. The rime
profile shipped zh-Hans-CN / zh-CN, so the profile only appeared for
users who had Simplified Chinese enabled, while every other PIME input
method declares zh-Hant-TW / zh-TW.

Both buckets are kept rather than traded: each rime manifest now declares
the Traditional pair as its primary profile and one additionalProfiles
entry for the Simplified pair, each with its own profile GUID, so
DllRegisterServer issues two AddLanguageProfile calls for the one CLSID
and a user finds 中州韻輸入法 under either Windows input locale.
langProfileFromJson returns the profiles it read (std::vector) and parses
that array; the flat keys stay the first profile, so every other ime.json
registers exactly as before, and an entry without guid or locale is
skipped the way the flat keys already fall back. The python and go twins
carry the same three keys because DllRegisterServer scans every backend's
input_methods/*/ime.json, and one disagreeing twin would leave that
registration in a single bucket.

installer/installer.nsi needs no change: its PYTHON_CHS_SECTION_GROUP
entry is the installer's own section grouping, independent of the TSF
language profile, and both profiles come from these manifests.

Architecture and design by asdf80730. Implementation generated with AI
assistance from omp (tensorfold/Qwen3.8-Flash-Next).
The two ime.json manifests carry an additionalProfiles entry (the zh-CN twin
of the zh-Hant-TW profile), so the dispatchers and the config loader have to
know those GUIDs as well as the flat one:

- python/serviceManager.py: TextServiceInfo gains additionalGuids, filled from
  additionalProfiles (each entry's guid, lowercased; an entry without a usable
  guid is skipped, as the flat keys already fall back), and
  TextServiceManager.load() registers the same info under each of them, so
  createService() answers for the second profile too.
- go-backend/server.go: additionalProfileGuids(imeConfig) reads the array and
  both the meow and the rime case register the factory for the primary and
  every profile GUID, so newClient finds one for {9882e350-…}.
- PIMETextService/PIMEImeModule.cpp: ImeModule::loadImeInfo matches the flat
  guid, then walks additionalProfiles, so onConfigure finds the ime.json from
  either profile GUID.
- node/loadServices.js: loadServiceById compares the primary guid or any
  additionalProfiles[].guid.

Verified with the project's local harness on the integration branch, where the
regression cases for these four seams live: the Python service-manager module
(10 tests, including both keys mapping to one TextServiceInfo and
createService() on the additional GUID), the Go packages under
`go test -count=1 ./...` (two cases reading the shipped manifest and the
skip-over-bad-entries behaviour), and the node loadServices test with
additionalProfiles in the fixture. PIMEImeModule.cpp is compiled by the
build-and-sign job.

Architecture and design by asdf80730. Implementation generated with AI
assistance from omp (tensorfold/Qwen3.8-Flash-Next).
`ImeModule::loadImeInfo` compared the flat `guid` and then walked
`additionalProfiles` inline, so this one of the four dispatchers had no way to
be exercised outside the `build-and-sign` job: the vendored mingw carries no
Windows SDK headers. Extracting the match into `PIMETextService/ImeProfileGuids.h`,
which includes only `<string>` and the header-only nlohmann json, keeps the
behaviour and lets the two pure-C++ helper tests upstream already runs gain a
third sibling case.

- `imeProfileGuidEqual`: ASCII case-insensitive, the same comparison `stricmp`
  gave, so a lowercased client id still meets an upper-case manifest.
- `imeProfileGuidMatches`: the flat `guid` first, then each `additionalProfiles`
  entry; a non-object entry, a missing or non-string `guid`, and an empty
  `guid` are skipped without throwing.
- `loadImeInfo` calls it: the 17 inline lines become one call (22 lines
  changed, 15 fewer), and the first-match `break` of the backend scan is
  unchanged, so `onConfigure` resolves `ime.json` from either profile GUID.

Architecture and design by asdf80730. Implementation generated with AI assistance from omp (tensorfold/Qwen3.8-Flash-Next).
One manifest is one Windows input language profile, so each dispatcher again
compares the flat guid only: langProfileFromJson returns the single profile,
the python and node dispatchers and the go loader match it directly, and the
header-only helper loses the array walk. The rime engine serves zh-Hant-TW and
zh-CN, so both backends now ship input_methods/rime and input_methods/rime-cn,
each with its own profile GUID, while the shared engine (librime.py,
rime_keyevent.py, rime_service.py, rime.dll, data/, icons/) sits once under
python/rimebase and the two wrappers re-export one RimeTextService. The
installer stages the engine folder plus the two IME folders.

Architecture and design by asdf80730. Implementation generated with AI assistance from omp (tensorfold/Qwen3.8-Flash-Next).
The two fixture cases of the loader suite remove their temporary tree right
after killing server.js, and on Windows the still-running child holds that
directory as its cwd, so rmSync answers EBUSY. Both finally blocks now await
the exit promise the starter already exposes before removing the tree.

Architecture and design by asdf80730. Implementation generated with AI assistance from omp (Qwen3.8-Flash-Next).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

怎樣可以把中州韻設為台灣

3 participants