Skip to content

Commit b25ae2e

Browse files
Release 1.2.3
1 parent c7affb7 commit b25ae2e

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## 1.2.3 - 2025-03-18
6+
### Fixed
7+
- Fixed an issue with DeepL Pro API keys.
8+
59
## 1.2.2 - 2025-03-12
610
### Added
711
- Allow translating nested entries in CKEditor fields for CraftCMS 5.x.
@@ -11,7 +15,7 @@ All notable changes to this project will be documented in this file.
1115
- Added the ability to translate Assets.
1216

1317
### Fixed
14-
- Fixed and issue when translating Categories to all languages.
18+
- Fixed an issue when translating Categories to all languages.
1519

1620
## 1.2.0 - 2025-02-21
1721
### Added

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "convergine/craft-content-buddy",
33
"description": "Content Buddy is an AI-driven CraftCMS plugin that leverages the ChatGPT API to automatically generate and manage multi-language content, including text and images, with customizable settings and features for precise control and enhanced content creation.",
44
"type": "craft-plugin",
5-
"version": "1.2.2",
5+
"version": "1.2.3",
66
"keywords": [
77
"craftcms",
88
"content-buddy",

src/api/text/DeepL.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ public function sendRequest($prompt, $maxTokens, $temperature, $isTranslate = fa
3535

3636
$body = $res->getBody();
3737
$json = json_decode( $body, true );
38-
if(isset($json['message'])){
38+
Craft::info( 'Result: '.$body, 'content-buddy' );
39+
if($res->getStatusCode() == 403) {
40+
Craft::info( 'DeepL ERROR', 'content-buddy' );
41+
throw new Exception( 'DeepL API key is invalid' );
42+
} else if(isset($json['message'])) {
3943
$message = $json['message'];
4044
Craft::info( 'DeepL ERROR', 'content-buddy' );
4145
Craft::info( $message, 'content-buddy' );
@@ -52,12 +56,13 @@ public function sendRequest($prompt, $maxTokens, $temperature, $isTranslate = fa
5256
return $this->_getTextGeneration($json );
5357
}
5458

55-
private function getEndpoint() {
56-
return "https://api-free.deepl.com/v2/translate";
59+
private function getEndpoint() : string {
60+
$api_key = $this->settings->getDeepLApiKey();
61+
return str_ends_with($api_key,':fx') ? "https://api-free.deepl.com/v2/translate" : "https://api.deepl.com/v2/translate";
5762
}
5863

59-
private function _getTextGeneration( array $result):string {
60-
return trim( $result['translations'][0]['text'] );
64+
private function _getTextGeneration($result) : string {
65+
return $result ? trim($result['translations'][0]['text']) : '';
6166
}
6267

6368
private function _getTranslatedData($prompt,$lang ):array {

0 commit comments

Comments
 (0)