Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

How do i do localisation?

default discord avatar
sasjumblast year
2

I've read the docs on localisation but I am still a bit confused.



I am creating an element in my collection, but I dont see how would i localise the different fields? I must be missing something basic here...



When i change the locale in my dashboard, the fields values stay the same as in all other locales



the code:



export default buildConfig({


collections: [SellingPointCardCms],


globals: [


// Your globals here


],


typescript: {


outputFile: path.resolve(__dirname, "../payload-types.ts"),


},


localization: {


locales: ["en", "da"],


defaultLocale: "en",


fallback: true,


},


});




export const SellingPointCardCms: CollectionConfig = {


slug: "SellingPointCardCms",


admin: { useAsTitle: "title" },


access: {


read: () => true,


},


fields: [


{


name: "title",


type: "text",


required: true,


localized: true,


},


{


name: "description",


type: "text",


required: true,


localized: true,


},


{


name: "content",


type: "text",


required: true,


localized: true,


},


{


name: "linkTitle",


type: "text",


required: true,


localized: true,


},


{


name: "href",


type: "text",


required: true,


},


],


};



When i change locale here, the fields stay the same



This is how it looks like in my db:

  • discord user avatar
    denolfe
    last year

    If you've saved anything while in dk, it will take precedence over en



    if not, it will fallback to en



    Taking a look at the api response in the bottom right might help you



    Can also change that to

    locale=all

    to all as well

  • default discord avatar
    sasjumblast year
    @967118574445547650


    When i change my locale in the dashboard and make changes to an element, the same change is also made in the other locale. Eg. changing title while in da, will also change the title in the en locale. <- this is also reflected in the data base as there is corresponding field to the different locales, eg title_da or title_en.



    So how would i edit the element and so that there is an english version and danish version of it?



    It actually works now, I restarted my dev env and it works as described...

    :blobshrug:
Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.