[mod] Translate chat using commands [babelfish]

Post Reply
User avatar
taikedz
Member
Posts: 692
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake
Location: Scotland, UK
Contact:

[mod] Translate chat using commands [babelfish]

by taikedz » Post

License: LGPLv3.0

Requires being added to secure mods config due to making HTTPS calls to external translation service

Dependencies:
- security
- irc (optional)

Download:

github: https://github.com/taikedz-mt/babelfish
ZIP: https://github.com/taikedz-mt/babelfish ... master.zip
  • * Can be extended to use different web APIs
    * Currently uses Yandex to do the translation because it was the only free API I could get.
    * Can be used as an API for other mods
    * You MUST add babelfish to the `secure.trusted_mods` for it to work, as it makes calls out to the Internet.
Chatting

In its simplest form, players can simply do something like

Code: Select all

Hello everybody! %fr
and this will be transmitted to everybody as

Code: Select all

Bonjour tout le monde!
Other features are implemented as commands:

Code: Select all

    /babel {player}
        * Translates the last message from the specified player to your preferred language
        * Only you see the result of this
        * /babel mrGibberish

    /bblang {language}
        * Set your preferred language using a language code
        * Default is English

    /bb {language} {sentence}
        * Broadcasts a message in the target language (French in this case)
        * /bb fr My english sentence

    /bmsg {language} {player} {sentence}
        * Sends a private message to another player in the target language
        * /bmsg es spanishplayer I do not understand you, please use the translation commands

    /bbcodes
        * List the available language codes
Use as an API

Mod creators can leverage babelfish by using

Code: Select all

babel:translate( phrase_to_translate , language_code )
See README for more API notes
Last edited by taikedz on Fri Mar 02, 2018 16:15, edited 10 times in total.

User avatar
DS-minetest
Member
Posts: 1136
Joined: Thu Jun 19, 2014 19:49
GitHub: Desour
IRC: DS-minetest
In-game: DS
Location: I'm scared that if this is too exact, I will be unable to use my keyboard.

Re: [mod] Translate chat using commands [babelfish]

by DS-minetest » Post

nice!
Note that I've recently renamed myself on github and co. to "Desour". (I'm bad at naming things.)
Feel free to call me DS.

User avatar
taikedz
Member
Posts: 692
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake
Location: Scotland, UK
Contact:

Re: [mod] Translate chat using commands [babelfish]

by taikedz » Post

There are quite a few players of various languages on this server, and the mod is running. First day of it going live it seems to hold up well...

minetest.ducakedhare.co.uk : 30002

(Axinite)

If anyone wants to try it in the wild and feeback ....

User avatar
taikedz
Member
Posts: 692
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake
Location: Scotland, UK
Contact:

Re: [mod] Translate chat using commands [babelfish]

by taikedz » Post

** finally ** got around to fixing the issues preventing me implementing mod security

You can now turn on mod security and this should work fine. Sorry it took a while.

User avatar
octacian
Member
Posts: 594
Joined: Mon Dec 21, 2015 22:18
GitHub: octacian
IRC: octacian
In-game: octacian
Location: Canada

Re: [mod] Translate chat using commands [babelfish]

by octacian » Post

[DELETED]

Someone else was on my computer.
MicroExpansion, Working Computers, All Projects - Check out my YouTube channel! (octacian)
I'm currently inactive in the Minetest community! So if I don't respond, that's why.

User avatar
DS-minetest
Member
Posts: 1136
Joined: Thu Jun 19, 2014 19:49
GitHub: Desour
IRC: DS-minetest
In-game: DS
Location: I'm scared that if this is too exact, I will be unable to use my keyboard.

Re: [mod] Translate chat using commands [babelfish]

by DS-minetest » Post

This mod could be made clientside.
Note that I've recently renamed myself on github and co. to "Desour". (I'm bad at naming things.)
Feel free to call me DS.

User avatar
octacian
Member
Posts: 594
Joined: Mon Dec 21, 2015 22:18
GitHub: octacian
IRC: octacian
In-game: octacian
Location: Canada

Re: [mod] Translate chat using commands [babelfish]

by octacian » Post

In the future, yes, it'd work great client-side. At this point, though, it is best to remain as is. If I remember correctly, client-side MT still is missing and HTTP request API (and may never get one), and it does not have the features to properly intercept chat messages yet.
MicroExpansion, Working Computers, All Projects - Check out my YouTube channel! (octacian)
I'm currently inactive in the Minetest community! So if I don't respond, that's why.

User avatar
taikedz
Member
Posts: 692
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake
Location: Scotland, UK
Contact:

Re: [mod] Translate chat using commands [babelfish]

by taikedz » Post

I disagree about the client-sidedness of this:

For one, the code reaches out to the wider Internet (over HTTP), requiring privileged access. This is not something you want users to go trust blindly, and I doubt we'll be introducing code-signing on mods anytime soon (because a/ it defeats the paradigm of free modding and b/ nobody will care enough to check what they're accepting to run anyway)

Secondly, the server-side implementation of this ensures that translations happen once and then are broadcast, and it is possible to control what is displayed under what conditions, rather than a user simply spewing out a heap of translations from their client and telling the server who they are for. It's a game server, not an email relay.

Case in point, I'm still working on making it so that a babel-enabled chat message initiated from a sender is received in the right language for the recipient players, and only translating once per language.

There are other threads on the topic solely of client-side scripting, so I will not elaborate here.
Last edited by taikedz on Tue Mar 21, 2017 19:53, edited 1 time in total.

User avatar
azekill_DIABLO
Member
Posts: 7494
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

Re: [mod] Translate chat using commands [babelfish]

by azekill_DIABLO » Post

Good Jab Tai! (can i call you like this idk to write your name)

it might be very useful forinternational servers!

User avatar
taikedz
Member
Posts: 692
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake
Location: Scotland, UK
Contact:

Re: [mod] Translate chat using commands [babelfish]

by taikedz » Post

Yeah - International servers is the goal for this mod :-)

PS -Et bien sur appelle-moi Tai, c'est encore plus simple qu'un pseudo :-P

PPS - "jab" c'est un poinçon, ou un bonne gauche rapide dans les côtes ;-)

User avatar
azekill_DIABLO
Member
Posts: 7494
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

Re: [mod] Translate chat using commands [babelfish]

by azekill_DIABLO » Post

ha. oups. t'as du avoir mal :)

User avatar
taikedz
Member
Posts: 692
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake
Location: Scotland, UK
Contact:

Re: [mod] Translate chat using commands [babelfish]

by taikedz » Post

[comment deleted]
Last edited by taikedz on Tue Aug 01, 2017 08:01, edited 1 time in total.

Sporax
Member
Posts: 146
Joined: Mon Jul 11, 2016 16:33
GitHub: Sporax
IRC: Sporax
In-game: Sporax
Location: France

Re: [mod] Translate chat using commands [babelfish]

by Sporax » Post

Hello taikedz, i find a bug today on Axinite with this mod, i revoked priv shout to a player but he spoke to others thanks to /bb.
He could sent message with this command, can you change that please? :)

User avatar
taikedz
Member
Posts: 692
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake
Location: Scotland, UK
Contact:

Re: [mod] Translate chat using commands [babelfish]

by taikedz » Post

quick note to say this was fixed in commit/bea880cf .... I simply forgot to update this post :-/

User avatar
taikedz
Member
Posts: 692
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake
Location: Scotland, UK
Contact:

Re: [mod] Translate chat using commands [babelfish]

by taikedz » Post

I've updated babelfish to now have persistent translations !

As an API, persistent translations allow your mod to save a sentence to babelfish, and get translated versions of it back !

For example, a translated signs mod would allow players to write signs ; other players would be able to read them in their own language. For every language, a translation is stored, so that the item is only translated once. (If the sign is edited, it should clear the translations from the database...)

User avatar
azekill_DIABLO
Member
Posts: 7494
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

Re: [mod] Translate chat using commands [babelfish]

by azekill_DIABLO » Post

it's a particularly awesome mod!

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 3 guests