The product quantity in the cart block is not translatable and does not support singular, only plural.

CommentFileSizeAuthor
#12 cart_block_quantity-2724059-12.patch4.37 KBmglaman

Comments

nomadkz created an issue. See original summary.

nomadkz’s picture

Category: Task » Bug report
nomadkz’s picture

up

bojanz’s picture

@nomadkz
Bumping issues like that is extremely frowned upon everywhere on drupal.org.
Feel free to provide a patch, otherwise you'll need to wait when another contributor has free time to address this.

nomadkz’s picture

@bojanz

OK.

Sonal.Sangale’s picture

Assigned: Unassigned » Sonal.Sangale
Sonal.Sangale’s picture

Assigned: Sonal.Sangale » Unassigned
pieterjanput’s picture

Assigned: Unassigned » pieterjanput
Issue tags: +DevDaysMilan
pieterjanput’s picture

Assigned: pieterjanput » Unassigned
Status: Active » Needs review

Quantities can now be set for singular and plural. For translation of these setting you can use Configuration Translation.

https://github.com/drupalcommerce/commerce/pull/416

mglaman’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Can we have tests added to verify this works? Should be a Functional test. If you're unfamiliar, please see my recent blog post: https://drupalcommerce.org/blog/45322/commerce-2x-unit-kernel-and-functi.... We have plenty of code examples :)

mglaman’s picture

Assigned: Unassigned » mglaman
mglaman’s picture

StatusFileSize
new4.37 KB

Here is the initial original patch.

mglaman’s picture

Status: Needs work » Needs review
bojanz’s picture

Title: Cart block quantity text is not translatable » Remove the cart block item text because it is not translatable
Assigned: mglaman » bojanz
Status: Needs review » Needs work
Issue tags: -translation, -DevDaysMilan, -Needs tests

I've looked into the patch, and it's complex, both UX and DX wise.
I see that it's copied from core (NumberField?), where there's a similar need.
However, there's no API defined for this, and the original implementation is already criticized for being hard to understand: #2499639: Use correct labels for numeric fields when using a multiple plural forms language.

So I think the better solution is to simply remove the setting in question, and to pass the variable to the template after running formatPlural() ourselves. The few people who wish to override item/items will be able to write a preprocess template hook, and do their own formatPlural() line inside.

Commit incoming as soon as it passes tests.

  • bojanz committed e6a7676 on 8.x-2.x
    Issue #2724059 by mglaman, bojanz, PieterJanPut: Remove the cart block...
bojanz’s picture

Status: Needs work » Fixed

Done. Thanks, everyone.

ndf’s picture

Nice testCountText()

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.