Needs work
Project:
Commerce Core
Version:
7.x-1.x-dev
Component:
Internationalization
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
11 Mar 2012 at 21:16 UTC
Updated:
12 Jan 2017 at 19:38 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
rszrama commentedIf you look in commerce_line_item_handler_area_line_item_summary.inc, you'll see near line 123 where format_plural() is being called to prepare this quantity string. You should be able to translate "1 item" and "@count items" to whatever you need.
Comment #2
no2e commentedHmm, that doesn't work.
singular
/admin/config/regional/translate/translateI search for "1 item".1 item" (with Context: "product count on a Commerce order")Shopping cart (1 item)"plural
/admin/config/regional/translate/translateI search for "@count items".@count items" (with Context: "product count on a Commerce order")Shopping cart (@count items)"Problem with i18nviews?
I use Internationalization Views (i18nviews). But after my first test I changed Views translation method to "Core" (at
/admin/structure/views/settings/advanced) and refreshed all strings → still doesn't work.Even stringoverrides doesn't work …
Even using a string override doesn't work for this string. When I overwrite (for English) the string "1 item" with "1 foobar" (and use the Context "product count on a Commerce order"), nothing changes.
Comment #3
no2e commented(oops, forgot to change status; … don't know if this is now a bug or still a support request?)
Comment #4
rszrama commentedI still think it should be a support request, but the issue appears to be centered around either that these strings are coming through format_plural() and therefore aren't being translated properly for some reason or that these strings are being passed as variables to a theme function. But honestly, neither of these seems like the real issue, because I don't know of any reason for them not to work.
Comment #5
no2e commentedHmm … anything I could do to test? (can't program, though :/)
If I remember correctly, the translation worked some weeks/months ago when I was building the site - I think it was with Commerce 7.x-1.1. But I'm not sure about it.
Because I want to go live in the next days, I would have to use some JavaScript to replace and translate the string on the client-side … which is, of course, really ugly.
Comment #6
didaka commentedI got it translatable.
I used l10n_client to do my translation on screen and it turned out that the string to be translated is not @count items. It is only items and item in singular form.
Comment #7
didaka commentedComment #8
igi commentedDrupal core 7.22, commerce_kickstart 2.9 (commerce_kickstart-7.x-2.9)
file:
/profiles/commerce_kickstart/modules/contrib/commerce/modules/line_item/includes/views/handlers/commerce_line_item_handler_area_line_item_summary.inc
Change line 116
// 'quantity_label' => format_plural($quantity, 'item', 'items', array(), array('context' => 'product count on a Commerce order')),
to:
'quantity_label' => format_plural($quantity, t('item'), t('items'), array(), array('context' => 'product count on a Commerce order')),
Comment #9
nessunluogo commentedDrupal core 7.41, commerce_kickstart 2.30
After two years I had the same issue. #8 worked fine, so I made a patch where the t() is applied to both 'quantity' and 'quantity_label' elements of the array.
It needs testing, but I hope it can help.
Comment #10
rootworkThe existing state (redeclaring a gigantic function that does a ton of stuff in template.php or a custom module) seems like a real hassle, and it seems like it'd be useful to just have these strings translatable.
Not even just for internationalization, but let's say your store sells only kittens -- wouldn't it be nice to be able to use String Overrides or a quick
$confsetting so that your cart says "1 kitten, 2 kittens, etc."? Come on. More kittehs!The patch in #9 was against a Commerce Kickstart install, so I've updated it to be specific to the module. But it'd be nice to see this reviewed and committed. It seems like an easy win.
Comment #12
rootworkOh, right, as @nessunluogo said, it needs updated tests. So maybe not as "easy" of a win. But still worth pursuing, commerce maintainers?
Comment #13
perarg commentedpatch #10, worked for me too. I use D7 7.50 and Commerce 2.x
Comment #14
nachus commentedFound the same problem. The patch fix it. Thanks!
Comment #15
nachus commentedFound the same problem. The patch fix it. Thanks!
Comment #16
thomas.wardin commentedFor version 8.x-2.33
Same applies to the summary block. Currently it relies on "item" or "items" translated elsewhere. But in order for it to be specifically translatable, line 173 of commerce/modules/cart/src/Plugin/Block/CartBlock.php should read
'#count_text' => $this->formatPlural($count, t('@count item'), t('@count items')),