diff --git a/assets/voxygen/i18n/en/hud/trade.ftl b/assets/voxygen/i18n/en/hud/trade.ftl index 396ac9d73a..f17762a3d7 100644 --- a/assets/voxygen/i18n/en/hud/trade.ftl +++ b/assets/voxygen/i18n/en/hud/trade.ftl @@ -16,11 +16,16 @@ hud-trade-invite_sent = Trade request sent to { $playername }. hud-trade-result-completed = Trade completed successfully. hud-trade-result-declined = Trade declined. hud-trade-result-nospace = Not enough space to complete the trade. -hud-trade-buy_price = Buy Price -hud-trade-sell_price = Sell Price -hud-trade-coin = coin(s) +hud-trade-buy = Buy Price: { $coin_num -> + [one] one coin + *[other] { $coin_formatted } coins +} +hud-trade-sell = Sell Price: { $coin_num -> + [one] one coin. + *[other] { $coin_formatted } coins +} hud-trade-tooltip_hint_1 = hud-trade-tooltip_hint_2 = hud-trade-your_offer = Your offer hud-trade-their_offer = Their offer -hud-trade-amount_input = Select an item \ No newline at end of file +hud-trade-amount_input = Select an item diff --git a/voxygen/src/hud/util.rs b/voxygen/src/hud/util.rs index bbe386c7fc..39cacb9d3b 100644 --- a/voxygen/src/hud/util.rs +++ b/voxygen/src/hud/util.rs @@ -13,14 +13,14 @@ use common::{ trade::{Good, SitePrices}, }; use conrod_core::image; -use i18n::Localization; +use i18n::{fluent_args, Localization}; use std::{borrow::Cow, fmt::Write}; -pub fn price_desc( +pub fn price_desc<'a>( prices: &Option, item_definition_id: ItemDefinitionId<'_>, - i18n: &Localization, -) -> Option<(String, String, f32)> { + i18n: &'a Localization, +) -> Option<(Cow<'a, str>, Cow<'a, str>, f32)> { if let Some(prices) = prices { if let Some(materials) = TradePricing::get_materials(&item_definition_id) { let coinprice = prices.values.get(&Good::Coin).cloned().unwrap_or(1.0); @@ -42,18 +42,16 @@ pub fn price_desc( / prices.values.get(&Good::Coin).cloned().unwrap_or(1.0) / (materials.len() as f32); let deal_goodness = deal_goodness.log(2.0); - let buy_string = format!( - "{} : {:0.1} {}", - i18n.get_msg("hud-trade-buy_price"), - buyprice / coinprice, - i18n.get_msg("hud-trade-coin"), - ); - let sell_string = format!( - "{} : {:0.1} {}", - i18n.get_msg("hud-trade-sell_price"), - sellprice / coinprice, - i18n.get_msg("hud-trade-coin"), - ); + + let buy_string = i18n.get_msg_ctx("hud-trade-buy", &fluent_args! { + "coin_num" => buyprice / coinprice, + "coin_formatted" => format!("{:0.1}", buyprice / coinprice), + }); + let sell_string = i18n.get_msg_ctx("hud-trade-sell", &fluent_args! { + "coin_num" => sellprice / coinprice, + "coin_formatted" => format!("{:0.1}", sellprice / coinprice), + }); + let deal_goodness = match deal_goodness { x if x < -2.5 => 0.0, x if x < -1.05 => 0.25,