Addons-server: Localize all error messages in API responses

Created on 10 Feb 2017  路  9Comments  路  Source: mozilla/addons-server

Describe the problem and steps to reproduce it:

The addons-frontend app makes API requests with a language setting in hopes that we receive localized responses.

What happened?

As discovered via https://github.com/mozilla/addons-server/issues/4652, some error messages such as this one are not marked for localization.

Example request:
POST http://olympia.dev/api/v3/addons/addon/sound-control/reviews/?lang=de
This could result in:
{"non_field_errors":["An add-on author can not leave a review on its own add-on."]}

What did you expect to happen?

Can we get these strings localized? It should be possible with a lazy gettext call.

All 9 comments

Here is my rationale for why I think the API should be responsible for localizing error messages: https://github.com/mozilla/addons-frontend/issues/1775#issuecomment-278817291

Part of the reason why I didn't do it is that I made up the error messages myself (sometimes writing APIs that we didn't need yet) and I'm not a native english speaker. If we can agree on the wording then yes, it's trivial to localize the messages.

Can anyone confirm those strings in the ratings API are good, and if not, suggest better ones ?

  • Can not reply to a review that is already a reply.
  • Can not change version once the review has been created.
  • Version does not exist on this add-on or is not public.
  • An add-on author can not leave a review on its own add-on.
  • The same user can not leave a review on the same more than once.

Slight tweaks:

  • Cannot reply to a review that is already a reply.
  • Cannot change the version of the add-on reviewed once the review has been created.
  • This version of the add-on doesn't exist or isn't public.
  • You can't leave a review on your own add-on.
  • You can't leave more than one review for the same version of an add-on.

(The second one I was a bit unclear on but I think that's what it means.)

The second one should not be exposed to the user through the frontend, but yes, you got it.

Do you think we should conjugate the first 3 ? Like, "You can't reply to a review...".

Do you think we should conjugate the first 3 ? Like, "You can't reply to a review...".

Yes, actually! Good call. The third one should change a bit for that: "You can't review this version of this add-on; it doesn't exist or isn't public."

Yeah, I agree on the conjugation. All messages should be complete sentences.

I wouldn't worry too much about getting them perfect, we can make tweaks to them as people (like QA, etc) review the site. I know that it's a little more work for localizers that way but I think they are already aware that we are actively developing a new version of the site.

Would it also help to mark all unlocalized strings with _to_localize('The yet to be localized text')? (Or some no-op function like that.) We did that before so we could easily grep to find all strings.

Might as well localize the strings directly :) I'll submit a PR shortly for the strings I've found.

Was this page helpful?
0 / 5 - 0 ratings