Automattic / gp-localci

LocalCI is a Github-oriented localization continuous integration add-on to GlotPress.
GNU General Public License v2.0
3 stars 5 forks source link

Context Police: Inform about smart context uses #13

Closed yoavf closed 7 years ago

yoavf commented 7 years ago

Adding a context to a string makes it a separate entry as far as Gettext is concerned. While there are some good use cases of contexts, they are few, and context are often abused.

This PR will add a GH comment to almost string with a context. The possible messages (by priority):

  1. If the string is long enough, it probably doesn't need a context
  2. If the context is too long, it probably should be a translator comment
  3. If a context is added while the string doesn't exist without a context, context isn't needed
  4. If a context is added when the string already exists without a context. This is a good use case, but only if the meaning is different.
  5. If a context is added while there are already one or more occurrences with different contexts. Maybe a context can be reused.

The only case where a comment won't be posted is if a context is specifically added. This is probably a good use case.

This might end up being too opinionated, but we'll see :)

yoavf commented 7 years ago

Sample comments are visible here: https://github.com/Automattic/wp-calypso/pull/10527

akirk commented 7 years ago

Very nice, it's something that makes a lot of sense to enforce. I wouldn't display the message though if it actually matches an existing translation (with context), then I think it's ok to assume that this was a deliberate use of context.

yoavf commented 7 years ago

I wouldn't display the message though if it actually matches an existing translation (with context)

Do you mean this one?

  1. If a context is added when the string already exists without a context. This is a good use case, but only if the meaning is different.
akirk commented 7 years ago

No, I am referring to the case when a context is specified but also has already existing translations (for example because the dev was following a suggestion).