Häufige ProblemeJSON-Dekodierung der Antwort des KI-Dienstes fehlgeschlagen
JSON-Dekodierung der Antwort des KI-Dienstes fehlgeschlagen
Gato AI Translations for Polylang sendet einen Prompt an den KI-Dienst, und die Antwort ist im JSON-Format.
Je nach den gesendeten Daten (zu übersetzende Strings und Sprache) kann der KI-Dienst eine Antwort erzeugen, die kein gültiges JSON ist. Die Logs zeigen dann eine Fehlermeldung wie diese:
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 responseImmer wenn wir ein neues Problem entdecken, passen wir den Prompt an, um zu verhindern, dass es erneut auftritt.
Derzeit enthält der Prompt Folgendes:
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.Wenn du einen Fehler erhältst, handelt es sich um ein neues Problem, das wir identifizieren und beheben müssen.
Gehe folgendermaßen vor:
- Versuche zu verstehen, worum es sich bei dem Problem handelt
- Passe den Prompt an, um das Problem zu beheben
Sobald es funktioniert, schick uns deinen Prompt und wir werden diese Lösung direkt in das Plugin integrieren.