There's an API in Chrome and Firefox (that I know of) that lets you get localized strings with variable replacements from a JSON file that you provide.

Example from the Mozilla docs:

var message = browser.i18n.getMessage("messageContent", target.url);
console.log(message);

This would work with a _locales/en/messages.json file containing:

{
  "messageContent": {
    "message": "You clicked $URL$.",
    "description": "Tells the user which link they clicked.",
    "placeholders": {
      "url" : {
        "content" : "$1",
        "example" : "https://developer.mozilla.org"
      }
    }
  }
}
Final thoughts

You can't force the language (it uses the one from the browser), which is annoying. Also, what that content attribute means and why it's there is anyone's guess. I, for one, don't see myself using this thing any time soon.

Previous on Javascript