Localize group & trade invite answers

This commit is contained in:
coffee-compiler 2024-07-27 22:06:49 +00:00 committed by Marcel
parent 127c0ce0aa
commit a731d85c83
3 changed files with 24 additions and 12 deletions

View File

@ -1,6 +1,11 @@
hud-group = Group hud-group = Group
hud-group-invite_to_join = [{ $name }] invited you to their group! hud-group-invite_to_join = [{ $name }] invited you to their group!
hud-group-invite_to_trade = [{ $name }] would like to trade with you. hud-group-invite_to_trade = [{ $name }] would like to trade with you.
hug-group-invite-accepted = { $target } accepted your group invite.
hud-group-invite-declined = { $target } declined your group invite.
hud-group-invite-timed_out= Group invite to { $target } timed out.
hud-group-invite = Invite hud-group-invite = Invite
hud-group-kick = Kick hud-group-kick = Kick
hud-group-assign_leader = Assign Leader hud-group-assign_leader = Assign Leader

View File

@ -12,7 +12,12 @@ hud-trade-has_accepted =
has accepted has accepted
hud-trade-accept = Accept hud-trade-accept = Accept
hud-trade-decline = Decline hud-trade-decline = Decline
hud-trade-invite_sent = Trade request sent to { $playername }. hud-trade-invite_sent = Trade request sent to { $playername }.
hud-trade-invite-accepted = { $target } accepted your trade request.
hud-trade-invite-declined = { $target } declined your trade request.
hud-trade-invite-timed_out = Trade request to { $target } timed out.
hud-trade-result-completed = Trade completed successfully. hud-trade-result-completed = Trade completed successfully.
hud-trade-result-declined = Trade declined. hud-trade-result-declined = Trade declined.
hud-trade-result-nospace = Not enough space to complete the trade. hud-trade-result-nospace = Not enough space to complete the trade.

View File

@ -302,12 +302,6 @@ impl SessionState {
answer, answer,
kind, kind,
} => { } => {
// TODO: i18n (complicated since substituting phrases at this granularity may
// not be grammatical in some languages)
let kind_str = match kind {
InviteKind::Group => "Group",
InviteKind::Trade => "Trade",
};
let target_name = match client.player_list().get(&target) { let target_name = match client.player_list().get(&target) {
Some(info) => info.player_alias.clone(), Some(info) => info.player_alias.clone(),
None => match client.state().ecs().entity_from_uid(target) { None => match client.state().ecs().entity_from_uid(target) {
@ -320,13 +314,21 @@ impl SessionState {
None => format!("<uid {}>", target), None => format!("<uid {}>", target),
}, },
}; };
let answer_str = match answer {
InviteAnswer::Accepted => "accepted", let msg_key = match (kind, answer) {
InviteAnswer::Declined => "declined", (InviteKind::Group, InviteAnswer::Accepted) => "hud-group-invite-accepted",
InviteAnswer::TimedOut => "timed out", (InviteKind::Group, InviteAnswer::Declined) => "hud-group-invite-declined",
(InviteKind::Group, InviteAnswer::TimedOut) => "hud-group-invite-timed_out",
(InviteKind::Trade, InviteAnswer::Accepted) => "hud-trade-invite-accepted",
(InviteKind::Trade, InviteAnswer::Declined) => "hud-trade-invite-declined",
(InviteKind::Trade, InviteAnswer::TimedOut) => "hud-trade-invite-timed_out",
}; };
let msg = format!("{} invite to {} {}", kind_str, target_name, answer_str);
// TODO: Localise let msg = global_state
.i18n
.read()
.get_msg_ctx(msg_key, &i18n::fluent_args! { "target" => target_name });
self.hud.new_message(ChatType::Meta.into_plain_msg(msg)); self.hud.new_message(ChatType::Meta.into_plain_msg(msg));
}, },
client::Event::TradeComplete { result, trade: _ } => { client::Event::TradeComplete { result, trade: _ } => {