I see in the code there are a lot of t() "context" option usage, which is a really good thing, but a lot of those contextes are english partial sentences, such as: "a drupal commerce order" or "product count on a Commerce order"

From http://www.gnu.org/software/gettext/manual/gettext.html we can read:

Finding a canonical msgctxt string that doesn't change over time can be hard. But you shouldn't use the file name or class name containing the pgettext call – because it is a common development task to rename a file or a class, and it shouldn't cause translator work. Also you shouldn't use a comment in the form of a complete English sentence as msgctxt – because orthography or grammar changes are often applied to such sentences, and again, it shouldn't force the translator to do a review.

So I guess you should probably switch to more generic and "internal" litterals, such as just "commerce" or "commerce_order", before every language has the chance of translating it all using those contextes.

Comments

no2e’s picture

pounard’s picture

The first link is in contradiction with gettext documentation, I'd definitely trust gettext people, not Drupal one about this specific issue.

Sutharsan’s picture

I collected all context from the Commerce module and investigated their usage.

Context 'a drupal commerce order' is used for:
'Commerce Order'
'Order'
'Order history'
'Order ID'
'Order number'
'Orders'
'Save order'
'Specify order by'
'order' in these strings is not specific to Drupal Commerce. I propose to use 'purchase order' as a context as it describes the meaning of the word 'order' in this context and is reusable by other modules too.

Context 'a drupal commerce payment transaction' is used for:
'Payment transactions'
Why does this need a context? This (exact) same string is only used by the Pay module [1], in which case I don't expect a difference in meaning. I propopse to remove this context.

Context 'a drupal commerce transaction' is used for:
'Transaction'
This is the lable for the "Payment Transaction" relationship. I suggest to use 'Payment transaction' or as context.

Context 'credit card issue number for card types that require it' is used for:
'Issue number'
Does this need a context, was it reported as a problem? Not many modules use it [2] If so, the context should focus on the meaning of 'issue'. Suggestions: 'Distribution', 'Identification number'

Context 'product count on a Commerce order' is used for:
'item', 'items' (plural)
'1 item', '@count items' (plural)
Does this need a context, was it reported as a problem? The context should focus on fixing the problem and be reusable for other strings and modules. Suggestions: 'row item', 'list item'

Context 'tax rate' is used for:
'Rate @rate'
'Rate'
'You must specify a numeric rate value'
I proposed this context, no comments ;)

[1] https://localize.drupal.org/translate/languages/nl/translate?status=0&re...
[2] https://localize.drupal.org/translate/languages/nl/translate?status=0&re...

hansfn’s picture

Issue summary: View changes

Setting good context values are important.

I agree very much with the idea of using contexts that aren't specific to Drupal commerce enabling the translations to be reused in similar modules (for example in Übercart). To repeat:

  1. 'purchase order' in stead of 'a drupal commerce order'
  2. 'payment transaction' in stead of 'a drupal commerce transaction'

and so on are good changes.

However, I disagree with the suggested change to the 'product count on a Commerce order' context - 'row item' or 'list item' is to generic. Maybe 'product count on a purchase order'? (In Norwegian items in an order is different from items in a general list.)