Plugin Translations

Is there currently any system/plugin/resource that allows to simply add translations to a plugin that’s able to get translations in player languages?

I searched the forums but can’t seem to find anything, so I wrote my own translation system right now, but before refining or even thinking about releasing it I wanted to ask if such a thing already exists and how complicated they are, if they exist.

Currently I thought of something like:
A plugin has to register with Language.loadLang(myPluginInstance).
Later on it has various ways to get translations like lang.locale("translation.name.string").resolve(player).orElse("no translation for that").
I also plan on automatically unload translations that are not needed and use a default language (Locale.getDefault()). A player could then switch language at any time with /language en_US or similar

This is not really a plugin request as I already started the plugin, and not really WIP as I won’t continue if such a plugin would be obsolete, so I’ll just post it here for now.

I had been working on something like that. Where it takes the player requested lanuage and translates all messages sent to the player. Mine was originally going to just request to talk to google api’s google cloud and request all translates from there. But you need a key these days to do that. So it quickly turned into a local translator library however all the java lanuage converter libraries i found that were none cloud based had issues (and a huge download). Thats why i cancelled my project on it.

That being said you could still use google translate. Just create a library (or use some free lib that does the same) to load the google translate webpage and get your plugin to parse in the original text and then your plugin collects the result. Im not sure if the google translate licence forbids you from doing that or something like it.

You also need to keep in mind latency of converting the lanuage. Sure you can do the whole thing asynced, so offline converting shouldn’t be that much of a issue. But if you are requesting cloud based translation there will be a noticeable delay. So my suggestion would be to let the original message travel though as normal and then your plugin sends a client only message to thouse who dont have that language set.

I would also suggest allowing players to set a primary lanuage and then other lanuages. Users can be multi lingual so instead of filling there chat with converted messages you send them the original message if its contained as one of there supported lanuages.

My approach would have been user translated where translation files for each plugin are loaded and unloaded as needed and, if a players choosen language is not available the server default would be used. Of course someone would have to go through your language file and be willing to translate it, but I think that shouldn’t be too much of a problem.

Basically as a player with certain language joins, the Locale gets available for all plugins. If a player disconnects and nobody else is using that locale on the server it unloads those translations.

OK, so now I just finished my translation plugin as a service, so I guess I’ll just post that in the Plugin Resources section…

There is a SpongeAPI PR in the works that may also be of relevance: Translation dictionary API. We’ve been waiting on this for quite a while…

1 Like

I also made my own translation plugin, though it could still use with quite a few improvements. RysingDragon / DragonTranslations.

The pr looks interesting but was last touched 5 montgs ago. It seems to go a similar direction to what I wrote yesterday.

DragonTranslations seems to require quite the preparation for it to work, wher i only require the plugin to get the service and register to it in order to be ready to go.

I’ll take a closer look at it and try to provide compatibility for translation files. (As I mentioned, I already wrote my own system now)

For all of my new plugins I just have a ‘messages’ section in the config(or separate file). They are texts or texttemplates, serialized by my custom type serializer: kosp/InstructionsForPluginUsers.md at master · randombyte-developer/kosp · GitHub

The admin can modify the messages as he likes. I provided for one plugin a translation into french to make it easier for users. Translation · randombyte-developer/claim-blocks Wiki · GitHub