I've been working on a website using ni18n with Next.js, but I'm having trouble removing the language part from the URL even after trying to force remove it.
What I'm aiming for is a URL like this:
"http://localhost:3000"
However, whenever I type in the website address, it redirects to "localhost:3000/tr" instead.
Any thoughts on why this might be happening? I'm stumped.
//_app.tsx
function MyApp({ Component, pageProps }: AppPropsWithLayout) {
// Use the layout defined at the page level, if available
const getLayout = Component.getLayout ?? ((page) => page)
if(typeof window !== 'undefined'){
const locale = window.localStorage.getItem('locale') || 'en'
useSyncLanguage(locale)
}
return getLayout(
<ThemeProvider attribute='class'>
<Component {...pageProps} />
</ThemeProvider>
)
}
// ni18n.config.ts
import type { Ni18nOptions } from 'ni18n'
export const ni18nConfig: Ni18nOptions = {
supportedLngs: ['en', 'tr'],
ns: ['common','navbar'],
}
//18next.d.ts
declare module 'react-i18next' {
interface CustomTypeOptions {
resources: {
common: typeof common,
navbar: typeof navbar
}
}
}
//next.config.js
module.exports = {
i18n: {
defaultLocale: 'en',
locales: ['en', 'tr'],
},
}