Astro + Hybrid + i18Next (SSR, SSG)

Hi,

I’m a bit new with Astro. Issue as follows:

export default defineConfig({
output: ‘hybrid’,
integrations: [
astroI18next({
defaultLocale: ‘en’,
locales: [‘en’, ‘es’],
ssr: true,
resourcesBasePath: ‘/public/locales’
})
],
adapter: netlify(),
})

Anything that I could be missing?

Thanks

Hi @Zigor, thanks for the post and welcome.
Kindly make sure that your translations are organized in the correct folder structure under /public/locales . For example, you should have folders like /public/locales/en and /public/locales/es with the translation files inside.

If the above does not work, you can go to the Official Astro GitHub issues page below and then try to also get help there.

Thanks.

1 Like

Thanks for your answer.

1 Like

I got the SSR working adding the files as resources in the astro-i18next.config file:

import en from ‘./public/locales/en/translation.json’ assert { type: ‘json’ }
import es from ‘./public/locales/es/translation.json’ assert { type: ‘json’ }

and then:

i18nextServer: {
resources: {
en: {
translation: {
…en
}
},
es: {
translation: {
…es
}
}
}
}

Thanks for your advice.

1 Like

thanks for sharing this!

1 Like