AI 辅助 i18n:我是怎么把 3 小时翻译压缩到 30 分钟的
接手老项目第一天,打开代码仓库,语言文件里躺着三千多条键值对,重复两百多条,还有一百多条压根找不到引用。下午产品经理又丢来二十个新文案,要求当晚全部翻成中英日韩四种语言。 以前碰上这种事,基本就是打开在线翻译网页,复制粘贴,手动调格式,一干就是三四个小时。现在不一样了,AI 助手两分钟生成全部文件,我再花十分钟检查修正。 这篇文章把我这几周折腾出来的方法、踩过的坑和总结的经验完整写出来,希望能帮你少走弯路。 我负责一个面向海外市场的 SaaS 产品,前端用 React,国际化方案是传统的 i18next 加 JSON 文件。每个语言一个文件,结构是嵌套对象。项目跑了一年多,语言文件从最初的一千条涨到了三千多条。 维护成本越来越高,人工翻译跟不上迭代速度,漏翻错翻是家常便饭。我试用过几款商业翻译管理平台,功能确实强大,但价格不菲,而且需要把整个工作流迁移过去,团队学习成本太高。…
AI-assisted i18n: Transforming a 3-hour translation process to just 30 minutes
Upon taking over an old project, I encountered a repository with 3,000+ key-value pairs in language files, containing 200+ repetitive entries and 100+ that had no references. To handle this, I created a script to generate a structure summary of the JSON file, which was then shared with an AI model. The AI would first paraphrase the structure before generating new content based on a given sample.
The main challenge was ensuring the AI understood the data structure, as it could otherwise output truncated or misinterpreted content. To address this, I wrote a Node.js script that read new text cases in a TXT file and used the AI's API to translate each case into English, Japanese, and Korean. The context of each text case was crucial for accurate translation, so I included the extraction location for better understanding.
After the initial run, I encountered inconsistencies in Japanese and English translations. To improve consistency, I created a terminology table from high-frequency words and their corresponding translations in existing language files. This table was passed to the AI model as a part of the prompt, resulting in more consistent translations.
The project had duplicate keys with similar and identical values. I developed scripts to identify these cases and present them to the AI model for judgment on which keys to retain or merge. The AI provided reasonable suggestions, but I reviewed and approved the final decisions.
Unreferenced keys were identified by scanning the frontend code and comparing it with the language files. This list was sent to the AI model for verification, with a confidence score determining whether the key should be deleted or marked for confirmation.
The process was automated using GitHub Actions, which triggered a script to extract new text cases and generate translations using the AI model. PRs were created for review by developers, eliminating manual copy-pasting. The AI-generated content needed human review, particularly for brand-related or culturally sensitive content, which was marked as such in PR descriptions.
I tested the process thoroughly, ensuring JSON formatting correctness and preventing key name changes in AI translations. The AI's output was diffed with previous files to identify unchanged entries and catch potential oversights. Additionally, I suggested having a mother-tongue speaker review Japanese and Korean translations to catch subtle errors.
Overall, the AI-assisted i18n process reduced translation time from 3 hours to just 30 minutes, resulting in a 60% improvement in overall efficiency. While AI can handle the basics, human oversight remains crucial for maintaining brand image and user experience. For those interested in trying this method, starting with a small module and gradually expanding is recommended.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.