Skip to content

Commit 7f10159

Browse files
committed
Initial commit
1 parent de3806c commit 7f10159

File tree

63 files changed

+3761
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+3761
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.DS_Store
2+
/vendor

README.md

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
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

composer.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"require": {
3+
"google/cloud-translate": "^1.12",
4+
"deeplcom/deepl-php": "^0.4.0"
5+
},
6+
"replace": {
7+
"guzzlehttp/guzzle": "^6.3",
8+
"guzzlehttp/promises": "^1.0",
9+
"guzzlehttp/psr7": "^1.6.1",
10+
"monolog/monolog": "^1.5.0",
11+
"psr/http-message": "^1.0",
12+
"psr/cache": "~1.0"
13+
}
14+
}

0 commit comments

Comments
 (0)