johannschopplich / kirby-content-translator

🌐 Moved to: https://kirby.tools/content-translator
https://kirby.tools/content-translator
MIT License
34 stars 2 forks source link

Error on translate #12

Closed lrntmszrs closed 6 months ago

lrntmszrs commented 6 months ago

Hi, I encounter an error when I click on the translate button. I've try on a plain kit clean install, with two languages and a simple textarea field… Sync works, but when I click translate I get an error message.

In the console tab, of the browser, a message appears when I click

index.js?1714369334:1

TypeError: Cannot read properties of undefined (reading 'text')
    at index.js?1714369334:1:2393
    at async Promise.all (:8888/deepl/panel/pages/index 0)
    at async I (index.js?1714369334:1:2982)
    at async recursiveTranslateContent (index.js?1714369334:1:2850)
    at async Object.H (index.js?1714369334:1:5466)

The message error is not very helpful, so I'm quite stuck…

image

Any Idea ? Thanks

Lrt

-- Kirby 4.2.0 Php 8.1.13

johannschopplich commented 6 months ago

Seems like your server-side request to the DeepL API failed and thus the response in the Kirby Panel is empty. Can you please provide a minimum reproducible example (a repo) so I can test your issue? Thanks!

lrntmszrs commented 6 months ago

Another clue is that my DeepL account receives the texts to be translated, because the quota decreases every time I click on the "translate" button.

I should point out that I've tried this locally with Mamp (Apache 2.4/php 8.1) and on a live server (Apache 2.4/php 8.2).

(I'll try to put an instance on a repo)

johannschopplich commented 6 months ago

Sounds good. Thanks!

Can you show me the the response log from your browser's console? Specifically, the request error from the response body. Please enable Kirby debug mode therefore.

lrntmszrs commented 6 months ago

My browser displays these 2 errors in the console panel... (I'm not sure if this meets your request?) image

johannschopplich commented 6 months ago

No, I mean the result of the fetch request happening before the JS error.

lrntmszrs commented 6 months ago

Oops… sorry. I'm afraid, I don't really know where to look…

johannschopplich commented 6 months ago

You can look in your browser's network tab. There is probably a red item, indicating the failed request. The response is important, because the DeepL translation is happening on the server-side, not client-side (Kirby Panel).

lrntmszrs commented 6 months ago

wow thanks ! I'd never used this tab before.

Request header image

Response headers image

The preview shows that the right information is being sent... and received. It seems that Kirby is unable to update the page...

Request preview image Response preview image

johannschopplich commented 6 months ago

Thanks for the hints. The origin of the issue is on my side. 🙂

I believe you're using the ZIP file (main branch) of this plugin and not the Composer-managed version, right? I have made some changes latetly (https://github.com/johannschopplich/kirby-content-translator/commit/22726c2ffd8573044d5c4cf400ca34f193e156a4) that require a new build of the plugin... Which I have done just now: https://github.com/johannschopplich/kirby-content-translator/commit/f995e7fed0a4b354593e60f73acb4c54d6f4c5ea

Please download the ZIP again. Or better, use a version managed by Composer or load the plugin releases from the dedicated release pages, like v1.2.0. But either way, it should work now. Please let me know, if it does. 🎬

johannschopplich commented 6 months ago

@lrntmszrs This issue should be resolved with the latest build. Please follow my instructions above. Thanks!

lrntmszrs commented 6 months ago

Absolutely, everything works fine now. I had indeed DL the main branch Thank you very much for your help !