Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

172
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!