Merge branch 'juliancoffee/better-i18n-keys' into 'master'

Remake price-tips internationalization

See merge request veloren/veloren!3571
This commit is contained in:
Marcel 2022-08-29 12:18:36 +00:00
commit 60f05f45a7
2 changed files with 23 additions and 20 deletions

View File

@ -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 = <Shift-Click to Add/Remove from trade.>
hud-trade-tooltip_hint_2 = <Ctrl-Click to Auto-Balance with this.>
hud-trade-your_offer = Your offer
hud-trade-their_offer = Their offer
hud-trade-amount_input = Select an item
hud-trade-amount_input = Select an item

View File

@ -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<SitePrices>,
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,