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 @translator that's damn awesome! Thanks!

@cs Ah. The fourth account :P

I assume it won't translate toots that are forwarded to it (i.e. someone replies to a toot and tags the bot), correct?

@jbbdude It does right now, which is kind of problematic... next item to fix is not tooting when the source language and translated language are the same.
@cs Wait, so if I reply to a foreign language toot (say, in Japanese) with "@translator en" it would translate the previous toot? That's amazing!

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

@cs I think this should be integrated into the UI, honestly. I don't want to toot something to get a translation and I *really* love "translate this"-buttons in other webapps :)
@Merovius You can use a translation browser extension for that! Problem with integrating it in the UI and translating lots of toots is programmatic translation is not cheap :(
@cs Saw at least one user request that the translator post using unlisted toots, so that the Federated (and Local) Timeline(s) don't get flooded by translations...

@cs Crap. Meant to include "but not sure if you saw that already" at the end of that toot.

Well, count this as a +1 on that request, then. Seems like a legit request to me.

@sendoshin Whoops, I should fix that. Hadn't seen that yet, thanks for bringing it to my attention! I'll fix it when I wake up in the morning :) (3 am here now)
@sendoshin This was keeping me up, so I just pushed the change 😛 Should be 'unlisted' now.
@cs I know that feeling all too well. 😁 Sleep well!

@cs @translator translation would be neat but I don't want to mention toots to find out what they say (if I understand how it works).

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.

@translator @cs I got my first Japanese follower today but there's no point me following back because I can't read any of their toots ☹
@translator @markhughes There are some browser extensions that will translate highlighted text for you (e.g. the Google Translate browser extension). You could use that to read translated toots and then use this to reply back quickly :)
@cs @translator thanks but I'm a Googlephobe because of how they track people and use that data in harmful ways.
@markhughes @translator Fair enough! This is also why it would be difficult to add translation to Mastodon itself or to clients though. Using a 3rd-party service raises privacy concerns. Not using a 3rd-party service would require probably GBs of trained translation models
@cs @translator I agree it's a tricky issue but some level of privacy could be introduced (translating text without exposing the URL for example). Using a browser plugin is a much bigger privacy concern I think.
@markhughes @translator Ah, I see what you mean. Agreed, a browser extension that's reading text off pages you visit/text you highlight is definitely much greater cause for concern.
@cs Very cool! Awesome work! This can be very handy
@cs @translator Hi Chris, which translation service do you use? This is not described on your project side.
Thanks
Wolfgang
@translator @cs Found the info in your timeline...
@translator @vilbi Ya, it's using the Microsoft Translation API. Going to update the project FAQ later to include this info
@cs Wondering, How hard would it be to ask the translator bot to translate a toot.
Like, hit reply, mention @ translator and: [previous] [ja]
Or @ translator with the URL of the toot
Both could be useful, just wondering :)
@hugo It wouldn't be too hard; and that's a highly requested feature, so I'm considering it!
@cs @translator fr
thanks for your useful work. Anyway which API is used for the translation ?
@yvesago [fr] @cs Merci pour votre travail utile. En tout cas quelle API est utilisée pour la traduction ?
@yvesago @translator I'm using the (paid) Microsoft Translation API.
@cs @translator
Re: " I'm using the (paid) Microsoft Translation API"
Thanks for the reply. Maybe you could add this in the status of translator. This could be important for some users.
@translator @yvesago Yup, planning on adding it to the FAQ soon
@cs @translator From french to spanish, "Jean" was translated by "John" (should have been "Juan" or, probably better, not translated)
@cs @translator A public issue tracker may be a good idea?
@translator @bortzmeyer Good idea, I'll get on that
@cs @translator When the toot is already in the target language, it is reproduced as is, *except* if the target language is english, where the toot is ignored.
@translator @bortzmeyer That's intentional. What do you think it should do?
@cs Why the difference between english and the other target languages? @translator yua