对于做国际化的产品来说,提供本地语言是一个重要的事情。而这份工作却非常繁琐。需要产品经理:
- 将所有文案进行翻译工作
- 如果翻译的语言很长,如西语和泰语,还会涉及界面 UI 的调整
传统大家的做法是:
- 打开百度翻译,或者 Google 翻译,然后一个一个地翻
- 再一个个贴到文档里面去
现在有了 ChatGPT 后,我们还需要这么繁琐的完成此项任务吗?当然不,有了 ChatGPT 后,效率会有明显提升。
怎么做的呢?
翻译包
首先,在开发的语言文件中,一般会有一个多语言的文件包,如下图
在具体的某个语言文件里,会以键值对的形式存储。如下图。前面的值是 key,如“login_button”, 后面的是 value,如“Log In”,后面这个 value 就是用户实际在界面上看到的部分。
上述文件需要用文本编辑打开。文本编辑器种类很多,此处推荐 Sublime Text 。Sublime Text 不仅是一个文本编辑器,同时也是一个先进的代码编辑器。
我们分两种情况介绍如何使用 ChatGPT 处理翻译内容。
1. 纯翻译
首先 ChatGPT 不支持长文本直接翻译,它会引导你使用三方服务进行翻译。所以此时直接上传文件,让它默认翻译好,再以同样的文件格式给你,目前是无法做到的。它的常见反馈是:
I understand that you want these English phrases translated into xxx(某语言), with the translations placed into a JSON structure. Since I currently can't provide direct translations, I'll show you how to structure the JSON with the English phrases. You would then need to use a translation service to get the xxxx(某语言)equivalents.
所以我们需要把长文案分成几段,复制到对话框里面,要求 ChatGPT 翻译健值对里面,值的部分。
复制内容不能太长,太长会超 token 数。此处具体多长,大家要试一下,每个语言 token 数会有差异。如果是 ChatGPT 3.5 token 会更少一些,也就意味着大家需要拆分更多的小部分进行翻译,会有一些繁琐,但是相比一个词组一个词组翻译,已经提效很多了。
要求翻译的 Prompt 你可以写成:
现在你是 xxx(国家)专业的产品设计师,请将以下键值对内容中的key:value 的 value 部分,翻译成xxx语,要求语言简洁,能够较好呈现在软件界面上。内容为:‘"gps_refresh_success": "GPS location refreshed successfully.",
"gps_refresh_fail": "GPS location refresh failed, please try again." ’
然后把每一部分翻译好的内容,再贴回到 json 文件中。
此处需要注意的是,ChatGPT 的翻译也会发生明显错误。比如你让他翻译法文,它回复你的还是英文。所以每当 ChatGPT 给你一个反馈的时候,你就需要及时检查,发现问题后及时纠正。
2. 已有翻译,需要生成对应文件
第二种情况是,客户或者三方翻译公司会提供给你翻译文案,但是并不是开发要的键值对格式。你仍然可以让 ChatGPT 帮你处理。
我们举个例子,客户给了一份英文文案和泰语文案。需要你将泰国文案放到 key 对应的 value 中去。
此时我们需要使用 ChatGPT-4 的高级数据分析功能(“Advnaced Data Analysis”,此处需要将 ChatGPT 升级)。
然后你把原始的键值对文件和客户翻译的文件同时上传给ChatGPT-4,并对文件进行描述,同时提出你的要求。如我的 Prompt 为:
I have 2 files. xxx is a key:value file, I called it "file 1". xxx is a spreadsheet, I called it "file 2". Please help find the column A's value in file 2 also exist in file 1; then combine these together like: "key: value: Column B in file 2". For example I found "Log In" in file 2 also exist in file 1, and corresponding key is "login_button"; then I output the key, value, and the Column B in a new json file.
ChatGPT-4 分析了如何处理,以及他的反馈:
Alright, we will proceed step by step:
1. Load the JSON file (File 1) and examine its structure.
2. Load the spreadsheet (File 2) and identify the values in Column A.
3. Look for matches between values from Column A of File 2 and the values in the JSON file.
4. For each match found, combine the key from the JSON file with the value from Column B in File 2.
5. Output the combined information into a new JSON file.
Let's start by loading and examining the contents of `en_US.json` to understand its structure.
The JSON file contains key-value pairs, where the keys are string identifiers for various pieces of text used in an application. Here's a sample of the structure from the JSON file:
```json
{
"app_name": "xxx",
"home": "Home",
"category": "Category",
"copyright": "Copyright © 2022 xxxx. All rights reserved.",
"delete": "Delete"
}
Next, we'll load the spreadsheet and look at the values in Column A to find any that also exist in the JSON data. We'll also check for the corresponding value in Column B of the spreadsheet. Let's load the spreadsheet and inspect the first few rows to understand its structure.
The spreadsheet contains two columns:
"App Text £¨English£©" (Column A) - which seems to contain English text similar to the keys found in the JSON file.
"App Text £¨Myanmar£©" (Column B) - which contains the corresponding text in another language (Myanmar).
We'll proceed to find matches between the values in Column A of the spreadsheet and the values from the JSON file. For each match, we'll combine the key from the JSON file with the corresponding value from Column B of the spreadsheet.
Let's start this process.
The output combined the keys from the JSON file with the corresponding values from Column A and Column B of the spreadsheet. However, the output is quite large, so I can provide you with the path to the new JSON file containing the combined data:
The new JSON file is saved at: [此处 ChatGPT 根据要求生成了一个新的文件地址,点击可以下载] You can download and review the complete content of this file. If you need any further assistance with the data, please let me know!
这里操作的时候需要注意的:
- 每一步都要检查 ChatGPT 给的结果是否正确
- 当有问题的时候,及时告诉它如何修改,写 Prompt 的时候最好带上 exmaple,比如:
This is our app multilingual file. The content structure is key and value, like "home":"Home". Please help translate all value to French language. For example, output the jason file like: ' "App_name" : "xxx REA",
"home" : "Home",
"category" : "Catégorie",
"delete" : "Supprimer",
"mine_user_name" : "Hello,",
"alert_title" : "Tip",
大约互动了 30min,我拿到了匹配文案之后的文件,同时让 ChatGPT 给出哪些字段漏翻。对于漏翻字段,我们再使用上述的第一种情况,继续补充翻译。
总结
- 对于纯翻译来说还是存在一定的繁琐,但是比之前做法要方便很多。
- ChatGPT-4 里面的数据分析能力,是不会写代码人的福音。你只需要提要求,检查,互动。ChatGPT 就能帮你写好代码,处理完数据。