|
| 1 | +# Macareux Content Translator |
| 2 | + |
| 3 | +Concrete CMS has powerful features to manage multilingual content by |
| 4 | +its default. You can add language sections in your sitemap and connect |
| 5 | +pages between language sections, copy contents from one section to another |
| 6 | +language section, add a Switch Language block to provide an interface to |
| 7 | +switch languages for visitors, etc. Also, you can translate a user |
| 8 | +interface from Dashboard easily. The one last missing piece is content |
| 9 | +translation. |
| 10 | + |
| 11 | +This package installs a CAT tool into your dashboard. Translators can |
| 12 | +translate pages from outside in-context editing, so they can focus on translate |
| 13 | +contents. |
| 14 | + |
| 15 | +Also, developers can add machine translators easily. |
| 16 | +This package contains built-in machine translators: Google Translate, DeepL |
| 17 | + |
| 18 | +## Videos |
| 19 | + |
| 20 | +* [How to translate contents](https://youtu.be/6Tr-8dI6G8o) |
| 21 | +* [How to enable machine translators](https://youtu.be/90vNHARToUw) |
| 22 | + |
| 23 | +## ToDo |
| 24 | + |
| 25 | +* Test with Basic Workflow (This package creates a new version of the page and approves it. It should work with built-in workflow system). |
| 26 | +* Dictionary for human translators |
| 27 | +* Support more blocks |
| 28 | +* Permission Keys |
| 29 | + * Can translate page contents (done) |
| 30 | + * Can discard translate request |
| 31 | + * Can edit translate request |
| 32 | + * Can publish translate request |
| 33 | + * Can use machine translators |
| 34 | +* Search requests |
| 35 | +* More machine translators |
| 36 | +* Merge this package to the core |
| 37 | + |
| 38 | +## Not to do |
| 39 | + |
| 40 | +* Dictionary for machine translators |
| 41 | + * Developers should add a custom translator that has this feature as another package. I want to keep this package as simple as I can. |
| 42 | + |
| 43 | +## How to extend |
| 44 | + |
| 45 | +### Make custom blocks translatable |
| 46 | + |
| 47 | +#### Extractor Routine |
| 48 | + |
| 49 | +Create an Extractor Routine class to get translatable content from original block. |
| 50 | + |
| 51 | +You must implement `\Macareux\ContentTranslator\Extractor\Routine\ExtractBlockRoutineInterface` interface. |
| 52 | + |
| 53 | +You should extend `\Macareux\ContentTranslator\Extractor\Routine\AbstractExtractBlockRoutine` class to implement the interface easily. |
| 54 | + |
| 55 | +You need to return an instance of `\Macareux\ContentTranslator\Entity\TranslateContent` |
| 56 | +class only when the given block instance is the type of you want to support. |
| 57 | + |
| 58 | +Register your extractor class to extractor manager. |
| 59 | + |
| 60 | +```php |
| 61 | +$manager = $app->make(\Macareux\ContentTranslator\Extractor\Routine\Manager::class); |
| 62 | +$manager->registerRoutine(new YourCustomRoutine()); |
| 63 | +``` |
| 64 | + |
| 65 | +#### Publisher Routine |
| 66 | + |
| 67 | +Create a Publisher Routine class to publish translated content to original page. |
| 68 | + |
| 69 | +You must implement `\Macareux\ContentTranslator\Publisher\Routine\PublishRoutineInterface` interface. |
| 70 | + |
| 71 | +You have to update a block of correct source type and correct identifier. |
| 72 | +Please check built-in publisher classes. |
| 73 | + |
| 74 | +Register your publisher class to publisher manager. |
| 75 | + |
| 76 | +```php |
| 77 | +$manager = $app->make(\Macareux\ContentTranslator\Publisher\Routine\Manager::class); |
| 78 | +$manager->registerRoutine(new YourCustomRoutine()); |
| 79 | +``` |
| 80 | + |
| 81 | +### Add custom machine translators |
| 82 | + |
| 83 | +Create a Translator class to translate content automatically. |
| 84 | + |
| 85 | +You must implement `\Macareux\ContentTranslator\Translator\TranslatorInterface` interface. |
| 86 | + |
| 87 | +You should extend `\Macareux\ContentTranslator\Translator\AbstractTranslator` to implement the interface easily. |
| 88 | + |
| 89 | +You must create an element file for configuration like adding an API key. |
| 90 | +The file structure is: `elements/content_translator/translator/{translator_handle}.php` |
| 91 | + |
| 92 | +Finally, please install your custom translator. |
| 93 | + |
| 94 | +```php |
| 95 | +$manager = $app->make(\Macareux\ContentTranslator\Translator\Manager::class); |
| 96 | +$manager->installTranslator('translator_handle', "Translator Name", 'YourTranslatorClassName'); |
| 97 | +``` |
| 98 | + |
| 99 | +## License |
| 100 | + |
| 101 | +MIT license |
0 commit comments