Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

118
Visualizações
react-i18next ignores options parameter

I wanted to organize better the language translation files of my project having to nest objects in the language file.

  • Without nesting everything works fine
  • Even nesting objects I can access them by passing the attribute directory in the t() function (ie: t('section.subsection.text')
  • Documentation's solution doesn't work for me and I don't know why

I already tried printing the useTranslation instance to see if it was receiving the "keyPrefix" value but it always says 'undefined' either on the t or the fixedT function.

lang file is like this:

export const en = {
  section:{
    subsection:{
      text:'my text',
    }
  }
}

the file where I use the useTranslation hook:

const { t } = useTranslation('section', { keyPrefix: 'subsection' });

<h1>{t('text')}</h1>

this is taken from the documentation

// having resources like this:
/*{
  "translation": {
    "very": {
      "deeply": {
        "nested": {
          "key": "here"
        }
      }
    }
  }
}*/
// you can define a keyPrefix to be used for the resulting t function
const { t } = useTranslation('translation', { keyPrefix: 'very.deeply.nested' });
const text = t('key'); // "here"
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

I've updated Node.js from 12.14.0 to 14.19.0 when I had this exact issue.

about 4 years ago · Juan Pablo Isaza Relatório

0

I had an old node.js version.

Update it (nvm is a great tool for this) and voilà

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda