Active
Project:
Commerce Core
Version:
7.x-1.x-dev
Component:
Cart
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
9 Jan 2013 at 17:12 UTC
Updated:
4 Jun 2016 at 07:24 UTC
Jump to comment: Most recent
The file profiles/commerce_kickstart/modules/contrib/commerce/modules/line_item/includes/views/handlers/commerce_line_item_handler_area_line_item_summary.inc has a a snippet of slightly incorrect code. Slightly - cause it works fine in English, but this code knows nothing to do with 3 forms of plurals in Russian.
'quantity_label' => format_plural($quantity, 'item', 'items', array(), array('context' => 'product count on a Commerce order')),
So I had to wrap this code into regex replacement (it cuts the first number):
'quantity_label' => preg_replace( '/^[0-9]*\s+(.*)/', '${1}', format_plural($quantity, '1 item', '@count items', array(), array('context' => 'product count on a Commerce order'))),
Comments
Comment #1
bojanz commentedThis is a Commerce issue. And we definitely can't fix it with a regular expression ;)
The recommended way to use format_plural is format_plural($quantity, '1 item', '@count items', array(), array('context' => 'product count on a Commerce order')), which should work in your case (can you check?)
And that's exactly what Commerce is doing for quantity, but not quantity_label, not sure why. Perhaps Ryan will have more insight.
Comment #2
rszrama commentedThe function is being used here as specified, it's just separating out the quantity from the label for the purposes of theming (i.e. having a wrapper around the number separate from the label). We definitely don't want a regex in the code, but I also don't think I understand why this isn't working for you or why this isn't but any other format_plural() does. Can you provide more info?
Comment #3
CSoft commentedВы пишете про 5 items вместо 5 товаров, например? Просто недопереведено нашими коллегами. Зайдите в
/admin/config/regional/translate/translate
в фильтр вбейте "@count items" и переведите как "@count товара".
Затем ищем следующую форму: "@count[2] items". Переводим её: "@count[2] товаров".
Ну и конечно следим, чтобы правки делались в контексте product count on a Commerce order. И всё, всё будет работать как положено.
=============
Sorry for the answer in Russian, it concerns only the problem of our localization :)
Comment #4
glebgo commentedThe thing is that when you have cart block displayed, summary with total quantity should have 3 different forms, but in case of 'quantity_label' programmatically configured to have only 2: 'item', 'items' - there is no chance. With translation we could only have 2 plural forms in Russian: translation of 'item, and 'items', but it's necessary to have 3. Please, correct me if I'm wrong or misunderstand something.
Comment #5
CSoft commentedNo, in our Russian language is 3 plural forms in this case. For example:
1 товар
2 товара
5 товаров
Comment #6
guy_schneerson commentedSame issue, If I understand it correctly, the numbering go like this:
1 товар,
2-4 товара,
5 -20 товаров
After 21 they start from 1 again but this time in cycles of 10:
21 товар,
22-24 товара,
25-30 товаров
31 товар etc
32-34 товара,
35-40 товаров
Comment #7
guy_schneerson commentedmade correction to #6 changed "2-3" to "2-4"
Comment #8
pere orgaCan Drupal do this? Use multiple plural forms?
Comment #9
pere orgaComment #10
rootwork