fix(translation): only read own dictionary entries
fix(translation): only read own dictionary entries
Confirmed defect
Translation lookup reads inherited Object.prototype properties as dictionary entries. Missing text such as constructor, toString, or __proto__ returns a function/object instead of the original text, and the sampled debug logging can throw. In full mode, a valid JSON translation named hasOwnProperty shadows the method and makes substring matching throw.
Change
- Check own properties for exact and trimmed lookups.
- Use Object.prototype.hasOwnProperty.call for full-mode enumeration, so translation text cannot shadow the method.
- Preserve explicitly declared special-name keys, empty-string translations, ordinary lookups, and the existing substring strategy.
Only the translation function and a new offline test file change. No dependencies, lockfiles, workflows, installer, credentials, or permissions change. Existing #5, #6, and #7 remain independent and untouched.
Validation
Base: 83ceac969392e7ea1948652d0b2dd6d06233ddeb.
Head: dae56749947263101955bddeb46640c208eda406.
Published tree: fe862b2d43ab39e29ecb7a9f4bd84bfb45008825, identical to the locally tested tree.
- All 15 baseline files verified against their Git blob IDs; at validation time the baseline tree matched remote main at
83ceac9. Main has moved since, so this is historical. - Unchanged baseline: 68 Jest tests passed.
- New regression/control suite on unchanged source: 18 failed, 7 passed. Fixed source: all 25 passed.
- Final locked npm ci --ignore-scripts and full Jest suite: 93 tests passed on Node 24.22.1 / npm 11.9.0.
- Python installer suite: 27 tests passed on Python 3.12.14 / pytest 9.0.2.
- JavaScript syntax, Python compileall, pip check, and git diff --cached --check passed. No separate build or lint command is declared.
- Independent read-only review found no blocker and independently reran all 93 Jest tests.
Hosted CI for the published head passed, as recorded below. Existing development-dependency warnings remain unchanged; #6 tracks the independent dependency refresh. Tests use synthetic JSON/XHR and mocked RPG Maker globals, not a real game or browser acceptance test. This is dictionary lookup correctness, not a general schema validation or security audit. No live game files, user computer, merge, deployment, or release was used.
Hosted verification
CI run 42345844514 completed successfully for head dae56749947263101955bddeb46640c208eda406. Node 18.20.8 and 20.20.2 each passed all 93 tests; Python 3.11.18 / pytest 9.2.0 passed all 27 installer tests.
All three checkout logs confirm merge ref 687f54a9663e58a934f8f721d4f187f351c1200b. Its parents are the unchanged base and published head, and its tree equals the locally tested/published tree fe862b2d43ab39e29ecb7a9f4bd84bfb45008825. This is verified merge-ref CI, not a bare-head checkout. Both changed remote files were read back and matched the tested files byte-for-byte.
CommitCheck passed. CodeRabbit skipped the Draft, which is not a review pass; no inline review threads were present. The unchanged npm lockfile still reports 11 development-dependency findings (7 low, 1 moderate, 3 high) in hosted installation output; the independent dependency refresh remains in #6. Existing action-runtime deprecation/cache warnings did not fail the jobs. The PR remains Draft, with no merge or deployment.
Independent box rerun
Box rerun at dae5674 (Linux, Node v24.22.1): npm ci, npx jest 93 passed, pytest -q tests 27 passed.
Summary by Sourcery
Make translation lookup treat only dictionary-owned entries as translations.
Bug Fixes:
- Prevent inherited object properties from being returned as translations, including for exact, trimmed, and substring lookups.
Enhancements:
- Keep explicitly defined special-name and empty-string translations usable, including dictionaries for special language names.
Tests:
- Add offline regression tests for inherited property names, special-name translations, and substring matching.
Summary by CodeRabbit
- Bug Fixes
- Translation lookups now recognize only entries explicitly defined in the dictionary, preventing inherited properties from appearing as translations.
- This applies to exact and trimmed-text matches, as well as substring extraction in full mode. Missing translations retain their original whitespace, while explicitly defined translations for names such as
constructorcontinue to work.