plone / plone.app.multilingual

Plone Multilingual Content Add-on
https://pypi.org/project/plone.app.multilingual
19 stars 47 forks source link

Translation id chooser heuristics are not ok for some edge cases #412

Open tiberiuichim opened 1 year ago

tiberiuichim commented 1 year ago

https://github.com/plone/plone.app.multilingual/blob/6325639b06040519ce4f33faa7d75a0b3a0e4276/src/plone/app/multilingual/factory.py#L68-L76

It should regenerate a new id in the context of the new parent.

If I have an id like items-74, it tries to name the translation as items, which triggers:

  Module plone.app.multilingual.api, line 46, in translate
  Module plone.app.multilingual.manager, line 135, in add_translation
  Module plone.app.multilingual.factory, line 93, in __call__
  Module plone.dexterity.content, line 808, in invokeFactory
  Module Products.CMFCore.PortalFolder, line 299, in invokeFactory
  Module Products.CMFCore.TypesTool, line 809, in constructContent
  Module Products.CMFCore.TypesTool, line 308, in constructInstance
  Module Products.CMFCore.TypesTool, line 570, in _constructInstance
  Module Products.BTreeFolder2.BTreeFolder2, line 436, in _setObject
  Module plone.folder.ordered, line 253, in _checkId
  Module Products.CMFCore.PortalFolder, line 318, in _checkId
  Module OFS.ObjectManager, line 125, in checkValidId
zExceptions.BadRequest: The id "items" is invalid - it is already in use
lokeshmeesala commented 1 year ago

Hey, I can work on this. In the given example, either content_id is not in parent.objectIds() or 'language' argument is empty. Please let me know how a new id must be generated in these cases. Thanks.