Currently, we're using angular to build our front panels and, as a translation component, we're using ngx-translate and we load our translation keys on a json file for each language:
- en.json: English translations
- es.json: Spanish translations
- it.json: Italian translations
In order to generate translations using ChatGpt, we use now two different strategies. One for short labels and another for larger translations.
Handling short labels
Let's imagine we want to get a translation for each language (English, Spanish and Italian) for the following keys:
msg.rejectRequest
msg.approveRequest
msg.requestRejected
msg.requestApproved
In this case, as translations can be easily inferred from labels, we can directly send the following prompt to ChatGpt:
The following labels represents a translation label:
- alert.rejectRequest
- alert.approveRequest
- alert.requestRejected
- alert.requestApproved
Your task is to generate a json output for en, es and it languages following this rules:
- keys will be the labels
- Values will be an human readable translation for the label
After sending it to ChatGpt, we will get the following output:
Now, we're able to copy each output and paste it in the corresponding translation file.
It's important to review translations so that they match what we want user to understand.
Handling larger labels
In this case, we have to build our prompt from the translation in any specific language. Let's see the following example:
From the following texts written in Spanish language:
- "Sistema de informes personalizados"
- "Visualizacion cuantica de eventos externos"
Your task is to translate them to the following languages: fr, it, en and pt and generate a json output for each language following the next rules:
- Keys will always be english strings with no more than 30 chars prefixed with the word "info" followed by an identifying text to the English translation
- Values will be the translations
As we can see, this prompt is a bit harder. Let's see it step by step:
- First, we show ChatGpt the texts we want to translate and what languages we want them to be translated to and what kind of output we want to get (json).
- Then, we specify some rules:
- We want keys for each json to be always in english, being no larger than 30 chars and start by "info." prefix.
- We want values to be the target translations.
After sending the prompt, we get the next output:
As in the labels example, we should review the generated translations to ensure they are right.
Generating other output types
We can get other output types with a very short modification of the last prompt: Let's see what happens if we change generate a json output by generate a yaml output:
As we can see, we get the same result with a different output.