Copy document structure for localizations

default discord avatar
woellij
2 months ago
9

Hi there.


I'm currently evaluating several headless CMS and so far payload-cms is my favorite.



But i'm having trouble adding localizations and keeping the structure of an existing localization.



I cloned the public demo.


- Adding a new page for

en

with Hero and Layout.


- Save as draft


- switching to

de

clears the layout and i have to build it from scratch.



Is there a simple way to keep the structure when switching to a different locale? (Do i have to use a hook or something?



Thanks in advance.

  • discord user avatar
    dribbens
    Payload Team
    2 months ago

    The nice thing about Payload's localization is that it can be applied at any level of your document structure. Since the blocks layout you're working in has localization: true, this is being set at the top in your project currently. It sounds like you would prefer to have the localization applied at the field level, inside your blocks instead of at the top.

  • default discord avatar
    woellij
    2 months ago

    Thanks for the response.



    I got it working by removing

    localized: true

    from the Page Layout. It might be a bit misleading for total newcomers trying out the demo.


    But it is a great feature to be able to localize even the layout of documents.


    I'm more than likely going to recommend going forward with using payload-cms in the project.

  • default discord avatar
    kariyngva
    2 weeks ago

    Hey @dribbens


    In the case where you localise on the field level wouldn't that mean, if you'd remove a block on the

    de

    version it would also be removed on the

    en

    version?



    I ran into the same thing and kinda figured keeping the localisation on the block field would be a better option. Do you think it would be tricky to implement a custom component to copy block structure from the original language?

  • discord user avatar
    dribbens
    Payload Team
    2 weeks ago

    This is up to your config @kariyngva . If you want the document to have the same blocks, you would not set

    localized: true

    on the block field and instead put it on the fields within the blocks.



    We have a task right now to improve our localization editing experience



    I'd say this is a great point to make in the discussion on github to capture your pain paints.



    https://github.com/payloadcms/payload/discussions/1234
  • default discord avatar
    kariyngva
    2 weeks ago

    Thanks, I'll add my 2 cents 🙂

  • discord user avatar
    dribbens
    Payload Team
    2 weeks ago

    Thanks!

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.