자주 발생하는 문제AI 서비스의 응답을 JSON으로 디코딩할 수 없습니다
AI 서비스의 응답을 JSON으로 디코딩할 수 없습니다
Gato AI Translations for Polylang은 AI 서비스에 프롬프트를 전송하며, 응답은 JSON 형식으로 반환됩니다.
전송하는 데이터(번역할 문자열과 언어)에 따라 AI 서비스가 유효한 JSON이 아닌 응답을 반환할 수 있습니다. 이 경우 로그에는 다음과 같은 오류 메시지가 표시됩니다:
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 response새로운 문제를 발견할 때마다 재발을 방지하기 위해 프롬프트를 조정하고 있습니다.
현재 프롬프트에는 다음 내용이 포함되어 있습니다:
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.오류가 발생한 경우, 아직 확인 및 수정이 필요한 새로운 문제가 발생한 것입니다.
다음 단계를 진행해 주세요:
- 문제의 원인을 파악합니다
- 프롬프트를 커스터마이즈하여 문제에 대처합니다
정상적으로 작동하게 되면 사용하신 프롬프트를 보내 주세요. 해당 해결책을 플러그인 내에 하드코딩하겠습니다.