use getText for external functions translation
This commit is contained in:
parent
3501a79aea
commit
16f00bcf09
@ -4,6 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"path"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -15,6 +16,12 @@ import (
|
|||||||
"git.grassecon.net/urdt/ussd/internal/handlers/server"
|
"git.grassecon.net/urdt/ussd/internal/handlers/server"
|
||||||
"git.grassecon.net/urdt/ussd/internal/models"
|
"git.grassecon.net/urdt/ussd/internal/models"
|
||||||
"git.grassecon.net/urdt/ussd/internal/utils"
|
"git.grassecon.net/urdt/ussd/internal/utils"
|
||||||
|
"gopkg.in/leonelquinteros/gotext.v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
scriptDir = path.Join( "services", "registration")
|
||||||
|
translationDir = path.Join(scriptDir, "locale")
|
||||||
)
|
)
|
||||||
|
|
||||||
type FSData struct {
|
type FSData struct {
|
||||||
@ -126,11 +133,9 @@ func (h *Handlers) SavePin(ctx context.Context, sym string, input []byte) (resou
|
|||||||
|
|
||||||
func (h *Handlers) SetResetSingleEdit(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
func (h *Handlers) SetResetSingleEdit(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||||
res := resource.Result{}
|
res := resource.Result{}
|
||||||
menuOPtion := string(input)
|
menuOption := string(input)
|
||||||
|
switch menuOption {
|
||||||
switch menuOPtion {
|
|
||||||
case "2":
|
case "2":
|
||||||
fmt.Println("Resetting unlock for update")
|
|
||||||
res.FlagReset = append(res.FlagSet, models.USERFLAG_UNLOCKFORUPDATE)
|
res.FlagReset = append(res.FlagSet, models.USERFLAG_UNLOCKFORUPDATE)
|
||||||
res.FlagSet = append(res.FlagSet, models.USERFLAG_SINGLE_EDIT)
|
res.FlagSet = append(res.FlagSet, models.USERFLAG_SINGLE_EDIT)
|
||||||
case "3":
|
case "3":
|
||||||
@ -685,11 +690,14 @@ func (h *Handlers) GetAmount(ctx context.Context, sym string, input []byte) (res
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// QuickWithBalance retrieves the balance for a given public key from the custodial balance API endpoint before
|
// QuickWithBalance retrieves the balance for a given public key from the custodial balance API endpoint before
|
||||||
// gracefully exiting the session.
|
// gracefully exiting the session.
|
||||||
func (h *Handlers) QuitWithBalance(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
func (h *Handlers) QuitWithBalance(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||||
res := resource.Result{}
|
res := resource.Result{}
|
||||||
|
code := codeFromCtx(ctx)
|
||||||
|
l := gotext.NewLocale(translationDir, code)
|
||||||
|
l.AddDomain("default")
|
||||||
accountData, err := h.accountFileHandler.ReadAccountData()
|
accountData, err := h.accountFileHandler.ReadAccountData()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
@ -698,7 +706,7 @@ func (h *Handlers) QuitWithBalance(ctx context.Context, sym string, input []byte
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
res.Content = fmt.Sprintf("Your account balance is: %s", balance)
|
res.Content = l.Get("Your account balance is %s", balance)
|
||||||
res.FlagReset = append(res.FlagReset, models.USERFLAG_ACCOUNT_UNLOCKED)
|
res.FlagReset = append(res.FlagReset, models.USERFLAG_ACCOUNT_UNLOCKED)
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
3
services/registration/locale/swa/default.po
Normal file
3
services/registration/locale/swa/default.po
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
msgid "Your account balance is %s"
|
||||||
|
msgstr "Salio lako ni %s"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user