Hy,
I’m starting to use log messages in the server.
The server messages use template scripts. I would like all these messages to defined in a single file, avoiding duplicated messages and making them all more standard. However, since there are variables included in the messages, that doesn’t seem like a simple task.
Example:
NOW:
let date = new Date();
let userName= “John”;
console.log(Started at ${date}
);
console.log(Goodbye ${userName}
);
WISH:
code file:
let date = new Date();
let userName= “John”;
console.log(MSG.start);
console.log(MSG.bye);
msg file:
const MSG= { start: “Started at ${date}
”,
bye: “Goodbye ${userName}
” }
This seem similar to a i18n problem. However i18n usually does not work on the server.
Any thoughts?
Thanks,