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

173
Visualizações
Should I get a translated text string from a JSON or a function? discordJS bot

so, I'm making a discord bot, and I'll add the set-language feature, so I've to translate it in some languages, and for example:

return message.reply({
  content: `${message.author.username}, hello!`
});

will maybe become something like:

import langs from "some-path"
import getLang from "some-path"

const lang = await getLang("ID");
const text = langs[lang].<CommandName>.<TextIdentifier>; // e.g. "AUTHOR_USERNAME$, hello!"
const replyTxt = text.replace(/$AUTHOR_USERNAME$/g, message.author.username)
return message.reply({
  content: replyTxt
)

Or should I do something like:

  • langs-file:
export default function (
message_author_username?: string
// ...
) {
  this.<LangCode> = {
    <CommandName>: {
      <TextIdentifier>: `${message_author_username}, hello!`
      // Other texts...
    }
    // Other commands...
  }
  // Other languages...
}
  • command-file:
import langs from "some-path"
import getLang from "some-path"

const lang = await getLang("ID");
const replyTxt = langs(
  message_author_username: message.author.username,
  // Other used parameters...
  )[lang].<CommandName>.<TextIdentifier>;
return message.reply({
  content: replyTxt
)
about 4 years ago · Juan Pablo Isaza
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