Compare commits

...

2 Commits

Author SHA1 Message Date
8223a0b4d5
added translations for voucher selection
Some checks failed
release / docker (push) Has been cancelled
2026-02-04 17:02:50 +03:00
c57aa220e6
show a default message if the user only has 1 voucher 2026-02-04 17:02:24 +03:00
4 changed files with 23 additions and 5 deletions

View File

@ -181,8 +181,18 @@ func (h *MenuHandlers) GetVoucherList(ctx context.Context, sym string, input []b
return res, fmt.Errorf("missing session")
}
code := codeFromCtx(ctx)
l := gotext.NewLocale(translationDir, code)
l.AddDomain("default")
userStore := h.userdataStore
// Fetch session data
_, _, activeSym, _, _, _, err := h.getSessionData(ctx, sessionId)
if err != nil {
return res, nil
}
// Read vouchers from the store
voucherData, err := userStore.ReadEntry(ctx, sessionId, storedb.DATA_VOUCHER_SYMBOLS)
logg.InfoCtxf(ctx, "reading voucherData in GetVoucherList", "sessionId", sessionId, "key", storedb.DATA_VOUCHER_SYMBOLS, "voucherData", voucherData)
@ -191,6 +201,11 @@ func (h *MenuHandlers) GetVoucherList(ctx context.Context, sym string, input []b
return res, err
}
if len(voucherData) == 0 {
res.Content = l.Get("Your active voucher %s is already set", string(activeSym))
return res, nil
}
voucherBalances, err := userStore.ReadEntry(ctx, sessionId, storedb.DATA_VOUCHER_BALANCES)
logg.InfoCtxf(ctx, "reading voucherBalances in GetVoucherList", "sessionId", sessionId, "key", storedb.DATA_VOUCHER_BALANCES, "voucherBalances", voucherBalances)
if err != nil {
@ -203,7 +218,7 @@ func (h *MenuHandlers) GetVoucherList(ctx context.Context, sym string, input []b
logg.InfoCtxf(ctx, "final output for GetVoucherList", "sessionId", sessionId, "finalOutput", finalOutput)
res.Content = finalOutput
res.Content = l.Get("Select number or symbol from your vouchers:\n%s", finalOutput)
return res, nil
}

View File

@ -78,3 +78,9 @@ msgstr "Unaweza kuondoa kiwango cha juu cha %s %s kutoka kwenye '%s'\n\nWeka kiw
msgid "Please confirm that you will use %s %s to remove your debt of %s %s\n"
msgstr "Tafadhali thibitisha kwamba utatumia %s %s kulipa deni lako la %s %s.\nWeka PIN yako:"
msgid "Your active voucher %s is already set"
msgstr "Sarafu yako %s ishachaguliwa"
msgid "Select number or symbol from your vouchers:\n%s"
msgstr "Chagua nambari au ishara kutoka kwa sarafu zako:\n%s"

View File

@ -1,2 +1 @@
Select number or symbol from your vouchers:
{{.get_vouchers}}

View File

@ -1,2 +0,0 @@
Chagua nambari au ishara kutoka kwa salio zako:
{{.get_vouchers}}