Skip to content

Conversation

@pratyush07-hub
Copy link
Contributor

This fixes a bug where the Toolbar Types component crashes if a language in Plone is not in Volto’s langmap.

This PR fixes the issue by :

  • The crash happened because the code assumed langmap[lang] always exists.
  • Now, if a language is not in langmap, it will fall back to displaying the language code itself, preventing the toolbar from crashing.

Files changed:

  • packages/volto/src/components/manage/Toolbar/Types.jsx
  • packages/volto/news/7637.bugfix

Changelog:

  • Added a news file documenting this bug fix.


Closes #7637


@wesleybl
Copy link
Member

wesleybl commented Dec 5, 2025

@pratyush07-hub If I add fr-ht to the available languages ​​and then install plone.app.multilingual, I get the error:

Cannot read properties of undefined (reading 'nativeName')

I can't even add content afterwards. Perhaps issue #7637 is incomplete?

@pratyush07-hub
Copy link
Contributor Author

@pratyush07-hub If I add fr-ht to the available languages ​​and then install plone.app.multilingual, I get the error:

Cannot read properties of undefined (reading 'nativeName')

I can't even add content afterwards. Perhaps issue #7637 is incomplete?

I have checked it, and this is an additional issue that is not covered by my PR.
fr-ht doesn’t exist in the language map, so that’s why the error appears.
I’m trying to fix this issue now.

@pratyush07-hub
Copy link
Contributor Author

@pratyush07-hub If I add fr-ht to the available languages ​​and then install plone.app.multilingual, I get the error:

Cannot read properties of undefined (reading 'nativeName')

I can't even add content afterwards. Perhaps issue #7637 is incomplete?

Hi @wesleybl ,
I recorded a screen demo to show that my original fix works correctly.
The new issue happens only after a reload, and that's when the missing language in langmap causes the nativeName error you mentioned.
I didn’t notice this earlier, but now I understand the cause and I’m currently working on fixing this as well.

Screencast.from.2025-12-05.14-09-58.webm

@pratyush07-hub pratyush07-hub marked this pull request as draft December 6, 2025 21:45
@pratyush07-hub
Copy link
Contributor Author

Hi @wesleybl @stevepiercy ,

I’ve been looking into the crash that happens when Plone has a language that Volto doesn’t recognize in its LanguageMap.

What’s going wrong:
Plone can include languages like "fr-ht", but Volto doesn’t have an entry for them in LanguageMap.
When the UI tries to read langmap[lang].nativeName, it ends up being undefined, which causes Volto to crash.

What I am trying to do:

  • In LanguageSelector.tsx, I added a safe fallback so the UI won’t crash. If a language isn’t in the map, it just displays the language code.
  • In MultilingualRedirector.jsx, I added checks so unsupported languages in cookies fall back to the default language, and missing locale files don’t cause errors.

However, these fixes alone are not enough.

I need your guidance here:

  1. should we show unsupported languages using their code (e.g., “fr-ht”), or
  2. should we block them in the selector and prevent users from choosing them.
  3. Also, should we consider adding these missing languages to LanguageMap.js?

I am thinking that option 2 might be the better choice, but I’d like your guidance.

@wesleybl
Copy link
Member

wesleybl commented Dec 9, 2025

should we show unsupported languages using their code (e.g., “fr-ht”)

If the backend supports a specific language and the user has selected that language, I think it's best not to have limitations and only display the language code.

I don't think we need to update LanguageMap.js if Volto doesn't support that language.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Toolbar Types crashes when language code not in langmap

2 participants