How to Translate Content and Use Different Images Across Languages
3 replies
Last updated: Dec 9, 2021
D
Hello, how should I create translation on the content blog sanity?
Under the content category, I tried to add the EN and FR following the video, but doesn't seem to work.
Also if I want to have 2 images en and fr, how should I add it in my schema?
please advice
🙏
Under the content category, I tried to add the EN and FR following the video, but doesn't seem to work.
Also if I want to have 2 images en and fr, how should I add it in my schema?
please advice
🙏
{ name: 'content', type: 'array', title: 'Content', of:[ { type: 'block' }, { name: 'test', type: 'object', title: 'test', fields: [ { title: 'English', name: 'en', type: 'string' }, { title: 'French', name: 'fr', type: 'string' } ] }, { type: 'image', fields: [ { type: 'text', name: 'alt', title: 'Description', options: { isHighlighted: true } } ], options: { hotspot: true } }, { type: 'code' } ] }
Dec 9, 2021, 6:09 PM
D
I can use separate editor or same one, all I want is to have the content to have en and fr.
I tried to add this, but doesn't work:
I tried to add this, but doesn't work:
{ name: 'test', type: 'object', title: 'test', fields: [ { title: 'English', name: 'en', type: 'string' }, { title: 'French', name: 'fr', type: 'string' } ] },
Dec 9, 2021, 7:01 PM
R
Got it. First off, I'd pull your block content array out into its own reusable schema, like:
Then, in your document you can set up an object that contains both an
export default { name: 'blockContent', title: 'Block Content', type: 'array', of: [ { type: 'block', marks: { annotations: [ { name: "link", type: "object", title: "URL", fields: [ { title: "URL", name: "href", type: "url", }, ], } ] } }, { type: 'image' }, ] }
enand
frcontent schema. Like this:
{ name: 'content', title: 'Content', type: 'object', fields: [ { title: 'English', name: 'en', type: 'blockContent' }, { title: 'French', name: 'fr', type: 'blockContent' } ] },
Dec 9, 2021, 7:22 PM
D
okay thanks a lot
Dec 9, 2021, 7:51 PM
Sanity– build remarkable experiences at scale
The Sanity Composable Content Cloud is the headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.