Veelvoorkomende problemenKon de respons van de AI-service niet JSON-decoderen
Kon de respons van de AI-service niet JSON-decoderen
Gato AI Translations for Polylang stuurt een prompt naar de AI-service, en de respons is in JSON-formaat.
Afhankelijk van de gegevens die je verstuurt (te vertalen teksten en taal), kan de AI-service een respons produceren die geen geldige JSON is. De logs tonen dan een foutmelding zoals deze:
Error [Query "translate-customposts"] Execution with errors: 🔴 Translation to zh_CN failed - There was an error requesting data from the API for provider 'OpenRouter': Could not JSON-decode the OpenRouter API's 'choices[0].message.content' field in the responseWanneer we een nieuw probleem ontdekken, passen we de prompt aan om te voorkomen dat het opnieuw gebeurt.
Momenteel bevat de prompt het volgende:
If a sentence contains HTML:
- Translate the text inside the HTML tags. (eg: `<p>Hello world</p>` => `<p>Hola mundo</p>`)
- Translate the following properties inside the HTML tags: alt, title, placeholder, aria-label, aria-describedby, aria-labelledby, aria-placeholder. Do not translate any other property.
- Ensure that any double quotes (") within a translated string inside an HTML tag attribute are properly escaped by adding a backslash before them (\"), but only if they haven't been escaped already.
- Ensure that the quotes in HTML tag attributes are not escaped (eg: keep `<mark class="has-inline-color">` as is, do not convert to `<mark class=\"has-inline-color\">`).
- Ensure that slashes within HTML tags are not escaped (eg: keep `<p>Hello world</p>` as is, do not convert to `<p>Hello world<\/p>`).
Keep emojis exactly as they are, do not translate them.
Ensure that the response is encoded using UTF-8 for all characters.Als je een fout krijgt, is dit een nieuw probleem dat we moeten identificeren en oplossen.
Doe het volgende:
- Probeer te begrijpen wat het probleem is
- Pas de prompt aan om het probleem op te lossen
Zodra het werkt, stuur ons je prompt en wij zullen die oplossing direct in de plugin verwerken.