From 07df450b3c66e71caba203476e2678f880e57916 Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Thu, 21 Nov 2024 15:15:15 +0300 Subject: [PATCH 1/4] include labels to define the symbol and balance while selecting a voucher --- internal/handlers/ussd/menuhandler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/handlers/ussd/menuhandler.go b/internal/handlers/ussd/menuhandler.go index eeca3fd..bb63209 100644 --- a/internal/handlers/ussd/menuhandler.go +++ b/internal/handlers/ussd/menuhandler.go @@ -1570,7 +1570,7 @@ func (h *Handlers) ViewVoucher(ctx context.Context, sym string, input []byte) (r } res.FlagReset = append(res.FlagReset, flag_incorrect_voucher) - res.Content = fmt.Sprintf("%s\n%s", metadata.TokenSymbol, metadata.Balance) + res.Content = fmt.Sprintf("Symbol: %s\nBalance: %s", metadata.TokenSymbol, metadata.Balance) return res, nil } From b9ff467c0cb12b539c472c42a778e510a7570508 Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Thu, 21 Nov 2024 15:51:04 +0300 Subject: [PATCH 2/4] use the correct balance --- services/registration/my_balance_swa | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/registration/my_balance_swa b/services/registration/my_balance_swa index 9c3a7c7..afae8c1 100644 --- a/services/registration/my_balance_swa +++ b/services/registration/my_balance_swa @@ -1 +1 @@ -Salio lako ni: 0.00 SRF \ No newline at end of file +{{.check_balance}} \ No newline at end of file From e30bc177e96f0cba203c72c03065e854eb93a753 Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Thu, 21 Nov 2024 15:52:07 +0300 Subject: [PATCH 3/4] fixed typo and added a new translation --- services/registration/locale/swa/default.po | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/services/registration/locale/swa/default.po b/services/registration/locale/swa/default.po index aa033b5..4bf876b 100644 --- a/services/registration/locale/swa/default.po +++ b/services/registration/locale/swa/default.po @@ -13,7 +13,7 @@ msgstr "Kwa usaidizi zaidi,piga: 0757628885" msgid "Balance: %s\n" msgstr "Salio: %s\n" -msid "Your invite request for %s to Sarafu Network failed. Please try again later." +msgid "Your invite request for %s to Sarafu Network failed. Please try again later." msgstr "Ombi lako la kumwalika %s kwa matandao wa Sarafu halikufaulu. Tafadhali jaribu tena baadaye." msgid "Your invitation to %s to join Sarafu Network has been sent." @@ -23,4 +23,7 @@ msgid "Your request failed. Please try again later." msgstr "Ombi lako halikufaulu. Tafadhali jaribu tena baadaye." msgid "Community Balance: 0.00" -msgid "Salio la Kikundi: 0.00" +msgstr "Salio la Kikundi: 0.00" + +msgid "Symbol: %s\nBalance: %s" +msgstr "Sarafu: %s\nSalio: %s" From 7ce50398d1b829535f59a6f0e60c5c1c1c822c2b Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Thu, 21 Nov 2024 15:54:00 +0300 Subject: [PATCH 4/4] use the language translation instead of hardcoded eng --- internal/handlers/ussd/menuhandler.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/handlers/ussd/menuhandler.go b/internal/handlers/ussd/menuhandler.go index bb63209..98baf9d 100644 --- a/internal/handlers/ussd/menuhandler.go +++ b/internal/handlers/ussd/menuhandler.go @@ -817,7 +817,8 @@ func (h *Handlers) CheckBalance(ctx context.Context, sym string, input []byte) ( return res, err } - res.Content = l.Get("Balance: %s\n", fmt.Sprintf("%s %s", activeBal, activeSym)) + balStr := fmt.Sprintf("%s %s", activeBal, activeSym) + res.Content = l.Get("Balance: %s\n", balStr) return res, nil } @@ -1546,6 +1547,10 @@ func (h *Handlers) ViewVoucher(ctx context.Context, sym string, input []byte) (r return res, fmt.Errorf("missing session") } + code := codeFromCtx(ctx) + l := gotext.NewLocale(translationDir, code) + l.AddDomain("default") + flag_incorrect_voucher, _ := h.flagManager.GetFlag("flag_incorrect_voucher") inputStr := string(input) @@ -1570,7 +1575,7 @@ func (h *Handlers) ViewVoucher(ctx context.Context, sym string, input []byte) (r } res.FlagReset = append(res.FlagReset, flag_incorrect_voucher) - res.Content = fmt.Sprintf("Symbol: %s\nBalance: %s", metadata.TokenSymbol, metadata.Balance) + res.Content = l.Get("Symbol: %s\nBalance: %s", metadata.TokenSymbol, metadata.Balance) return res, nil }