Hiya, I need help with the issue of Multilingual Starter blog(Gatsby on localhost + DatoCMS)
I am customising this Multilingual Starter blog. I already followed this site of localization and unchecked the All locales required? option.
Would you please provide me with any tips to solve this problem as like the below picture shows?
I’d like to show only articles written in Japanese on the JA post list view page. What I really want to do is to show different contents for each language on the post list view page.
However, as you can see in the below picture, the date and minutesOfReading are still showed up. This issue happens only in other language and an english version is fine.
As you can see you’ll have to follow steps 1 to 15 on that readme file to make sure that the blog is configured with multi language support, and generates the posts accordingly.
Once you follow all the steps, you can just add posts in their respective locales through the dashboard and the blog will handle the generation of the posts accordingly based on the client selected language
Let me know if you find any problems allong the way
You won’t find that code in a specific file, it is just exemplifying the format of a query response now that you added more languages on the dashboard.
If you want to learn a little bit more about how queries work in depth, and how you can make one, you can check out this documentation page: Content Delivery API - Overview - DatoCMS Docs
But basically what this code snippet is saying, is that now that you’ve added those languages on your dashboard, the subsequent queries you’ll make on your code will have a response that has that format.
Does that make sense?
I can understand what you mentioned. I read the README again more seriously, but the steps from 1 to 15 do not seem to suggest the direct way to solve this issue. I might miss some points on the documents though. I am looking for the step or setting to avoid showing the date and minutesOfReading with post in JA which the above image is showing.
From your advise, I just added the “if condition” to archive.jsx of templates directory like the below code.
I thought that this code seemed to be logically correct to show different contents for each language but every contents in both language did not show up at all like the screenshot I attached with chat.
Is there any notice you think ?
When it comes to the project, i’m trying to install it to help you debug it, but i’m encountering some problems with it.
It isn’t a project directly maintained by Dato (you can see demo projects directly maintained by Dato here: Project starters - Free demo projects - Marketplace
So i can’t guarantee support for it, but i’ll try getting in contact with the project creator to see if we can find a solution.
I already have removed certain locals in the same way as you did on the recording, then I posted this question. I did not notice that this repo is not officially supported by dato.
I found the multi lang version’s demo project with next.js in the free demo project list you provided.
Do you think that this demo project, “Next.js i18n blog” can meet what I want to do ? I will also try to debug this repo though.
Sure! That Next.js demo provides a way to display a blog with several posts, allowing you to select the language of the entire site (including the posts) based on the option the user selected,. I think it is a good option for your use case.
The blog still shows the image, auther, and date in english version. I unchecked “All locales required?”, I just removed an english content on the dato cms, and run it on local. I do not touch application code at all.
Would you please suggest next step if you have some notice ?
Just so i’m certain of what you are trying to do, you are trying to remove a post in just one language? (that is, make the post show up only in italian, but not in english)
Or are you trying to remove the language option completely?
In that case, let’s say that you expect all posts to have a non-empty title.
So we will only render only the previews for posts that have a populated title.
We can modify our pages/index.js query to add a filter for non empty titles:
This will make sure that if the post has a blank title, its preview card won’t be rendered.
Now, if we want the post page itself also not to be rendered if the post doesn’t have a title (lets say, if someone inputs the post URL directly into the browser) we can add a similar check into the [slug].js file inside the “posts” folder.
Let me know if that was what you were looking for!
As for the Italian post showing up “On the english list”
That selection is only to select a title language, if that language is available, it is not an actual filter
There is a thread on the forum explaining this behaviour, here: Locale filter doesn't work