-
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Documentation about @translations endpoint
- Loading branch information
Showing
10 changed files
with
182 additions
and
2 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,6 @@ | ||
DELETE /plone/en/test-document/@translations HTTP/1.1 | ||
Accept: application/json | ||
Authorization: Basic YWRtaW46c2VjcmV0 | ||
Content-Type: application/json | ||
|
||
{"language": "es"} |
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,2 @@ | ||
HTTP/1.1 204 No Content | ||
|
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,3 @@ | ||
GET /plone/en/test-document/@translations HTTP/1.1 | ||
Accept: application/json | ||
Authorization: Basic YWRtaW46c2VjcmV0 |
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,13 @@ | ||
HTTP/1.1 200 OK | ||
Content-Type: application/json | ||
|
||
{ | ||
"@id": "http://localhost:55001/plone/en/test-document", | ||
"language": "en", | ||
"translations": [ | ||
{ | ||
"@id": "http://localhost:55001/plone/es/test-document", | ||
"language": "es" | ||
} | ||
] | ||
} |
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,6 @@ | ||
POST /plone/en/test-document/@translations HTTP/1.1 | ||
Accept: application/json | ||
Authorization: Basic YWRtaW46c2VjcmV0 | ||
Content-Type: application/json | ||
|
||
{"id": "http://localhost:55001/plone/es/test-document"} |
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,5 @@ | ||
HTTP/1.1 201 Created | ||
Content-Type: application/json | ||
Location: http://localhost:55001/plone/en/test-document | ||
|
||
{} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
Translations | ||
============ | ||
|
||
Since Plone 5 the product `plone.app.multilingual`_ is included in the base | ||
Plone installation although it is not enabled by default. plone.restapi | ||
provides a `@translations` endpoint to handle the translation information | ||
of the content objects. | ||
|
||
Once we have installed `plone.app.multilingual`_ and enabled more than one | ||
language we can link two content-items of different languages to be the | ||
translation of each other issuing a `POST` query to the `@translations` | ||
endpoint including the `id` of the content which should be linked to. The | ||
`id` of the content must be a full URL of the content object: | ||
|
||
|
||
.. http:example:: curl httpie python-requests | ||
:request: _json/translations_post.req | ||
|
||
|
||
.. note:: | ||
"id" is a required field and needs to point to an existing content on the site. | ||
|
||
The API will return a `201 Created` response if the linking was successful. | ||
|
||
|
||
.. literalinclude:: _json/translations_post.resp | ||
:language: http | ||
|
||
|
||
After linking the contents we can get the list of the translations of that | ||
content item by issuing a ``GET`` request on the `@translations` endpoint of | ||
that content item.: | ||
|
||
.. http:example:: curl httpie python-requests | ||
:request: _json/translations_get.req | ||
|
||
.. literalinclude:: _json/translations_get.resp | ||
:language: http | ||
|
||
|
||
To unlink the content, issue a ``DELETE`` request on the `@translations` | ||
endpoint of the content item and provide the language code you want to unlink.: | ||
|
||
|
||
.. http:example:: curl httpie python-requests | ||
:request: _json/translations_delete.req | ||
|
||
.. note:: | ||
"language" is a required field. | ||
|
||
.. literalinclude:: _json/translations_delete.resp | ||
:language: http | ||
|
||
.. note:: | ||
The `@translations` endpoint works also when using `Products.LinguaPlone`_ | ||
in Plone 4.3.x | ||
|
||
|
||
.. _`plone.app.multilingual`: https://pypi.python.org/pypi/plone.app.multilingual | ||
.. _`Products.LinguaPlone`: https://pypi.python.org/pypi/Products.LinguaPlone. |
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