Skip to content

i18n: Allow files with a subset of translations #6932

@JMLFP

Description

@JMLFP

Issue

Right now the i18n support in Decap will create a file for every enabled locale even if no data was entered for this locale. This can be undesirable when the user would like to fallback to the default locale if content is not available in the user locale (or if translation will be done later). You can see the effects of this issue mentioned here: #4480 (comment).

Example: if the user creates a new page and enters the content in the default locale (en), but leaves one of the other locales blank (es) the CMS will still commit a new-page.en.md and new-page.es.md. This means that new-page.es.md may show up on index pages and as a linked translation even though it's a blank file with just header data.

Proposed Solution

I suggest that we add a boolean configuration flag that would require manually enabling a translation. It would default to true to keep the existing behavior and keep backwards compatibility.

# config.yml
i18n:
  save_all_locales_by_default: false

This config flag could trigger an updated UI element that would require the content editor to enable a translation. If the translation is enabled, the translated file will be saved. If not, no translated file will be created:

image

Other Solutions

I have also thought about discarding the translation if certain fields are empty (for example, no body) - but this seems more likely to break workflows. Thoughts?

Final Thoughts

I am interested in cooperating on a PR to help implement a feature to resolve this issue, but I would appreciate some feedback on the architecture before I begin writing code :-)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: i18npinnedtype: featurecode contributing to the implementation of a feature and/or user facing functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions