How to translate JSON language pack files without compromising keys and program logic?

Core Issue Diagnosis

During app or website internationalization, erroneous JSON translation—such as translating keys or corrupting brackets—can result in program crashes.

Root Cause Analysis

Key-value separation algorithm

DL.Translator leverages AST (Abstract Syntax Tree) parsing technology at the preprocessing stage to lock JSON keys as non-editable regions, sending only values to the AI engine, thereby fundamentally eliminating the risk of accidental key translation.

Placeholder and Variable Protection

For common variables within values (such as `{username}`, `%s`, `{{count}}`), we use regular expression tagging techniques to convert them into special tokens recognizable to AI models, ensuring that variable positions remain correct and unaltered after translation.

Multi-level Nested Processing

Regardless of the depth of JSON structure nesting (nested objects), recursive algorithms can precisely locate the underlying string nodes and accurately restore indentation formatting after translation, enabling developers to directly diff and compare changes.

Final Solution Summary

With intelligent structural protection, developers do not need to manually extract text and can directly deploy translated JSON files to the production environment.