strapi/nextjs-corporate-starter

How to set default locals

asifdastagir-ovrlod opened this issue · 6 comments

Hi,

I want to set the default language as Arabic as I can.
When I hit http://localhost:3000/ the URL redirects the English version.

I accidentally closed the issue, I reopened it. I thought this was regarding to something else. But I will look into how to set defualt locales. Not sure how to do this of the top of my head.

@PaulBratslavsky Thanks for your reply, I hope you will find out about this. Basically, I am developing the client website on your prebuilt structure the default language is Arabic. I had to find out how the default locale is Arabic. Please help me sort out this issue...

@asifdastagir-ovrlod just change defaultLocale value in i18n config in i18n-config.ts

@colonder I changed but the app not getting the default locale, The defaultLocale is working only in blog page.

@asifdastagir-ovrlod I haven't found the issue yet, but when getting pages we are calling this function https://github.com/strapi/nextjs-corporate-starter/blob/main/frontend/src/app/%5Blang%5D/utils/get-page-by-slug.ts

import {fetchAPI} from "@/app/[lang]/utils/fetch-api";

export async function getPageBySlug(slug: string, lang: string) {
    const token = process.env.NEXT_PUBLIC_STRAPI_API_TOKEN;

    const path = `/pages`;
    const urlParamsObject = {filters: {slug}, locale: lang};
    const options = {headers: {Authorization: `Bearer ${token}`}};
    return await fetchAPI(path, urlParamsObject, options);
}

I wonder if you console log the locale you are requesting here what does it show. Maybe it is not getting the right locale to pass in the GET request.

Closing this issue due to "no recent activity".