Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

181
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda