0

When i run locally (even with yarn start in prod mode), my translations work correctly. However, after i deploy my project to AWS Amplify, this specific /dashboard page is not working the translations (no error messages at all in console.log, nothing).

I have the following structure:

import { serverSideTranslations } from 'next-i18next/serverSideTranslations'

import { UserHome } from '~/templates'

export default function Dashboard() {
  return <UserHome />
}

export async function getServerSideProps({ locale }: { locale: string }) {
  const res = await serverSideTranslations(locale, ['common'])
  return {
    props: {
      ...res
    }
  }
}

This leads to UserHome template. Now the following:

import { useTranslation } from 'next-i18next'
import Image from 'next/image'

import { PageHeader, TableCampaign } from '~/components'
import { tableData } from '~/components/TableCampaign/mock'

import Base from '../Base'
import styles from './user-home.module.css'

const UserHome = () => {
  const { t } = useTranslation('common')
  return (
    <Base>
      <PageHeader image="/img/computer.svg" title={t('tableCampaign.title')}>
        <div className={styles.header__legends}>
          <div className={styles.header__infos}>
            <div className={styles.header__legend}>
              <div
                className={`${styles.header__circle} ${styles.header__circle__success}`}
              ></div>
              <p className={styles.header__state}>
                {t('tableCampaign.active')}
              </p>
            </div>
            <div className={`${styles.header__legend} mt-2`}>
              <Image
                src="/icon/eye.svg"
                alt="Eye icon"
                className="mr-2"
                width={24}
                height={24}
              />
              <p className={styles.header__state}>{t('tableCampaign.view')}</p>
            </div>
          </div>

          <div className={`${styles.header__infos} mx-6`}>
            <div className={styles.header__legend}>
              <div
                className={`${styles.header__circle} ${styles.header__circle__warning}`}
              ></div>
              <p className={styles.header__state}>
                {t('tableCampaign.pending')}
              </p>
            </div>
            <div className={`${styles.header__legend} mt-2`}>
              <Image
                src="/icon/edit.svg"
                alt="Pen icon"
                className="mr-2"
                width={24}
                height={24}
              />
              <p className={styles.header__state}>{t('tableCampaign.edit')}</p>
            </div>
          </div>

          <div className={styles.header__infos}>
            <div className={styles.header__legend}>
              <div
                className={`${styles.header__circle} ${styles.header__circle__danger}`}
              ></div>

              <p className={styles.header__state}>
                {t('tableCampaign.finished')}
              </p>
            </div>
            <div className={`${styles.header__legend} mt-2`}>
              <Image
                src="/icon/download.svg"
                alt="Download icon"
                className="mr-2"
                width={24}
                height={24}
              />
              <p className={styles.header__state}>
                {t('tableCampaign.download')}
              </p>
            </div>
          </div>
        </div>
      </PageHeader>
      <TableCampaign tableList={tableData} />
    </Base>
  )
}

export default UserHome

The translations of UserHome and Base component, and the components inside Base are not working. The other pages are working correctly. Do you guys have any idea?

ezragul
  • 1
  • 2
  • how does your next-i18next config look like? – adrai Jan 25 '23 at 21:09
  • Hello! It looks like this: module.exports = { i18n: { defaultLocale: 'en', locales: ['en', 'es'] }, localePath: './locales' } – ezragul Jan 25 '23 at 21:51
  • you may need to adapt the localePath: https://github.com/i18next/next-i18next#vercel-and-netlify – adrai Jan 25 '23 at 22:43
  • @adrai this works! Thanks a lot! I used this config you mentioned and transfered the locales to public folder. // eslint-disable-next-line @typescript-eslint/no-var-requires const path = require('path') module.exports = { i18n: { defaultLocale: 'en', locales: ['en', 'es'] }, localePath: path.resolve('./public/locales') } – ezragul Jan 26 '23 at 17:29

0 Answers0