Random Sutta Getter — r.ReadingFaithfully.org

Is it on purpose that verses are shown as indented paragraphs, not line by line?

Nope! Another bug. Thanks! I think I fixed one thing and broke another.

1 Like

Ayya @sabbamitta, could you try out this app again?

The way it works now, you will see a . . . while it is looking for a sutta you have translated. If you open up the console you will see a notice when it tries to load a sutta that doesn’t exist. But the end user won’t see anything. Nothing needs to be changed in the app when you add new translations. All that happens is that as you get closer to a complete translation of the canon, it will take the app less time to find a translated sutta.

I’m on a fairly slow internet connection and it doesn’t feel like I’m waiting any longer for one of your suttas to pop up than for one of Bhante Sujato’s.

1 Like

Looks great, thank you! If you are very attentive you may notice that sometimes it takes a little longer, at other times it is perhaps slightly faster. Really hardly noticeable.

1 Like

It appears that German is the only language besides English that has even close to 50% translated. So I may not actually internationalize the app. But maybe? I’m not sure.

1 Like

I love it. Thank you !
I was overusing Random Sutta from ATI.
Now we can have access to more suttas from SN.

:smile:

In case you want to keep the German I would like to post it on Dhammaregen and make folks aware in the next newsletter. If that’s not too much work it would be nice to have the text in German in that case. But at least please replace “Bhikkhu Sujato” at the bottom by “Sabbamitta”. :wink:

(Note: Like you, I personally don’t consider a random sutta app as essential, but people seem to like it. And as you already did the work to build a German one, it would just be nice to use it.

Germans do already have the “Such mir etwas aus” button on Dhammaregen, but that’s not really random; it is guided by meaningful search phrases compiled by humans.)

1 Like

I see that Dhammaregen is actually a github site. In that case maybe you could just add the files from my repo to your repo. Once there you could translate everything into German. I’m happy to help in any way.

I have now put all the text that needs to be translated at the top of the main js file.

// BUILDING YOUR OWN VERSION OF THIS APP
// [ ] remove Google Tracking Script from end of index.html
// [ ] update <meta> tags at top of index.html
// [ ] change language and translator as needed
const language = "en";
const translator = "sujato";
// [ ] below needs to be translated when changing to a new language
const disclaimer = "Disclaimer: This random sutta generator is not to be used to somehow get an answer from the universe as to what Dhamma we need to hear most at this moment in time. It's just code. Better to ask a good kalyanamitta what Dhamma you need to reflect on.";
const buttonText = "Random Sutta";
translatorInfo.innerText = "All translations are by Bhikkhu Sujato as found on SuttaCentral.net";

In theory that would mean that when I updated the app, you would just be able to copy paste that section of the code into the new version.

2 Likes

I am not exactly sure how to best do this. Dhammaregen is intimately intertwined with other ebt-sites (we haven’t done much publicity for them, because in many respects they haven’t reached a satisfactory state yet). Dhammaregen receives updates three times a day from the general ebt-site data stream via GitHub actions, which means any change that concerns the actual Sutta pages will only be possible in this context, otherwise we would create a big mess which I would be unable to resolve.

But … I am the total master over the “Wiki” section of Dhammaregen, and this is where I was thinking to post a link to your app. There is a section with other related ebt websites which would be a good place to add a page for it.

If it is possible to somehow install the app on such a page that would be a good possibility; but if not, a link would have to do.

Honestly I am not sure how that would work. I don’t have any experience with github pages.

For now (and forever if you like) we can use de.readingfaithfully.org. It’s live.

I have invited you to the repository on github. You should have gotten something by email asking you to accept. Then you can select the random-german branch and make the changes instructed in index.js, namely the translation. I’ve never added a collaborator before, so you will have to forgive me if it seems like I don’t know what I’m doing. Because I don’t!

Apologies to all the non-techie people trying to follow this thread. I’m leaving all this in on purpose so those who are curious can see how it is possible to work with the data of SC on projects like this.

1 Like

Bhante, could it be integrated into SC as a new functionality ?
In that way we could benefit from all other functionalities of SC (other languages, pali, dictionary…).

I think this is the best option. I really don’t know where exactly it would be safe to put files with another code into the Dhammaregen repository.

And thanks for inviting me to collaborate. I was already thinking to do the translation in your repository and create a pull request for you to merge—but now you have given me the whole burden of responsibility to mess up your entire thing! :scream_cat: Well … will do it carefully. :smile_cat:

I guess the index.js file is the one that needs to be changed. No, it seems to be in index.html.

2 Likes

Oh, I forgot that you could just branch and make a PR. Maybe you should just do that anyway. Just make sure you are doing it from the german branch.

The index.js has the instructions at the top. EDIT: There are things to change in index.js. There is also a small bit at the top of index.html, but index.js explains all that.

2 Likes

Okay, let me do it carefully.

  • “Remove Google tracking script from end of index.html”
    I take it this is this bit

    <script async src="https://www.googletagmanager.com/gtag/js?id=UA-120551088-1"></script>
     <script>
         window.dataLayer = window.dataLayer || [];
         function gtag() { dataLayer.push(arguments); }
         gtag('js', new Date());
    
         gtag('config', 'UA-120551088-1');
     </script>
    
  • “update/translate specified tags in at top of index.html”
    So this looks like this

    <!--CHANGE WHEN CHANGING LANGUAGE-->
     <title>Random Sutta Getter</title>
     <meta property="og:locale" content="de_de" />
     <meta property="og:title" content="Random Sutta Getter | ReadingFaithfully" />
     <meta property="og:description" content="Get a Random Sutta" />
     <meta property="og:image" itemprop="image"
         content="https://r.readingfaithfully.org/images/featuredimage-random-brown.png" />
    

    I am not going to change the URL.

  • “change language and translator below as needed”
    This appears to be

    // [ ] below needs to be translated when changing to a new language
    const disclaimer =
    "Disclaimer: This random sutta generator is not to be used to somehow get an answer from the universe as to what Dhamma we need to hear most at this moment in time. It’s just code. Better to ask a good kalyanamitta what Dhamma you need to reflect on.";
    clickInstruction.innerText = "Click to get a";
    const buttonText = "Random Sutta";
    translatorInfo.innerText = "All translations are by Bhikkhu Sujato as found on    SuttaCentral.net";
    getDaily.innerHTML = `Get a new sutta by email each day from <a href="http://daily.readingfaithfully.org" title="Daily Suttas" rel="noreferrer" target="_blank">Daily.ReadingFaithfully.org</a>`;
    // end of building your own version
    

Did I understand this correctly?

Perfectly!

I should have removed the tracking code, but I forgot to follow my own instructions!

If you don’t want to include the text about getting a new sutta (sorry, I’m not ready to commit to doing a German version of that🤣) then you can just make it

getDaily.innerHTML = ""

I’ll make the social sharing image based on the translation you do.

2 Likes

Yes, that’s what I did. if someone really wants daily English Suttas in their inbox they can always find it via the icons that are on the site. They show the text in English when hovering with the mouse, but as they are all in English anyway there’s probably no need to translate this too.

There are now 2 pull requests for you to merge:

Checks have passed, no merge conflicts. Please merge as you see fit.

The only thing I didn’t know what to do with is the “image”.

Congratulations on developing such coding expertise, it definitely works. But I‘m mystified as to the benefits. Or did I just pull a short straw? :wink:

4 Likes

Yes, that’s the nature of parts of the SN and AN. I guess someone could manually pull out all of those from the offering. Or maybe if the contents of the sutta is less than x characters it could be skipped. Or maybe if they end with a ?

Thoughts, anyone?

4 Likes

Done! How exciting.

I think I like your description in German better than the one in English! Also, I forgot to mention that you didn’t need to include the disclaimer. If you would rather not have that I don’t mind if you delete it.

Thank you! And thank you for all your hard work translating the suttas!

1 Like

Yes, thinking about it, I rather like to delete it. It’s sort of funny, but perhaps better without.

Thank you for your help to get this done! :pray:

1 Like