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

1

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.

2

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 contents remain unchanged after translation and that their positions within the translated text are appropriate.

3

Multi-level Nested Processing

The current process recursively handles translatable string values in JSON objects and arrays, then serializes the output again. Indentation and whitespace may differ from the original file. Check the structure, placeholders and differences before use.

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.