Skip to content

Commit 1731dd7

Browse files
fix: improve translation script prompt and fix some incorrectly used terms in spanish and dutch (#12548)
The translations would sometimes be using the wrong meanings in other languages, for example Locale becoming "location" or "region" depending on the phrase or translation. Some words were also not being used consistently across the UI which could cause some confusion if they're interchanged. I've fixed these instances for locale specifically in dutch and spanish. I've also updated the prompt with more context around what's being translated and some examples, over time we should add to the examples so that translations are better guarded against changing meanings. --------- Co-authored-by: Germán Jabloñski <[email protected]>
1 parent bd2571c commit 1731dd7

File tree

3 files changed

+63
-23
lines changed

3 files changed

+63
-23
lines changed

packages/translations/src/languages/es.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ export const esTranslations: DefaultTranslationsObject = {
9494
invalidFileTypeValue: 'Tipo de archivo inválido: {{value}}',
9595
invalidRequestArgs: 'Argumentos no válidos en la solicitud: {{args}}',
9696
loadingDocument: 'Ocurrió un problema al cargar el documento con la ID {{id}}.',
97-
localesNotSaved_one: 'No se pudo guardar la siguiente configuración regional:',
98-
localesNotSaved_other: 'No se pudieron guardar las siguientes configuraciones regionales:',
97+
localesNotSaved_one: 'No se pudo guardar el siguiente idioma:',
98+
localesNotSaved_other: 'No se pudieron guardar los siguientes idiomas:',
9999
logoutFailed: 'El cierre de sesión falló.',
100100
missingEmail: 'Falta el correo.',
101101
missingIDOfDocument: 'Falta la ID del documento a actualizar.',
@@ -215,7 +215,7 @@ export const esTranslations: DefaultTranslationsObject = {
215215
adminTheme: 'Tema del admin',
216216
all: 'Todo',
217217
allCollections: 'Todas las colecciones',
218-
allLocales: 'Todas las ubicaciones',
218+
allLocales: 'Todos los idiomas',
219219
and: 'Y',
220220
anotherUser: 'Otro usuario',
221221
anotherUserTakenOver: 'Otro usuario ha tomado el control de la edición de este documento.',
@@ -287,7 +287,7 @@ export const esTranslations: DefaultTranslationsObject = {
287287
error: 'Error',
288288
errors: 'Errores',
289289
export: 'Exportación',
290-
fallbackToDefaultLocale: 'Volver a la configuración regional por defecto',
290+
fallbackToDefaultLocale: 'Volver al idioma configurado por defecto',
291291
false: 'Falso',
292292
filter: 'Filtro',
293293
filters: 'Filtros',
@@ -305,8 +305,8 @@ export const esTranslations: DefaultTranslationsObject = {
305305
light: 'Claro',
306306
livePreview: 'Previsualizar',
307307
loading: 'Cargando',
308-
locale: 'Regional',
309-
locales: 'Locales',
308+
locale: 'Idioma',
309+
locales: 'Idiomas',
310310
menu: 'Menú',
311311
moreOptions: 'Más opciones',
312312
move: 'Mover',
@@ -404,13 +404,13 @@ export const esTranslations: DefaultTranslationsObject = {
404404
yes: 'Sí',
405405
},
406406
localization: {
407-
cannotCopySameLocale: 'No se puede copiar al mismo lugar',
407+
cannotCopySameLocale: 'No se puede copiar al mismo idioma',
408408
copyFrom: 'Copiar de',
409409
copyFromTo: 'Copiando de {{from}} a {{to}}',
410410
copyTo: 'Copia a',
411-
copyToLocale: 'Copiar a localización',
412-
localeToPublish: 'Locación para publicar',
413-
selectLocaleToCopy: 'Seleccione la ubicación para copiar',
411+
copyToLocale: 'Copiar a idioma',
412+
localeToPublish: 'Idioma para publicar',
413+
selectLocaleToCopy: 'Selecciona el idioma a copiar',
414414
},
415415
operators: {
416416
contains: 'contiene',
@@ -522,7 +522,7 @@ export const esTranslations: DefaultTranslationsObject = {
522522
previouslyPublished: 'Publicado Anteriormente',
523523
problemRestoringVersion: 'Ocurrió un problema al restaurar esta versión',
524524
publish: 'Publicar',
525-
publishAllLocales: 'Publicar todas las configuraciones regionales',
525+
publishAllLocales: 'Publicar en todos los idiomas',
526526
publishChanges: 'Publicar cambios',
527527
published: 'Publicado',
528528
publishIn: 'Publicar en {{locale}}',

packages/translations/src/languages/nl.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ export const nlTranslations: DefaultTranslationsObject = {
214214
adminTheme: 'Adminthema',
215215
all: 'Alle',
216216
allCollections: 'Alle collecties',
217-
allLocales: 'Alle locaties',
217+
allLocales: 'Alle talen',
218218
and: 'En',
219219
anotherUser: 'Een andere gebruiker',
220220
anotherUserTakenOver: 'Een andere gebruiker heeft de bewerking van dit document overgenomen.',
@@ -305,7 +305,7 @@ export const nlTranslations: DefaultTranslationsObject = {
305305
livePreview: 'Voorbeeld',
306306
loading: 'Laden',
307307
locale: 'Taal',
308-
locales: 'Landinstellingen',
308+
locales: 'Talen',
309309
menu: 'Menu',
310310
moreOptions: 'Meer opties',
311311
move: 'Verplaatsen',
@@ -403,13 +403,13 @@ export const nlTranslations: DefaultTranslationsObject = {
403403
yes: 'Ja',
404404
},
405405
localization: {
406-
cannotCopySameLocale: 'Kan niet naar dezelfde locatie kopiëren',
406+
cannotCopySameLocale: 'Kan niet naar dezelfde taal kopiëren',
407407
copyFrom: 'Kopiëren van',
408408
copyFromTo: 'Kopiëren van {{from}} naar {{to}}',
409409
copyTo: 'Kopiëren naar',
410-
copyToLocale: 'Kopieer naar locatie',
411-
localeToPublish: 'Te publiceren locatie',
412-
selectLocaleToCopy: 'Selecteer locatie om te kopiëren',
410+
copyToLocale: 'Kopieer naar taal',
411+
localeToPublish: 'Te publiceren taal',
412+
selectLocaleToCopy: 'Selecteer taal om te kopiëren',
413413
},
414414
operators: {
415415
contains: 'bevat',
@@ -536,10 +536,10 @@ export const nlTranslations: DefaultTranslationsObject = {
536536
saveDraft: 'Bewaar concept',
537537
scheduledSuccessfully: 'Succesvol gepland.',
538538
schedulePublish: 'Publicatie plannen',
539-
selectLocales: 'Selecteer locales om weer te geven',
539+
selectLocales: 'Selecteer talen om weer te geven',
540540
selectVersionToCompare: 'Selecteer een versie om te vergelijken',
541541
showingVersionsFor: 'Versies tonen voor:',
542-
showLocales: 'Toon locales:',
542+
showLocales: 'Toon talen:',
543543
status: 'Status',
544544
unpublish: 'Publicatie ongedaan maken',
545545
unpublishing: 'Publicatie ongedaan maken...',

tools/scripts/src/generateTranslations/utils/translateText.ts

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,55 @@ const dirname = path.dirname(filename)
66

77
dotenv.config({ path: path.resolve(dirname, '../../../../', '.env') })
88

9+
type TranslationMessage = {
10+
role: 'system' | 'user'
11+
content: string
12+
}
13+
914
export async function translateText(text: string, targetLang: string) {
15+
const systemMessage: TranslationMessage = {
16+
role: 'system',
17+
content: `Only respond with the translation of the text you receive. The original language is English and the translation language is ${targetLang}. Use formal and professional language. Only respond with the translation - do not say anything else.
18+
19+
Respect the meaning of the original text within the context of Payload. Here is a list of common Payload terms that carry very specific meanings:
20+
- Collection: A collection is a group of documents that share a common structure and purpose. Collections are used to organize and manage content in Payload.
21+
- Field: A field is a specific piece of data within a document in a collection. Fields define the structure and type of data that can be stored in a document.
22+
- Document: A document is an individual record within a collection. It contains data structured according to the fields defined in the collection.
23+
- Global: A global is a special type of collection that can only have 1 item and there cannot be multiple globals of the same type.
24+
- Locale: A locale is a specific language or regional setting that can be used to display content in different languages or formats.
25+
- Tenant: A tenant is a sub group in Payload, allowing a single instance of Payload to isolate users, data and content based on specific permissions.
26+
- SEO: SEO stands for Search Engine Optimization, which is the practice of optimizing content to improve its visibility and ranking in search engine results.
27+
- Payload: Payload is the name of the headless CMS platform that this text is related to.
28+
- Import and export: are terms used to describe the process of transferring data into or out of Payload, typically in a structured format like JSON or CSV.
29+
30+
If a term is capitalized treat it as a proper noun and do not translate it. If a term is not capitalized, translate it normally. For example, do not translate the word "Payload" or "Field" but you can translate "payload" or "field".
31+
32+
Examples of translations:
33+
<examples>
34+
<nl>
35+
- Locale: Taal - never locatie
36+
- Collection: Collectie
37+
<nl>
38+
39+
<es>
40+
- Locale: Idioma - never region or ubicación
41+
- Collection: Colección
42+
<es>
43+
<examples>
44+
45+
Apply these translations consistently so that the meaning is preserved across different languages. If you are unsure about a translation, use the examples as a guide. If there is not equivalant term in the target language, use the closes term to it. Use the same term consistently throughout the translation.
46+
47+
Use formal and professional language, avoiding colloquialisms or informal expressions. The translation should be clear, concise, and suitable for a professional context.
48+
49+
If you cannot translate the text, respond with "[SKIPPED]". Do not translate text inside double curly braces, i.e. "{{do_not_translate}}".
50+
`,
51+
}
52+
1053
const response = await fetch('https://api.openai.com/v1/chat/completions', {
1154
body: JSON.stringify({
1255
max_tokens: 150,
1356
messages: [
14-
{
15-
content: `Only respond with the translation of the text you receive. The original language is English and the translation language is ${targetLang}. Use formal and professional language. Only respond with the translation - do not say anything else. If you cannot translate the text, respond with "[SKIPPED]". Do not translate text inside double curly braces, i.e. "{{do_not_translate}}".`,
16-
role: 'system',
17-
},
57+
systemMessage,
1858
{
1959
content: text,
2060
role: 'user',

0 commit comments

Comments
 (0)