Traduire messages d'erreurs en français
Il serait intéressant d'ajouter un méchanisme d'internationalisation des chaines.
This commit is contained in:
parent
660d8826e2
commit
bacd4d737e
3 changed files with 20 additions and 20 deletions
|
@ -47,7 +47,7 @@ func (a *ApiClient) Call(method, route string, requestBody io.Reader, useKey boo
|
|||
|
||||
if useKey {
|
||||
if a.Key == "" {
|
||||
return response, fmt.Errorf("Call to API required a key but none was provided. See --help for instructions on providing an API key.")
|
||||
return response, fmt.Errorf("L'appel au serveur API requiert une clé, mais aucune n'était donnée. Voir --help pour les instructions sur comment fournir une clé API.")
|
||||
}
|
||||
|
||||
request.Header.Add("Authorization", fmt.Sprintf("Bearer %s", a.Key))
|
||||
|
@ -87,7 +87,7 @@ func (a *ApiClient) GetHealth() (string, error) {
|
|||
}
|
||||
|
||||
if response.Message == "" {
|
||||
return response.Message, errors.New("Could not confirm that API server is up, no response message")
|
||||
return response.Message, errors.New("Impossible de confirmer l'état du serveur API.")
|
||||
}
|
||||
|
||||
return response.Message, nil
|
||||
|
|
|
@ -87,7 +87,7 @@ func (d *DataClient) InsertTransactions(transactions []models.Transaction) ([]mo
|
|||
// Check values
|
||||
if transaction.MembreID == "" {
|
||||
tx.Rollback()
|
||||
return rowsInserted, errors.New("Cannot insert transaction with no membre_id")
|
||||
return rowsInserted, errors.New("Impossible d'insérer une transaction sans membre_id")
|
||||
}
|
||||
|
||||
rows, err := tx.NamedQuery("INSERT INTO transactions (membre_id, given_at, is_perpetual) VALUES (:membre_id, current_timestamp, :is_perpetual) RETURNING id, membre_id, is_perpetual;", &transaction)
|
||||
|
@ -126,7 +126,7 @@ func (d *DataClient) GetTransaction(membreID string, is_perpetual bool) (models.
|
|||
}
|
||||
|
||||
if transaction.ID == "" {
|
||||
return transaction, fmt.Errorf("No transaction found")
|
||||
return transaction, fmt.Errorf("Aucune transaction trouvée")
|
||||
}
|
||||
|
||||
return transaction, nil
|
||||
|
|
|
@ -19,7 +19,7 @@ func GetTransactions(c echo.Context) error {
|
|||
|
||||
client, err := data.NewDataClientFromViper()
|
||||
if err != nil {
|
||||
response.Message = fmt.Sprintf("Error during data.NewDataClientFromViper(): %s", err)
|
||||
response.Message = fmt.Sprintf("Erreur pendant data.NewDataClientFromViper(): %s", err)
|
||||
|
||||
return c.JSON(statusCode, response)
|
||||
}
|
||||
|
@ -28,19 +28,19 @@ func GetTransactions(c echo.Context) error {
|
|||
transactions, err := client.ListTransactions()
|
||||
response.Data.Transactions = transactions
|
||||
if err != nil {
|
||||
response.Message = fmt.Sprintf("Error during client.ListTransactions(): %s", err)
|
||||
response.Message = fmt.Sprintf("Erreur pendant client.ListTransactions(): %s", err)
|
||||
|
||||
return c.JSON(statusCode, response)
|
||||
}
|
||||
|
||||
if len(transactions) == 0 {
|
||||
response.Message = "No transactions found"
|
||||
response.Message = "Aucune transaction trouvée"
|
||||
statusCode = http.StatusNotFound
|
||||
|
||||
return c.JSON(statusCode, response)
|
||||
}
|
||||
|
||||
response.Message = "List successful"
|
||||
response.Message = "Liste complétée"
|
||||
statusCode = http.StatusOK
|
||||
|
||||
return c.JSON(statusCode, response)
|
||||
|
@ -55,21 +55,21 @@ func PostTransactions(c echo.Context) error {
|
|||
|
||||
if err := c.Bind(&transactions); err != nil {
|
||||
statusCode = http.StatusBadRequest
|
||||
response.Message = fmt.Sprintf("Error during c.Bind(): %s", err)
|
||||
response.Message = fmt.Sprintf("Erreur pendant c.Bind(): %s", err)
|
||||
|
||||
return c.JSON(statusCode, response)
|
||||
}
|
||||
|
||||
client, err := data.NewDataClientFromViper()
|
||||
if err != nil {
|
||||
response.Message = fmt.Sprintf("Error during data.NewDataClientFromViper(): %s", err)
|
||||
response.Message = fmt.Sprintf("Erreur pendant data.NewDataClientFromViper(): %s", err)
|
||||
|
||||
return c.JSON(statusCode, response)
|
||||
}
|
||||
defer client.DB.Close()
|
||||
|
||||
if len(transactions) == 0 {
|
||||
response.Message = fmt.Sprintf("Nothing to do")
|
||||
response.Message = fmt.Sprintf("Rien à faire")
|
||||
statusCode = http.StatusOK
|
||||
|
||||
return c.JSON(statusCode, response)
|
||||
|
@ -91,20 +91,20 @@ func PostTransactions(c echo.Context) error {
|
|||
// Check if membre_id exists according to bottin
|
||||
for _, transaction := range transactions {
|
||||
if transaction.MembreID == "" {
|
||||
response.Message = fmt.Sprintf("Cannot insert transaction without a membre_id")
|
||||
response.Message = fmt.Sprintf("Impossible d'insérer une transaction sans membre_id (numéro étudiant)")
|
||||
statusCode = http.StatusBadRequest
|
||||
|
||||
return c.JSON(statusCode, response)
|
||||
}
|
||||
membre, err := bottinApiClient.GetMembre(transaction.MembreID)
|
||||
if err != nil {
|
||||
response.Message = fmt.Sprintf("Error during bottinApiClient.GetMembre(): %s", err)
|
||||
response.Message = fmt.Sprintf("Erreur pendant bottinApiClient.GetMembre(): %s", err)
|
||||
|
||||
return c.JSON(statusCode, response)
|
||||
}
|
||||
|
||||
if membre.ID == "" {
|
||||
response.Message = fmt.Sprintf("Cannot insert transaction for non-existent membre %s", membre.ID)
|
||||
response.Message = fmt.Sprintf("Aucun membre avec numéro étudiant '%s' dans le bottin de l'AGECEM", membre.ID)
|
||||
statusCode = http.StatusNotFound
|
||||
|
||||
return c.JSON(statusCode, response)
|
||||
|
@ -118,17 +118,17 @@ func PostTransactions(c echo.Context) error {
|
|||
transaction, err := client.GetTransaction(transaction.MembreID, transaction.IsPerpetual)
|
||||
if err != nil {
|
||||
if err.Error() != "sql: no rows in result set" {
|
||||
response.Message = fmt.Sprintf("Error during client.GetTransaction(): %s", err)
|
||||
response.Message = fmt.Sprintf("Erreur pendant client.GetTransaction(): %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
if transaction.ID != "" {
|
||||
agendaType := "non-perpetual"
|
||||
agendaType := "non-perpétuel"
|
||||
if transaction.IsPerpetual {
|
||||
agendaType = "perpetual"
|
||||
agendaType = "perpétuel"
|
||||
}
|
||||
|
||||
response.Message = fmt.Sprintf("Membre %s already received %s", transaction.MembreID, agendaType)
|
||||
response.Message = fmt.Sprintf("Membre %s a déjà son agenda %s", transaction.MembreID, agendaType)
|
||||
|
||||
statusCode = http.StatusBadRequest
|
||||
|
||||
|
@ -139,13 +139,13 @@ func PostTransactions(c echo.Context) error {
|
|||
insertedTransactions, err := client.InsertTransactions(transactions)
|
||||
response.Data.Transactions = insertedTransactions
|
||||
if err != nil {
|
||||
response.Message = fmt.Sprintf("Error during client.InsertTransactions(): %s", err)
|
||||
response.Message = fmt.Sprintf("Erreur pendant client.InsertTransactions(): %s", err)
|
||||
|
||||
return c.JSON(statusCode, response)
|
||||
}
|
||||
|
||||
statusCode = http.StatusCreated
|
||||
response.Message = "Insert successful"
|
||||
response.Message = "Insertion complétée"
|
||||
|
||||
return c.JSON(statusCode, response)
|
||||
}
|
||||
|
|
Reference in a new issue