added the SetNewLanguage function

This commit is contained in:
Alfred Kamanda 2024-09-16 16:03:16 +03:00
parent 3a7c3ffc67
commit 353c38be46
Signed by: Alfred-mk
GPG Key ID: 7EA3D01708908703
5 changed files with 23 additions and 0 deletions

View File

@ -116,6 +116,7 @@ func getHandler(appFlags *asm.FlagParser, rs *resource.DbResource, userdataStore
rs.AddLocalFunc("reset_incorrect_date_format", ussdHandlers.ResetIncorrectYob)
rs.AddLocalFunc("set_reset_single_edit", ussdHandlers.SetResetSingleEdit)
rs.AddLocalFunc("initiate_transaction", ussdHandlers.InitiateTransaction)
rs.AddLocalFunc("set_new_language", ussdHandlers.SetNewLanguage)
return ussdHandlers, nil
}

View File

@ -86,6 +86,7 @@ func getHandler(appFlags *asm.FlagParser, rs *resource.DbResource, userdataStore
rs.AddLocalFunc("reset_incorrect_date_format", ussdHandlers.ResetIncorrectYob)
rs.AddLocalFunc("set_reset_single_edit", ussdHandlers.SetResetSingleEdit)
rs.AddLocalFunc("initiate_transaction", ussdHandlers.InitiateTransaction)
rs.AddLocalFunc("set_new_language", ussdHandlers.SetNewLanguage)
return ussdHandlers, nil
}

View File

@ -76,6 +76,7 @@ func getHandler(appFlags *asm.FlagParser, rs *resource.DbResource, userdataStore
rs.AddLocalFunc("reset_incorrect_date_format", ussdHandlers.ResetIncorrectYob)
rs.AddLocalFunc("set_reset_single_edit", ussdHandlers.SetResetSingleEdit)
rs.AddLocalFunc("initiate_transaction", ussdHandlers.InitiateTransaction)
rs.AddLocalFunc("set_new_language", ussdHandlers.SetNewLanguage)
return ussdHandlers, nil
}

View File

@ -71,6 +71,7 @@ func getHandler(appFlags *asm.FlagParser, rs *resource.DbResource, pe *persist.P
rs.AddLocalFunc("reset_incorrect_date_format", ussdHandlers.ResetIncorrectYob)
rs.AddLocalFunc("set_reset_single_edit", ussdHandlers.SetResetSingleEdit)
rs.AddLocalFunc("initiate_transaction", ussdHandlers.InitiateTransaction)
rs.AddLocalFunc("set_new_language", ussdHandlers.SetNewLanguage)
return ussdHandlers, nil
}

View File

@ -968,3 +968,22 @@ func (h *Handlers) GetProfileInfo(ctx context.Context, sym string, input []byte)
return res, nil
}
// SetNewLanguage sets the new language based on user input
func (h *Handlers) SetNewLanguage(ctx context.Context, sym string, input []byte) (resource.Result, error) {
var res resource.Result
inputStr := string(input)
switch inputStr {
case "0":
res.FlagSet = append(res.FlagSet, state.FLAG_LANG)
res.Content = "eng"
case "1":
res.FlagSet = append(res.FlagSet, state.FLAG_LANG)
res.Content = "swa"
default:
}
return res, nil
}