Better architectural choices for chat
Currently, our chat code is, in my opinion, weirdly, split between client
and voxygen
crates.
Internationalisation interference
hud-chat-online_msg = [{ $name }] is online now
hud-chat-offline_msg = [{ $name }] went offline
hud-chat-default_death_msg = [{ $name }] died
hud-chat-environmental_kill_msg = [{ $name }] died in { $environment }
hud-chat-fall_kill_msg = [{ $name }] died from fall damage
hud-chat-suicide_msg = [{ $name }] died from self-inflicted wounds
As it is now, a crate that is responsible for inserting $name
, $environment
and other things is client
. But client
crate does not know anything about fluent files so we have the following code.
message.message = self
.localized_strings
.get_msg_ctx(template_key, &i18n::fluent_args! {
"attacker" => "{attacker}",
"name" => "{name}",
"died_of_buff" => "{died_of_buff}",
"victim" => "{victim}",
"environment" => "{environment}",
})
.into_owned();
message.message = self.client.format_message(&message, show_char_name);
message
So, first, we replace our fluent argument with the {} argument and then client.format_message
replaces the {} argument with what is necessary.
This basically means we do replace twice.
NPC internationalization
This is the kind of thing we can do only on the side of the front end, so having it in the client
crate blocks us from doing that.
Meta symbols
[MOD - You] Coffey: hey
In the snippet above, the only thing that voxygen does is just print that message.
Which prefix to use for Moderators, how to mark that message is sent by you and what "name" to use, how to format message, etc, all of that is handled by the client
crate. This means You
can't be internationalized, as well as MOD. By judging from the fact that client
can be used in frontends like voxygen
and teloren
and doesn't handle internalization, that's too fine-grained details to handle, and should be done on the frontend side.