Skip to content

Commit 6eced05

Browse files
committed
feat: Update first line order description generation to improve translations
1 parent 875ede4 commit 6eced05

12 files changed

Lines changed: 309 additions & 26 deletions

File tree

bot/ordersActions.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,17 +203,13 @@ const buildDescription = (
203203
}: BuildDescriptionArguments,
204204
) => {
205205
try {
206-
const action = type === 'sell' ? i18n.t('selling') : i18n.t('buying');
207206
const hashtag = `#${type.toUpperCase()}${fiatCode}\n`;
208207
const paymentAction =
209208
type === 'sell' ? i18n.t('receive_payment') : i18n.t('pay');
210209
const trades = user.trades_completed;
211210
const volume = numberFormat(fiatCode, user.volume_traded);
212211
const totalRating = user.total_rating;
213212
const totalReviews = user.total_reviews;
214-
const username = user.show_username
215-
? `@${user.username} ` + i18n.t('is') + ` `
216-
: ``;
217213
const volumeTraded = user.show_volume_traded
218214
? i18n.t('trading_volume', { volume }) + `\n`
219215
: ``;
@@ -251,8 +247,10 @@ const buildDescription = (
251247

252248
const ageInDays = getUserAge(user);
253249

254-
let description =
255-
`${username}${action} ${amountText}` + i18n.t('sats') + `\n`;
250+
const firstLine = getOrderTitleMessage(user, type, i18n);
251+
252+
let description: string =
253+
`${firstLine}\n`;
256254
description += i18n.t('for') + ` ${currencyString}\n`;
257255
description += `${paymentAction} ` + i18n.t('by') + ` ${paymentMethod}\n`;
258256
description += i18n.t('has_successful_trades', { trades }) + `\n`;
@@ -268,6 +266,22 @@ const buildDescription = (
268266
}
269267
};
270268

269+
const getOrderTitleMessage = (user: UserDocument, type: string, i18n: I18nContext) => {
270+
const isSell = type === 'sell';
271+
272+
// Guard Clause: The user DOES want to show their name, we resolve and leave.
273+
if (user.show_username) {
274+
return isSell
275+
? i18n.t('showusername_selling_sats', { username: user.username })
276+
: i18n.t('showusername_buying_sats', { username: user.username });
277+
}
278+
279+
// The user DOES NOT want to show their name.
280+
return isSell
281+
? i18n.t('selling_sats')
282+
: i18n.t('buying_sats');
283+
};
284+
271285
const getOrder = async (
272286
ctx: MainContext,
273287
user: UserDocument,

issue712.diff

Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
diff --git a/bot/ordersActions.ts b/bot/ordersActions.ts
2+
index 8d63263..951c12e 100644
3+
--- a/bot/ordersActions.ts
4+
+++ b/bot/ordersActions.ts
5+
@@ -203,7 +203,6 @@ const buildDescription = (
6+
}: BuildDescriptionArguments,
7+
) => {
8+
try {
9+
- const action = type === 'sell' ? i18n.t('selling') : i18n.t('buying');
10+
const hashtag = `#${type.toUpperCase()}${fiatCode}\n`;
11+
const paymentAction =
12+
type === 'sell' ? i18n.t('receive_payment') : i18n.t('pay');
13+
@@ -211,9 +210,6 @@ const buildDescription = (
14+
const volume = numberFormat(fiatCode, user.volume_traded);
15+
const totalRating = user.total_rating;
16+
const totalReviews = user.total_reviews;
17+
- const username = user.show_username
18+
- ? `@${user.username} ` + i18n.t('is') + ` `
19+
- : ``;
20+
const volumeTraded = user.show_volume_traded
21+
? i18n.t('trading_volume', { volume }) + `\n`
22+
: ``;
23+
@@ -251,8 +247,10 @@ const buildDescription = (
24+
25+
const ageInDays = getUserAge(user);
26+
27+
- let description =
28+
- `${username}${action} ${amountText}` + i18n.t('sats') + `\n`;
29+
+ const firstLine = getOrderTitleMessage(user, type, i18n);
30+
+
31+
+ let description: string =
32+
+ `${firstLine}\n`;
33+
description += i18n.t('for') + ` ${currencyString}\n`;
34+
description += `${paymentAction} ` + i18n.t('by') + ` ${paymentMethod}\n`;
35+
description += i18n.t('has_successful_trades', { trades }) + `\n`;
36+
@@ -268,6 +266,22 @@ const buildDescription = (
37+
}
38+
};
39+
40+
+const getOrderTitleMessage = (user: UserDocument, type: string, i18n: I18nContext) => {
41+
+ const isSell = type === 'sell';
42+
+
43+
+ // Guard Clause: The user DOES want to show their name, we resolve and leave.
44+
+ if (user.show_username) {
45+
+ return isSell
46+
+ ? i18n.t('showusername_selling_sats', { username: user.username })
47+
+ : i18n.t('showusername_buying_sats', { username: user.username });
48+
+ }
49+
+
50+
+ // The user DOES NOT want to show their name.
51+
+ return isSell
52+
+ ? i18n.t('selling_sats')
53+
+ : i18n.t('buying_sats');
54+
+};
55+
+
56+
const getOrder = async (
57+
ctx: MainContext,
58+
user: UserDocument,
59+
diff --git a/locales/de.yaml b/locales/de.yaml
60+
index 1f64780..02690d7 100644
61+
--- a/locales/de.yaml
62+
+++ b/locales/de.yaml
63+
@@ -433,9 +433,11 @@ pending_payment_failed_to_admin: |
64+
Die Bezahlung der LN-Rechnung für den Auftrag ${orderId} des Benutzers @${username} ist fehlgeschlagen.
65+
66+
Zahlungsversuche: ${attempts}
67+
-selling: Verkaufe
68+
-buying: Kaufe
69+
+selling_sats: Verkaufe Sats
70+
+buying_sats: Kaufe Sats
71+
receive_payment: Zahlung erhalten
72+
+showusername_buying_sats: '@${username} kauft Sats'
73+
+showusername_selling_sats: '@${username} verkauft Sats'
74+
pay: Bezahlen
75+
is: ist
76+
trading_volume: 'Handelsvolumen: ${Volumen} Sats'
77+
diff --git a/locales/en.yaml b/locales/en.yaml
78+
index 3d88602..f912bf1 100644
79+
--- a/locales/en.yaml
80+
+++ b/locales/en.yaml
81+
@@ -439,8 +439,10 @@ pending_payment_failed_to_admin: |
82+
Payment of the invoice for the Buy order ${orderId} of user @${username} has failed.
83+
84+
Payment attempts: ${attempts}
85+
-selling: Selling
86+
-buying: Buying
87+
+selling_sats: Selling sats
88+
+buying_sats: Buying sats
89+
+showusername_selling_sats: '@${username} is selling sats'
90+
+showusername_buying_sats: '@${username} is buying sats'
91+
receive_payment: Receive payment
92+
pay: Pay
93+
is: is
94+
diff --git a/locales/es.yaml b/locales/es.yaml
95+
index 02715af..04b3cb6 100644
96+
--- a/locales/es.yaml
97+
+++ b/locales/es.yaml
98+
@@ -434,8 +434,10 @@ pending_payment_failed_to_admin: |
99+
El pago a la invoice de la compra Id: ${orderId} del usuario @${username} ha fallado!
100+
101+
Intento de pago: ${attempts}
102+
-selling: Vendiendo
103+
-buying: Comprando
104+
+selling_sats: Vendiendo sats
105+
+buying_sats: Comprando sats
106+
+showusername_buying_sats: '@${username} está comprando sats'
107+
+showusername_selling_sats: '@${username} está vendiendo sats'
108+
receive_payment: Recibo pago
109+
pay: Pago
110+
is: está
111+
diff --git a/locales/fa.yaml b/locales/fa.yaml
112+
index 3153077..fe8e1c2 100644
113+
--- a/locales/fa.yaml
114+
+++ b/locales/fa.yaml
115+
@@ -433,12 +433,14 @@ pending_payment_failed_to_admin: |
116+
پرداخت فاکتور سفارش خرید ${orderId} کاربر @${username} انجام نشد.
117+
118+
Payment attempts: ${attempts}
119+
-selling: فروش
120+
-buying: خرید
121+
+selling_sats: فروش ساتوشی
122+
+buying_sats: خرید ساتوشی
123+
receive_payment: دریافت وجه
124+
pay: پرداخت
125+
is: هست
126+
trading_volume: 'حجم معاملات: ${volume} sat'
127+
+showusername_buying_sats: '@${username} در حال خرید ساتوشی است'
128+
+showusername_selling_sats: '@${username} در حال فروش ساتوشی است'
129+
satoshis: ساتوشی‌ها
130+
by: توسط
131+
rate: نرخ
132+
diff --git a/locales/fr.yaml b/locales/fr.yaml
133+
index 15b4fe8..98a22ab 100644
134+
--- a/locales/fr.yaml
135+
+++ b/locales/fr.yaml
136+
@@ -432,9 +432,11 @@ pending_payment_failed_to_admin: |
137+
Le paiement de la facture pour l'offre d'achat ${orderId} de l'utilisateur @${username} a échoué.
138+
139+
Tentatives de paiement : ${attempts}
140+
-selling: Vente
141+
-buying: Achat
142+
+selling_sats: Vente de sats
143+
+buying_sats: Achat de sats
144+
receive_payment: Réception du paiement
145+
+showusername_buying_sats: "@${username} achète des sats"
146+
+showusername_selling_sats: "@${username} vent des sats"
147+
pay: Payer
148+
is: est
149+
trading_volume: 'Volume de transactions : ${volume} sats'
150+
diff --git a/locales/it.yaml b/locales/it.yaml
151+
index 60043fe..7ccebf4 100644
152+
--- a/locales/it.yaml
153+
+++ b/locales/it.yaml
154+
@@ -430,12 +430,14 @@ pending_payment_failed_to_admin: |
155+
Il pagamento della invoice per l'ordine di acquisto ${orderId} dell'utente @${username} è fallito.
156+
157+
Payment attempts: ${attempts}
158+
-selling: Vendita
159+
-buying: Acquisto
160+
+selling_sats: Vendita sats
161+
+buying_sats: Acquisto sats
162+
receive_payment: Ricezione del pagamento
163+
pay: Paga
164+
is: è
165+
trading_volume: 'Volume scambio: ${volume} sats'
166+
+showusername_buying_sats: '@${username} sta comprando sats'
167+
+showusername_selling_sats: '@${username} sta vendendo sats'
168+
satoshis: satoshi
169+
by: da
170+
rate: Valutazione
171+
diff --git a/locales/ko.yaml b/locales/ko.yaml
172+
index ce324ad..da04b01 100644
173+
--- a/locales/ko.yaml
174+
+++ b/locales/ko.yaml
175+
@@ -430,12 +430,14 @@ pending_payment_failed_to_admin: |
176+
177+
결제 시도 횟수: ${attempts}
178+
179+
-selling: 팝니다
180+
-buying: 삽니다
181+
+selling_sats: sats 판매
182+
+buying_sats: sats 구매
183+
receive_payment: 입금
184+
pay: 결제
185+
is: is
186+
trading_volume: '거래량: ${volume} sats'
187+
+showusername_buying_sats: '@${username} 님이 sats를 구매합니다'
188+
+showusername_selling_sats: '@${username} 님이 sats를 판매합니다'
189+
satoshis: 사토시
190+
by: 방법 -
191+
rate: 환율
192+
diff --git a/locales/pt.yaml b/locales/pt.yaml
193+
index bd3a5fa..61d3b83 100644
194+
--- a/locales/pt.yaml
195+
+++ b/locales/pt.yaml
196+
@@ -432,10 +432,12 @@ pending_payment_failed_to_admin: |
197+
Pagamento da fatura para o pedido de compra ${orderId} de usuário @${username} falhou.
198+
199+
Tentativas de pagamento: ${attempts}
200+
-selling: Vendendo
201+
-buying: Comprando
202+
+selling_sats: Vendendo sats
203+
+buying_sats: Comprando sats
204+
receive_payment: Receber pagamento
205+
pay: Pagar
206+
+showusername_buying_sats: '@${username} está comprando sats'
207+
+showusername_selling_sats: '@${username} está vendendo sats'
208+
is: é
209+
trading_volume: 'Volume de negócios: ${volume} sats'
210+
satoshis: satoshis
211+
diff --git a/locales/ru.yaml b/locales/ru.yaml
212+
index dea0cd9..a838f3a 100644
213+
--- a/locales/ru.yaml
214+
+++ b/locales/ru.yaml
215+
@@ -433,9 +433,11 @@ pending_payment_failed_to_admin: |
216+
Платеж по счету-фактуре на покупку с идентификатором ${orderId} пользователя @${username} не выполнен!
217+
218+
Попытка оплаты: ${attempts}
219+
-selling: Продаю
220+
-buying: Покупаю
221+
+selling_sats: Продажа сат
222+
+buying_sats: Покупка сат
223+
receive_payment: Расчет
224+
+showusername_buying_sats: '@${username} покупает саты'
225+
+showusername_selling_sats: '@${username} продает саты'
226+
pay: Расчет
227+
is: Я
228+
trading_volume: 'Обьем торгов: ${volume} сат'
229+
diff --git a/locales/uk.yaml b/locales/uk.yaml
230+
index 40e76f3..f0352a0 100644
231+
--- a/locales/uk.yaml
232+
+++ b/locales/uk.yaml
233+
@@ -430,12 +430,14 @@ pending_payment_failed_to_admin: |
234+
Платіж за рахунком-фактурою на покупку з ідентифікатором ${orderId} користувача @${username} не виконаний!
235+
236+
Спроб оплати: ${attempts}
237+
-selling: Продаю
238+
-buying: Купую
239+
+selling_sats: Продаж сатоші
240+
+buying_sats: Купівля сатоші
241+
receive_payment: Розрахунок
242+
pay: Оплата
243+
is: є
244+
trading_volume: 'Обсяг торгів: ${volume} сат'
245+
+showusername_buying_sats: '@${username} купує сатоші'
246+
+showusername_selling_sats: '@${username} продає сатоші'
247+
satoshis: сатоші
248+
by: за допомогою
249+
rate: Kурс

locales/de.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,9 +433,11 @@ pending_payment_failed_to_admin: |
433433
Die Bezahlung der LN-Rechnung für den Auftrag ${orderId} des Benutzers @${username} ist fehlgeschlagen.
434434
435435
Zahlungsversuche: ${attempts}
436-
selling: Verkaufe
437-
buying: Kaufe
436+
selling_sats: Verkaufe Sats
437+
buying_sats: Kaufe Sats
438438
receive_payment: Zahlung erhalten
439+
showusername_buying_sats: '@${username} kauft Sats'
440+
showusername_selling_sats: '@${username} verkauft Sats'
439441
pay: Bezahlen
440442
is: ist
441443
trading_volume: 'Handelsvolumen: ${Volumen} Sats'

locales/en.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,10 @@ pending_payment_failed_to_admin: |
439439
Payment of the invoice for the Buy order ${orderId} of user @${username} has failed.
440440
441441
Payment attempts: ${attempts}
442-
selling: Selling
443-
buying: Buying
442+
selling_sats: Selling sats
443+
buying_sats: Buying sats
444+
showusername_selling_sats: '@${username} is selling sats'
445+
showusername_buying_sats: '@${username} is buying sats'
444446
receive_payment: Receive payment
445447
pay: Pay
446448
is: is

locales/es.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,10 @@ pending_payment_failed_to_admin: |
434434
El pago a la invoice de la compra Id: ${orderId} del usuario @${username} ha fallado!
435435
436436
Intento de pago: ${attempts}
437-
selling: Vendiendo
438-
buying: Comprando
437+
selling_sats: Vendiendo sats
438+
buying_sats: Comprando sats
439+
showusername_buying_sats: '@${username} está comprando sats'
440+
showusername_selling_sats: '@${username} está vendiendo sats'
439441
receive_payment: Recibo pago
440442
pay: Pago
441443
is: está

locales/fa.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,12 +433,14 @@ pending_payment_failed_to_admin: |
433433
پرداخت فاکتور سفارش خرید ${orderId} کاربر @${username} انجام نشد.
434434
435435
Payment attempts: ${attempts}
436-
selling: فروش
437-
buying: خرید
436+
selling_sats: فروش ساتوشی
437+
buying_sats: خرید ساتوشی
438438
receive_payment: دریافت وجه
439439
pay: پرداخت
440440
is: هست
441441
trading_volume: 'حجم معاملات: ${volume} sat'
442+
showusername_buying_sats: '@${username} در حال خرید ساتوشی است'
443+
showusername_selling_sats: '@${username} در حال فروش ساتوشی است'
442444
satoshis: ساتوشی‌ها
443445
by: توسط
444446
rate: نرخ

locales/fr.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,11 @@ pending_payment_failed_to_admin: |
432432
Le paiement de la facture pour l'offre d'achat ${orderId} de l'utilisateur @${username} a échoué.
433433
434434
Tentatives de paiement : ${attempts}
435-
selling: Vente
436-
buying: Achat
435+
selling_sats: Vente de sats
436+
buying_sats: Achat de sats
437437
receive_payment: Réception du paiement
438+
showusername_buying_sats: "@${username} achète des sats"
439+
showusername_selling_sats: "@${username} vent des sats"
438440
pay: Payer
439441
is: est
440442
trading_volume: 'Volume de transactions : ${volume} sats'

locales/it.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,12 +430,14 @@ pending_payment_failed_to_admin: |
430430
Il pagamento della invoice per l'ordine di acquisto ${orderId} dell'utente @${username} è fallito.
431431
432432
Payment attempts: ${attempts}
433-
selling: Vendita
434-
buying: Acquisto
433+
selling_sats: Vendita sats
434+
buying_sats: Acquisto sats
435435
receive_payment: Ricezione del pagamento
436436
pay: Paga
437437
is: è
438438
trading_volume: 'Volume scambio: ${volume} sats'
439+
showusername_buying_sats: '@${username} sta comprando sats'
440+
showusername_selling_sats: '@${username} sta vendendo sats'
439441
satoshis: satoshi
440442
by: da
441443
rate: Valutazione

0 commit comments

Comments
 (0)