Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions bot/ordersActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,14 @@ const buildDescription = (

const ageInDays = getUserAge(user);

const firstLine = getOrderTitleMessage(user, type, i18n);
const firstLine = getOrderTitleMessage(
user,
type,
amount,
fiatCode,
priceFromAPI,
i18n,
);

let description: string = `${firstLine}\n`;
description += i18n.t('for') + ` ${currencyString}\n`;
Expand All @@ -269,19 +276,30 @@ const buildDescription = (
const getOrderTitleMessage = (
user: UserDocument,
type: string,
orderAmount: number,
fiatCode: string,
priceFromAPI: boolean,
i18n: I18nContext,
) => {
const isSell = type === 'sell';
// Fixed-price orders show the sats volume in the title; market-price orders
// don't, since the sats amount is not known until the order is taken.
const amount = priceFromAPI ? '' : numberFormat(fiatCode, orderAmount);
Comment thread
coderabbitai[bot] marked this conversation as resolved.

// Guard Clause: The user DOES want to show their name, we resolve and leave.
let title: string;
if (user.show_username) {
return isSell
? i18n.t('showusername_selling_sats', { username: user.username })
: i18n.t('showusername_buying_sats', { username: user.username });
title = isSell
? i18n.t('showusername_selling_sats', { username: user.username, amount })
: i18n.t('showusername_buying_sats', { username: user.username, amount });
} else {
title = isSell
? i18n.t('selling_sats', { amount })
: i18n.t('buying_sats', { amount });
}

// The user DOES NOT want to show their name.
return isSell ? i18n.t('selling_sats') : i18n.t('buying_sats');
// Collapse any double spaces left when amount is empty (market orders) so the
// result is clean regardless of where translators place the ${amount} slot.
return title.replace(/\s+/g, ' ').trim();
};

const getOrder = async (
Expand Down
8 changes: 4 additions & 4 deletions locales/de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -452,11 +452,11 @@ pending_payment_failed_to_admin: |
Zahlungsversuche: ${attempts}
selling: Verkaufe
buying: Kaufe
selling_sats: Verkaufe Sats
buying_sats: Kaufe Sats
selling_sats: 'Verkaufe ${amount} Sats'
buying_sats: 'Kaufe ${amount} Sats'
receive_payment: Zahlung erhalten
showusername_buying_sats: '@${username} kauft Sats'
showusername_selling_sats: '@${username} verkauft Sats'
showusername_buying_sats: '@${username} kauft ${amount} Sats'
showusername_selling_sats: '@${username} verkauft ${amount} Sats'
pay: Bezahlen
is: ist
trading_volume: 'Handelsvolumen: ${Volumen} Sats'
Expand Down
8 changes: 4 additions & 4 deletions locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -459,10 +459,10 @@ pending_payment_failed_to_admin: |
Payment attempts: ${attempts}
selling: Selling
buying: Buying
selling_sats: Selling sats
buying_sats: Buying sats
showusername_selling_sats: '@${username} is selling sats'
showusername_buying_sats: '@${username} is buying sats'
selling_sats: 'Selling ${amount} sats'
buying_sats: 'Buying ${amount} sats'
showusername_selling_sats: '@${username} is selling ${amount} sats'
showusername_buying_sats: '@${username} is buying ${amount} sats'
receive_payment: Receive payment
pay: Pay
is: is
Expand Down
8 changes: 4 additions & 4 deletions locales/es.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -454,10 +454,10 @@ pending_payment_failed_to_admin: |
Intento de pago: ${attempts}
selling: Vendiendo
buying: Comprando
selling_sats: Vendiendo sats
buying_sats: Comprando sats
showusername_buying_sats: '@${username} está comprando sats'
showusername_selling_sats: '@${username} está vendiendo sats'
selling_sats: 'Vendiendo ${amount} sats'
buying_sats: 'Comprando ${amount} sats'
showusername_buying_sats: '@${username} está comprando ${amount} sats'
showusername_selling_sats: '@${username} está vendiendo ${amount} sats'
receive_payment: Recibo pago
pay: Pago
is: está
Expand Down
8 changes: 4 additions & 4 deletions locales/fa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -535,14 +535,14 @@ pending_payment_failed_to_admin: |
تعداد تلاش‌های پرداخت: ${attempts}
selling: فروختن
buying: خریدن
selling_sats: فروش ساتوشی
buying_sats: خرید ساتوشی
selling_sats: 'فروش ${amount} ساتوشی'
buying_sats: 'خرید ${amount} ساتوشی'
receive_payment: دریافت وجه
pay: پرداخت
is: هست
trading_volume: 'حجم معاملات: ${volume} sat'
showusername_buying_sats: '@${username} در حال خرید ساتوشی است'
showusername_selling_sats: '@${username} در حال فروش ساتوشی است'
showusername_buying_sats: '@${username} در حال خرید ${amount} ساتوشی است'
showusername_selling_sats: '@${username} در حال فروش ${amount} ساتوشی است'
satoshis: ساتوشی‌ها
by: توسط
rate: نرخ
Expand Down
8 changes: 4 additions & 4 deletions locales/fr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -451,11 +451,11 @@ pending_payment_failed_to_admin: |
Tentatives de paiement : ${attempts}
selling: Vente
buying: Achat
selling_sats: Vente de sats
buying_sats: Achat de sats
selling_sats: 'Vente de ${amount} sats'
buying_sats: 'Achat de ${amount} sats'
receive_payment: Réception du paiement
showusername_buying_sats: "@${username} achète des sats"
showusername_selling_sats: "@${username} vend des sats"
showusername_buying_sats: "@${username} achète ${amount} sats"
showusername_selling_sats: "@${username} vend ${amount} sats"
pay: Payer
is: est
trading_volume: 'Volume de transactions : ${volume} sats'
Expand Down
8 changes: 4 additions & 4 deletions locales/it.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -449,14 +449,14 @@ pending_payment_failed_to_admin: |
Payment attempts: ${attempts}
selling: Vendita
buying: Acquisto
selling_sats: Vendita sats
buying_sats: Acquisto sats
selling_sats: 'Vendita ${amount} sats'
buying_sats: 'Acquisto ${amount} sats'
receive_payment: Ricezione del pagamento
pay: Paga
is: è
trading_volume: 'Volume scambio: ${volume} sats'
showusername_buying_sats: '@${username} sta comprando sats'
showusername_selling_sats: '@${username} sta vendendo sats'
showusername_buying_sats: '@${username} sta comprando ${amount} sats'
showusername_selling_sats: '@${username} sta vendendo ${amount} sats'
satoshis: satoshi
by: da
rate: Valutazione
Expand Down
8 changes: 4 additions & 4 deletions locales/ko.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -449,14 +449,14 @@ pending_payment_failed_to_admin: |

selling: 팝니다
buying: 삽니다
selling_sats: sats 판매
buying_sats: sats 구매
selling_sats: '${amount} sats 판매'
buying_sats: '${amount} sats 구매'
receive_payment: 입금
pay: 결제
is: is
trading_volume: '거래량: ${volume} sats'
showusername_buying_sats: '@${username} 님이 sats를 구매합니다'
showusername_selling_sats: '@${username} 님이 sats를 판매합니다'
showusername_buying_sats: '@${username} 님이 ${amount} sats를 구매합니다'
showusername_selling_sats: '@${username} 님이 ${amount} sats를 판매합니다'
satoshis: 사토시
by: 방법 -
rate: 환율
Expand Down
8 changes: 4 additions & 4 deletions locales/pt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -451,12 +451,12 @@ pending_payment_failed_to_admin: |
Tentativas de pagamento: ${attempts}
selling: Vendendo
buying: Comprando
selling_sats: Vendendo sats
buying_sats: Comprando sats
selling_sats: 'Vendendo ${amount} sats'
buying_sats: 'Comprando ${amount} sats'
receive_payment: Receber pagamento
pay: Pagar
showusername_buying_sats: '@${username} está comprando sats'
showusername_selling_sats: '@${username} está vendendo sats'
showusername_buying_sats: '@${username} está comprando ${amount} sats'
showusername_selling_sats: '@${username} está vendendo ${amount} sats'
is: é
trading_volume: 'Volume de negócios: ${volume} sats'
satoshis: satoshis
Expand Down
8 changes: 4 additions & 4 deletions locales/ru.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -452,11 +452,11 @@ pending_payment_failed_to_admin: |
Попытка оплаты: ${attempts}
selling: Продаю
buying: Покупаю
selling_sats: Продажа сат
buying_sats: Покупка сат
selling_sats: 'Продажа ${amount} сат'
buying_sats: 'Покупка ${amount} сат'
receive_payment: Расчет
showusername_buying_sats: '@${username} покупает саты'
showusername_selling_sats: '@${username} продает саты'
showusername_buying_sats: '@${username} покупает ${amount} саты'
showusername_selling_sats: '@${username} продает ${amount} саты'
pay: Расчет
is: Я
trading_volume: 'Обьем торгов: ${volume} сат'
Expand Down
8 changes: 4 additions & 4 deletions locales/uk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -449,14 +449,14 @@ pending_payment_failed_to_admin: |
Спроб оплати: ${attempts}
selling: Продаю
buying: Купую
selling_sats: Продаж сатоші
buying_sats: Купівля сатоші
selling_sats: 'Продаж ${amount} сатоші'
buying_sats: 'Купівля ${amount} сатоші'
receive_payment: Розрахунок
pay: Оплата
is: є
trading_volume: 'Обсяг торгів: ${volume} сат'
showusername_buying_sats: '@${username} купує сатоші'
showusername_selling_sats: '@${username} продає сатоші'
showusername_buying_sats: '@${username} купує ${amount} сатоші'
showusername_selling_sats: '@${username} продає ${amount} сатоші'
satoshis: сатоші
by: за допомогою
rate: Kурс
Expand Down
Loading