volto icon indicating copy to clipboard operation
volto copied to clipboard

Content without categorization behavior causes errors in view on multilingual sites

Open wesleybl opened this issue 3 months ago • 4 comments

Describe the bug Error occurred:

Cannot read properties of undefined (reading 'token')

To Reproduce Steps to reproduce the behavior:

  1. Create a multilingual website.
  2. Create a content type without the plone.dublincore behavior.
  3. Add plone.translatable behavior to content.
  4. Create an object of that type.
  5. Set the language on the object (In my case this is done at installation):
obj.language = 'en'
  1. Access the view.

PS: It might be easier to simulate by removing the Document type plone.categorization behavior.

Expected behavior It should show the content type view without error.

Software (please complete the following information):

  • Volto Version 18.25.0
  • Plone Version 6.1.2

Additional context This error started occurring after: https://github.com/plone/volto/pull/7125 I believe the line with the problem is: https://github.com/plone/volto/blob/4ef468c57298038dd0df623b6abef4efdbaf7b82/packages/volto/src/components/theme/AlternateHrefLangs/AlternateHrefLangs.jsx#L11

wesleybl avatar Sep 03 '25 13:09 wesleybl

Yeah, this code should be more careful and not add the current item if its language isn't known.

davisagli avatar Sep 05 '25 05:09 davisagli

@davisagli Is it "wrong" to create content with the plone.translatable behavior but without plone.categorization (which contains the schema with the Language field)? If I only have plone.translatable I can "translate" the content into the languages ​​available on the site. Then the object would have the language attribute, but would not have a schema with the Language field.

wesleybl avatar Sep 16 '25 15:09 wesleybl

@wesleybl I think our intention is that you can still translate content even if you don't want to show a language field in the edit form -- but I guess this combination is not well tested and may need some fixes.

davisagli avatar Sep 16 '25 16:09 davisagli

PS: It might be easier to simulate by removing the Document type plone.dublincore behavior.

Actually, to simulate with Document, the plone.categorization behavior must be removed. I fixed the description.

wesleybl avatar Nov 26 '25 03:11 wesleybl