Hi everyone! I made a translator bot that translates statuses it's mentioned in.

To use it, mention @translator ([email protected]) 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!

@translator ja
#MastoDev #Mastodon #Bots #Languages

@cs Would there be any chance of extending that to translate the /parent/ post into some specified language?

Say:

@translator parent fr

@dredmorbius Yeah, this has been the most requested feature now. I didn't add it in at first, because I didn't want spam notifications at the parent toot posters, but I suppose it wouldn't be too bad. Considering adding it! I would have to make it respect #nobot, probably.
@cs You could have translate bot /not/ mention the author of a toot.
@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.

@cs My understanding is that Notifs occur /only/ if the user is directly mentioned, or of a toot is favourited or boosted.

Otherwise, a post is added to a thread, but there's no notification generated.

@dredmorbius Good to know, thanks!

@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.