Merge branch 'coffee-compiler/localize_invites' into 'master'

Localize group & trade invite answers

See merge request veloren/veloren!4535
This commit is contained in:
Marcel 2024-07-27 22:06:50 +00:00
commit 0e64ac29ad
3 changed files with 24 additions and 12 deletions

View File

@ -1,6 +1,11 @@
hud-group = Group
hud-group-invite_to_join = [{ $name }] invited you to their group!
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-kick = Kick
hud-group-assign_leader = Assign Leader

View File

@ -12,7 +12,12 @@ hud-trade-has_accepted =
has accepted
hud-trade-accept = Accept
hud-trade-decline = Decline
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-declined = Trade declined.
hud-trade-result-nospace = Not enough space to complete the trade.

View File

@ -302,12 +302,6 @@ impl SessionState {
answer,
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) {
Some(info) => info.player_alias.clone(),
None => match client.state().ecs().entity_from_uid(target) {
@ -320,13 +314,21 @@ impl SessionState {
None => format!("<uid {}>", target),
},
};
let answer_str = match answer {
InviteAnswer::Accepted => "accepted",
InviteAnswer::Declined => "declined",
InviteAnswer::TimedOut => "timed out",
let msg_key = match (kind, answer) {
(InviteKind::Group, InviteAnswer::Accepted) => "hud-group-invite-accepted",
(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));
},
client::Event::TradeComplete { result, trade: _ } => {