strapi / nextjs-corporate-starter

Strapi Demo application for Corporate Websites using Next.js
MIT License
1.08k stars 338 forks source link

How to set default locals #83

Closed asifdastagir-ovrlod closed 9 months ago

asifdastagir-ovrlod commented 1 year ago

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.

PaulBratslavsky commented 1 year ago

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.

asifdastagir-ovrlod commented 1 year ago

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

colonder commented 12 months ago

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

asifdastagir-ovrlod commented 12 months ago

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

PaulBratslavsky commented 11 months ago

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

PaulBratslavsky commented 9 months ago

Closing this issue due to "no recent activity".