Content without categorization behavior causes errors in view on multilingual sites
Describe the bug Error occurred:
Cannot read properties of undefined (reading 'token')
To Reproduce Steps to reproduce the behavior:
- Create a multilingual website.
- Create a content type without the
plone.dublincorebehavior. - Add plone.translatable behavior to content.
- Create an object of that type.
- Set the language on the object (In my case this is done at installation):
obj.language = 'en'
- 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
Yeah, this code should be more careful and not add the current item if its language isn't known.
@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 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.
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.