plone / plone.restapi

RESTful API for Plone.
http://plonerestapi.readthedocs.org/
84 stars 75 forks source link

Multilingualism handling #225

Closed erral closed 6 years ago

erral commented 7 years ago

We need an endpoint to return the translations of a given content and another one to link two contents as translations of each other.

Progress so far:

erral commented 7 years ago

The idea is to provide a new enpoint called @translations on the same way that the current @workflow one that on GET returns the current translations of the content objects and on POST creates the translation link between both.

erral commented 7 years ago

When linking to content items as translations, we need to pass a parameter with the id of the linked content.

For the moment I will try to use the current value of @id of a content-item (its URL) for it.

erral commented 7 years ago

I created a branch for this issue:

https://github.com/plone/plone.restapi/tree/issue-225-multilingualism

erral commented 7 years ago

Is it safe to asume that the @translations endpoint should only exist in Plone 5 and not in Plone 4 because p.a.multilingual is included by default in Plone 5 and not in Plone 4?

erral commented 7 years ago

Discussed with @sneridagh and @buchi:

This would require to add conditional registrations for LinguaPlone and different test setup.

erral commented 7 years ago

The build is green:

https://travis-ci.org/plone/plone.restapi/builds/207939667

I still want to do some other checks if I can make it work with Plone 4 and earlier versions of plone.app.multilingual (1.x and 2.x) (currently I have some test issues with them)

tisto commented 7 years ago

@erral would you mind creating a pull request? Or is it too early for this?

erral commented 7 years ago

I'll do it. I have just been finishing other stuff.

I need to check one or two things, and then I'll issue the PR.

On Fri, Mar 10, 2017 at 12:51 PM, Timo Stollenwerk <notifications@github.com

wrote:

@erral https://github.com/erral would you mind creating a pull request? Or is it too early for this?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/plone/plone.restapi/issues/225#issuecomment-285650406, or mute the thread https://github.com/notifications/unsubscribe-auth/AAx41aLqZTDliOrNllq1l0ZIHyUV1I1Aks5rkTk6gaJpZM4MSByN .

-- Mikel Larreategi CodeSyntax

Azitaingo Industrialdea 3 K E-20600 Eibar Tel: (+34) 943 82 17 80

erral commented 7 years ago

And of course, I need to rewrite the docs to handle changes on #248

erral commented 7 years ago

After a long fight with this issue and the different test-setup scenarios needed to run this, I found it too complex to handle the whole scope of multilingualism handling just in one package.

If I include the implementation for LinguaPlone in plone.restapi, the documentation of plone.restapi breaks, because LinguaPlone installs some more vocabularies, and thus the @vocabularies endpoint documentation test breaks.

If I try to install plone.app.multilingual in Plone 4, there are some more testing breakages that occur when running the tests when the code is exactly the same...

Anyway neither LinguaPlone nor plone.app.multilngual are installed by default in Plone 4, moreover there are two versions of plone.app.multilingual that work in Plone 4 (1.x and 2.x).

So, as the last attempt, I just included the @translations endpoint for Plone 5 (using zcml:condition="have plone-5") and included the tests using some ugly PAM_INSTALLED conditional.

Anyway, the code and tests for LinguaPlone work, so I would go to include it in an external package, something like collective.restapi.linguaplone. I will try to do so also for plone.app.multilingual 1.x and 2.x with something like collective.restapi.pam.

Comments? @sneridagh @tisto @buchi

erral commented 6 years ago

The pull-request is merged, we can close this.

For future reference, only Plone 5 support is added directly on plone.restapi. To get Plone 4 support with either LinguaPlone or plone.app.multilingual use specific addons (https://pypi.python.org/pypi/collective.restapi.linguaplone and https://pypi.python.org/pypi/collective.restapi.pam)