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

215
Visualizações
How to let user switch displayed text language on page Node js Next js?

My client has a requirement for dual language on a web app. Users need to be able to toggle between French and English.

I added a button that toggles a state and sets a cookie so that I can remember their selection for next time.

What is the most efficient straight forward way to write the code to handle the user language preference, and display the correct language text on a page?

My current approach is to use an if Statement like this, to first check the State and render the text accordingly.

const [useLang, setLang] = useState('En')

(useLang == 'En') ? <p>English Text Here</p> : <p>French Text Here</p>

Would it be more efficient to try to get the English | French from a single source file, and if yes what should that look like, how should it be set up?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Next.js has built-in support for internationalized (i18n) routing since v10.0.0. You can provide a list of locales, the default locale, and domain-specific locales and Next.js will automatically handle the routing.

You can also disable the routing based translation and adjust it to state specific translation.

Complete documentation can be found here

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