Hi everyone! I made a translator bot that translates statuses it's mentioned in.
To use it, mention @translator (email@example.com) in your status, followed by the two-letter code for the language you want to translate to (e.g. "ja" for Japanese) (full list of possible codes here: https://christopher.su/projects/translator/). It uses English if no language is given.
Give it a try and toot me your suggestions and comments!
11t now displays the timeline as paragraphs of clean text, and when you click a toot, you get a mock richtext view of the toot where usernames, links and hashtags are bold and clickable. It's far from perfect.
@dredmorbius Would do that for sure. I wonder if Mastodon might still send a notification to the author though. It might look at the parent toot id, check that toot, and then send a notification to its author. Need to manually test a reply toot that doesn't mention the author and see if it still notifies.
@dredmorbius Actually, another problem with this: the https://toot.works instance is essentially a single-user (+bots) instance. If the parent toot isn't federated to the instance, I'm not sure if the bot can fetch the parent toot's content to translate it. Any idea on how to fix it?
When browsing my timeline on toot.works, I frequently click on toots that are replies and I can't see the parent toot :/
@chris You might need to work around that. I'm not sure what the bot API looks like but:
1. Open the requestor's local instance of the request (e.g., <instance>/@<requestor>/<post-ID>
2. Look at the parent post, which should be the original.
3. Grab its timeline URL.
4. Search that on the bot instance. This adds the post to that instance.
I don't know that there's a streamlined way of doing this, but it would include the parent work, if you can make this happen.
@dredmorbius Ah, using the instance search through the API to pull in the post to the instance is brilliant. I hadn't thought of that.
Another approach that I thought of that could work: the "Get a status" API endpoint was changed to not require authentication in one of the more recent versions, so I could try calling that API directly on the other instance. Would only work if the other instance was on a new enough version that the API didn't require auth though.
Any way to integrate this differently? Eg, as a translate tab, so toots can have a "translate to xx" tab that I can enable/disable in settings, and which I could permanently enable for certain people who I follow.
This is more than awesome!!
@translator @bortzmeyer Figured that was the most likely case as mentioning @translator without any code defaults it to English. I wanted to reduce the number of unwanted translations without reducing the number of wanted translations.
Implementation-wise, it takes another API call to detect the source language before translating
Don't have a Patreon yet. The API does have a "free tier" of 2 million characters (though at this rate, I think we'll be reaching it soon). I might start a Patreon once it starts to become costly :)
@xdej I think that should be the only translation in the thread, at it is the only translation requested in the thread. If you mention @translator without specifying a language code after the mention, and your toot is already in English, it will not respond. If you do give a language, it will reply with the translation in that language: @translator zh-CHS
@ChristianD @cs @translator Yes, for now, it only translates the actual toot that it is mentioned in. I'm adding in translation for parent toots soon (so you can mention the translator in a reply and get a translation of the original toot). I didn't add it in initially because the translator uses a paid translation API and figured such a feature could see some heavy usage and get expensive.