i18n: allow requiring/validation of fields for non-default locale #5112
Labels
area: i18n
type: feature
code contributing to the implementation of a feature and/or user facing functionality
I'm setting up a bilingual site (two locales) using Netlify CMS and the i18n feature. Things are working the way the documentation suggests they should but I'm trying to do something that doesn't seem to be possible for the moment - or at least I can't find the answer I'm looking for in the docs or in other issues raised here on GH.
I would like to be able to require a field for the second locale as well as for the default locale. As it stands, if the CMS user doesn't complete the translation fields, both files are saved (I'm using the multiple_folders setup), but the file for the second locale is just empty, except for the data fields that were set to i18n: duplicate.
I'd like a way to require certain fields for the second locale too.
Ideally what I'd like is that if the user doesn't fill in the fields for the second locale, then the fields are automatically duplicated from the primary locale fields, which will always be completed because they are required.
At the very least, if the user doesn't fill in the second locale, I'd like the generated file for the second locale to at least have the fields (keys) even if there's no data attached to them. Otherwise I have to incorporate a lot of extra logic into my application (parsing the files to check what data is or isn't present) which is possible of course, but I'd like to avoid it.
This seems like important functionality, so maybe I'm just completely missing something obvious and this is already possible?
Anyway, thanks to all the contributors for their work on netlify cms!
Edit: adding my very simple config.yml
Another edit:
Thought I was on to something there with CMS events and
preSave
, but I see that won't work either: #4729In the end I just solved it on the application side which wasn't a terrible big deal. For a statically generated site you could just integrate it into the build process. My app isn't statically generated though so the parsing of the data happens upon every request to the api which is fine for this small app in development, but wouldn't be ideal for bigger applications with a lot of data I suppose.
The text was updated successfully, but these errors were encountered: