Get language/multilingual settings from the backend
PLIP (Plone Improvement Proposal)
Responsible Persons
Proposer: Mikel Larreategi
Seconder:
Abstract
When using Volto we have 2 places where we need to set the language settings:
- In the backend:
- Install plone.app.multilingual
- Set the default language
- Set the available languages
- In the front-end configuration:
- Set
config.settings.isMultilingual = true - Set
config.settings.defaultLanguage = 'en' - Set
config.settings.availableLanguages = ['en', 'es', 'de']
- Set
This is a bit cumbersome, because it should be as easy as just enabling the languages in the backend to be able to have them in the frontend.
Motivation
- Reduce the number of possible failure points.
- Simplify the configuration.
- Imagine a user that wants to have multilingual features in Volto UI as they has in Classic UI. It is not possible without creating a frontend configuration and tweaking it in config.
Assumptions
Proposal & Implementation
- Add Plone's language configuration in the
@siteendpoint - Add a new AsyncPropExtender that queries the list of addons and sets a
isMultilingualkey in redux totrueifplone.app.multilingualis installed in the backend - Modify all uses of Volto language settings to get the value from redux
- Deprecate Volto settings for language handling from config (
isMultilingual,defaultLanguage,availableLanguages
Deliverables
- A new PR in plone.restapi to add language settings: A PR is already in place: https://github.com/plone/plone.restapi/pull/1738
- A new PR in Volto with the said changes. A playground branch and a draft PR is already in place: https://github.com/plone/volto/pull/5506
Risks
- We currently use Volto language settings in places where we do not have access to the redux store, such as routes or middleware . We may have some difficulties, or perhaps impossibilities to be able to achieve this as proposed; or we may need to change that configuration to something else.
- This would be definitely a breaking change.
Participants
- Mikel Larreategi
@erral Would we have to make this language request on each SSR render, or would it be possible to make the call on the Volto server startup and store the AsyncConnect result somewhere?
-
If we add the languages information to the @site endpoint, we already have an asyncpropsextender that will do the query and store it in redux in SSR.
-
regarding the isMultilingual setting, I initially thought to add it in the @site endpoint too and have it for free... but then I did it through the @addons endpoint and add a key in the reducer, and also add an asyncpropsextenders to the @addons endpoint. I don't know which option is better or more canonical regarding the REST API definition so I'm open to discuss it.