-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Add Event for Glossary detection
- Loading branch information
Showing
4 changed files
with
92 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace WebVision\Deepltranslate\Core\Domain\Dto; | ||
|
||
use WebVision\Deepltranslate\Core\Event\DeepLGlossaryIdEvent; | ||
|
||
/** | ||
* This class holds the current working page | ||
* while processing inside the DataHandler | ||
* | ||
* It is the main entry point for extensions during events | ||
* detecting the right page, | ||
* for example, while detecting a glossary. | ||
* | ||
* @see DeepLGlossaryIdEvent for an usage example | ||
*/ | ||
final class CurrentPage | ||
{ | ||
public function __construct( | ||
public readonly int $uid, | ||
public readonly string $title | ||
) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace WebVision\Deepltranslate\Core\Event; | ||
|
||
use WebVision\Deepltranslate\Core\Domain\Dto\CurrentPage; | ||
|
||
/** | ||
* Entry point for external synchronized DeepL glossaries. | ||
* | ||
* The event is fired right before the translation handling from the DeepL translation. | ||
* As entry, you get the source language, target language and the current page. | ||
* | ||
* Expects a string on parameter glossaryId. This ID is used for glossary-flavoured | ||
* translation. No check for synchronized glossary, the ID is taken "AS IS". | ||
*/ | ||
final class DeepLGlossaryIdEvent | ||
{ | ||
public string $glossaryId = ''; | ||
|
||
public function __construct( | ||
public readonly string $sourceLanguage, | ||
public readonly string $targetLanguage, | ||
public readonly ?CurrentPage $currentPage | ||
) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters