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:
export default function (
message_author_username?: string
// ...
) {
this.<LangCode> = {
<CommandName>: {
<TextIdentifier>: `${message_author_username}, hello!`
// Other texts...
}
// Other commands...
}
// Other languages...
}
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
)