Suggestion: Automated Submissions For Sutta Translations

Oh, great. I find it extremely useful, but then again, I built it. (with much help from @Khemarato.bhikkhu). I also wrote a bookmarlet to scrape the urls from the results and create the text you see at the bottom of the daily sutta emails I put out. If you are interested, it’s this:

code
javascript: (() => {   const currentCitations = document.getElementsByClassName("url-button-link");    let numberOfItems = currentCitations.length;   let textLinks = [];   let audioLinks = [];   let textSites = ["SC", "SF", "DT", "ABT"];   let audioSites = ["PA", "SCV"];    for (let i = 0; i < numberOfItems; i++) {     const thisCitation = currentCitations[i].attributes.site.value;     const thisUrl = currentCitations[i].href;     if (textSites.includes(thisCitation)) {       textLinks.push([thisCitation, thisUrl]);     } else if (audioSites.includes(thisCitation)) {       audioLinks.push([thisCitation, thisUrl]);     }   }   function createTextSiteText(textLinks) {     let numberOfItems = textLinks.length;     let output = "";     for (let i = 0; i < numberOfItems; i++) {       let prettySiteUrl = "";       let endJoiner = "";       let currentSiteName = textLinks[i][0];       let currentSiteUrl = textLinks[i][1];        switch (currentSiteName) {         case "SC":           prettySiteUrl = "SuttaCentral.net";           break;         case "SF":           prettySiteUrl = "SuttaFriends.org";           break;         case "DT":           prettySiteUrl = "DhammaTalks.org";           break;         case "ABT":           prettySiteUrl = "Ancient-Buddhist-Texts.net";           break;         default:           prettySiteUrl = "Something went wrong";       }        if (i === numberOfItems - 1) {         endJoiner = ".";       } else if (i === numberOfItems - 2) {         endJoiner = " or ";       } else {         endJoiner = ", ";       }       output += `<a href="${currentSiteUrl}" rel="noreferrer" target="_blank">${prettySiteUrl}</a>${endJoiner}`;     }     return output;   }    function createAudioSiteText(audioLinks) {     let numberOfItems = audioLinks.length;     let output = "";     for (let i = 0; i < numberOfItems; i++) {       let prettySiteUrl = "";       let endJoiner = "";       let currentSiteName = audioLinks[i][0];       let currentSiteUrl = audioLinks[i][1];        switch (currentSiteName) {         case "PA":           prettySiteUrl = "PaliAudio.com";           break;         case "SCV":           prettySiteUrl = "Voice.SuttaCentral.net";           break;         default:           prettySiteUrl = "Something went wrong";       }        if (i === numberOfItems - 1) {         endJoiner = ".";       } else if (i === numberOfItems - 2) {         endJoiner = " or ";       } else {         endJoiner = ", ";       }        output += `<a href="${currentSiteUrl}" rel="noreferrer" target="_blank">${prettySiteUrl}</a>${endJoiner}`;     }     return output;   }    let finalOutput = `Or read a different translation on ${createTextSiteText(     textLinks   )} Or <i>listen</i> on ${createAudioSiteText(audioLinks)}`;   navigator.clipboard.writeText(finalOutput); })();

There is one issue, though. The numbering on DhammaTalks.org is, for some suttas in SN and AN, off by a little bit. I haven’t decided on a way to fix that. If you have any ideas or suggestions, please discuss it in the citation helper thread. And of course the limitation for my tool is that it has to be updated when new translations on those sites come out. But that’s a fairly rare occurrence.

It is integrated (kind of) with the name lookup tool I built, which you may also find helpful.

1 Like