by 2 contributors:

/* get the page language */

var u = uri.parts(Page.uri);
var lang = string.tolower(u.path[0]);
if (string.contains(lang, "project") || string.contains(lang, "Project")) {
  lang = string.substr(lang, 8);
/* fall back to page.language on a user page */
else if (string.StartsWith(lang, "user:")) {
 lang = page.language;

var str = "Run Code";

// Localizers: add a case to this switch statement
// for your language

switch(lang) {
  case 'de':
    str = "Run Code";
  case 'zh-cn':
    str = "运行代码";

<a><span onclick='window.open("").document.write($("h3+pre")[1].textContent);' style="cursor:pointer; padding: 2px; border: solid 2px #333333; color: black; -moz-box-shadow:2px 2px 2px #191919; -webkit-box-shadow:2px 2px 2px #191919; -o-box-shadow:2px 2px 2px #191919; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; -o-border-radius: 5px; background:-moz-linear-gradient(76% 26% 142deg, #DCE3FF, #FFFFFF 47%);">(str)</span></a>
Search for pages that use Template:runcode to see example use cases and how many pages use this macro.

Document Tags and Contributors

Contributors to this page: trevorh, ziyunfei
Last updated by: trevorh,