Open JarlPenguin opened 2 weeks ago
Great idea, I think this should be possible!
Sessility already reads motile and sessile messages as translatable text components. However, it normalizes these components to strings before broadcasting them to players, which prevents localization on a per-player basis. This was done so that older formatting codes could be used to add style to the motile and sessile messages, since translatable text arguments would override the style defined by formatting codes.
In order for the keys of translatable text components to display properly, this string normalization would need to be removed and each client would need a translation file resource, which may require the use of a resource pack. Mods such as Nucleoid's Server Translations should allow the server to parse translatable text components based on a client's self-reported language, avoiding the need for a mandatory server resource pack.
Instead of using the old text formatting code for motile and sessile messages, I think it would be a good idea to instead utilize the newer JSON representation of text components. Translation keys could then be specified in translatable text components, which would then have corresponding strings either in a server resource pack or on the server with something like Nucleoid's Server Translations mod.
I've changed Sessility to use raw JSON text instead of strings for both sessile and motile messages. Try this build with the Server Translations mod and let me know if the changes work for your use case.
You'll first need to provide a raw JSON text string with translatable contents for the message-motile
and message-sessile
properties. Make sure the :
character is escaped with a backslash character. For example, the sessility.properties
file might look something like this:
message-motile={"translate"\:"multiplayer.player.motile","color"\:"yellow"}
message-sessile={"translate"\:"multiplayer.player.sessile","color"\:"yellow"}
Then, you will need to create a custom datapack with the translation files and place it in the server's datapacks
directory. For example, your server's working directory might look something like this:
<server-working-directory>
|- config
|- log
|- mods
|- world
| |- advancements
| |- data
| |- datapacks
| | |- <my-pack>
| | |- data
| | | |- <my-namespace>
| | | |- lang
| | | |- en_pt.json
| | | |- en_us.json
| | | |- ...
| | |
| | |- pack.mcmeta
| |
| |- ...
|
|- ...
Each translation file might look something like this:
{
"multiplayer.player.motile": "%s be movin' again!",
"multiplayer.player.sessile": "%s be like a sponge"
}
{
"multiplayer.player.motile": "%s is no longer AFK",
"multiplayer.player.sessile": "%s is AFK"
}
I'll try this a bit later today.
Would it be possible to support translating the motile/sessile messages into different languages?