jsend
jsend copied to clipboard
How do you handle multilanguage apps?
For example, I have this fail response, but the frontend is a multilanguage app.
{
"status" : "fail",
"data" : { "username" : "Username already exists" }
}
Should I specify the language on a header and handle it on the backend? I thought that maybe could be a good idea to add a code in a nested object like this
{
"status" : "fail",
"data" : {
"username" : {
"message": "Username already exists",
"code": "usernameExists"
}
}
}
And the frontend should have a dictionary with "userAlreadyExists" to manage multilanguage error messages.