Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 4d1627a

Browse files
committed
Add ignore_tag optional param
I have added handling of ignored tag with a method to set them.
1 parent 88d5173 commit 4d1627a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/DeepL.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ class DeepL
3939
*/
4040
const API_URL_TAG_HANDLING = 'tag_handling=%s';
4141

42+
/**
43+
* API v1 URL: Parameter ignore_tags
44+
*/
45+
const API_URL_IGNORE_TAGS = 'ignore_tags=%s';
46+
47+
4248
/**
4349
* DeepL HTTP error codes
4450
*
@@ -96,6 +102,13 @@ class DeepL
96102
*/
97103
protected $curl;
98104

105+
/**
106+
* DeepL ingored tags
107+
*
108+
* @var array
109+
*/
110+
protected $ignoreTags = [];
111+
99112
/**
100113
* DeepL constructor
101114
*
@@ -200,6 +213,11 @@ protected function buildUrl($sourceLanguage, $destinationLanguage, $tagHandling
200213
if (!empty($tagHandling)) {
201214
$url .= '&' . sprintf(DeepL::API_URL_TAG_HANDLING, implode(',', $tagHandling));
202215
}
216+
if (!empty($this->ignoreTags)) {
217+
$url .= '&' . sprintf(DeepL::API_URL_IGNORE_TAGS, implode(',', $this->ignoreTags));
218+
}
219+
220+
203221

204222
return $url;
205223
}
@@ -268,4 +286,9 @@ protected function request($url, $body)
268286

269287
return $translationsArray;
270288
}
289+
290+
public function setIgnoreTags($ignoreTags)
291+
{
292+
$this->ignoreTags = $ignoreTags;
293+
}
271294
}

0 commit comments

Comments
 (0)