How do i do localisation?

default discord avatar
sasjumb
last month
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
    Payload Team
    last month

    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

    CleanShot_2023-08-11_at_12.07.41.png
  • default discord avatar
    sasjumb
    last month

    @denolfe


    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:
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.