GithubHelp home page GithubHelp logo

Comments (10)

andreasba avatar andreasba commented on September 26, 2024 1

image

Outputs

string(39) "59ecab18-xxxx-431e-1bcc-9999c7a6e959:fx" (I have changed the key a bit and changed it meanwhile - but it is my authkey)

I am running on Kirby 4 alpha-5. Also I have two other plugins active (an SEO one and one for Matomo) but I cannot see how this could impact anything?

When replacing the version of your code, I deleted the whole directory and reuploaded the whole thing.

Oh I also deleted the media directory.

When I don't die(), I get a strange redirect which you obviously do not get.

What Kirby version are you running?

Edit: Interesting. I tried to create a new DeepL authkey and the portal says "Permission denied". So maybe it really is just my key. Let me check with DeepL support.

from kirby-machine-translation.

andreasba avatar andreasba commented on September 26, 2024 1

It works now @tobiasfabian, lots of thanks for your great support! It seems like my account was half-registered half-not-registered, After DeepL support fixed something, I had to re-register, re-generate a new AuthKey and now it works. I will test over the weekend and provide feedback if you like. Danke nochmal!

from kirby-machine-translation.

andreasba avatar andreasba commented on September 26, 2024

For testing purposes, I hardcoded the API key now into the index.php of the plugin. When pressing the button, I now receive a different error message:

image

Any way how I can help debug this @tobiasfabian ?

Thanks
Andreas

from kirby-machine-translation.

tobiasfabian avatar tobiasfabian commented on September 26, 2024

Hi @andreasba,
thanks for testing the plugin. There was indeed a problem with the handling of the options. I fixed it with 160bf70.

You should now be able to set the DeepL key as described in the Readme. I’m not sure about the second error you mentioned. If it still exists, could you please check the Web Inspector console for further details on the error.

from kirby-machine-translation.

andreasba avatar andreasba commented on September 26, 2024

Thanks for your quick response @tobiasfabian :)

Now, when pressing the translation button, I get a Fatal DeepL API error:

image

I am not a pro in debugging, but this is what the Web Inspector spits out:

image

image

Is that useful?

from kirby-machine-translation.

tobiasfabian avatar tobiasfabian commented on September 26, 2024

Thanks for your reply and thank you for being an early adopter. It helps a lot.

It’s a PHP error which is logged into the JavaScript console. So your second screenshot is the relevant one. It says, that the problem is on line 253 of the file /site/plugins/machine-translation/lib/Translate.php.

$response = Remote::request($url, $params);
$response = $response->json();
if (!array_key_exists('translations', $response ?? [])) {
throw new Exception($response['message'] ?? 'Fatal error with Deepl API');
}

The response of the DeepL API is not as excepted. Therefore I have improved the error handling of the DeepL API response. Could you please download the latest version and test again?

from kirby-machine-translation.

andreasba avatar andreasba commented on September 26, 2024

Thanks for your quick reaction @tobiasfabian ! Your plugin could be extremely useful so it is my pleasure to help anyway I can :) Now I receive the following error code:
image
(and I am quite sure I have the config.php edited in the right way)

If I hardcode the API key again into index.php of the plugin I get the same error. The same when I try via env.php file:

image

Edit: on the DeepL website, it states to make sure to use the right domain: api-free.deepl.com (I have a free API key, not a paid one). Could that be the issue?

from kirby-machine-translation.

tobiasfabian avatar tobiasfabian commented on September 26, 2024

There is something wrong with your Auth Key. I’m using the free API myself. This should not be the issue.

To debug your issue, could you please check the following. Add a var_dump($authKey) between line 239 and 241 of lib/Translate.php. When you click on “Translate Page” the output should be something like this, where you can check if your Auth Key is correct (your Auth Key is shown after string(39)). Your Auth Key should be ending with :fx (because you are using the free API).

Screenshot of debug message from Kirby Panel

$url = 'https://' . $apiDomain . '/v2/translate';
$params = [

from kirby-machine-translation.

tobiasfabian avatar tobiasfabian commented on September 26, 2024

To debug, you can use a curl command with your Auth Key.

curl -X POST 'https://api-free.deepl.com/v2/translate' \
--header 'Authorization: DeepL-Auth-Key [yourAuthKey]' \
--header 'Content-Type: application/json' \
--data '{
  "text": [
    "Hello, world!"
  ],
  "target_lang": "DE"
}'

https://www.deepl.com/de/docs-api/translate-text/translate-text/

from kirby-machine-translation.

andreasba avatar andreasba commented on September 26, 2024

Good idea @tobiasfabian - I get a 403 Forbidden error. Lets wait what DeepL support says.

from kirby-machine-translation.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.