Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I could not find a way to translate Coupon type label in checkout. Here is a patch that wrapps coupon type labels with a t(). Don't know if this it the correct way to do this but it works.
Comment | File | Size | Author |
---|---|---|---|
#4 | commerce_coupon-1780072-4.patch | 795 bytes | Cristian.Andrei |
#2 | 1780072-2.patch | 649 bytes | killua99 |
commerce_coupon_translate_coupontype_label.patch | 936 bytes | freakalis | |
Comments
Comment #1
pcambraThat's not how a label is translated, I'm afraid, you need to use i18n_field module for this.
Comment #2
killua99 CreditAttribution: killua99 commentedAlso I have an issue with the hook_commerce_price_component_type_info the $name of the label is unstranslated. This is the same issue with the i18n_field?
Comment #2.0
killua99 CreditAttribution: killua99 commentedAdded more explenation
Comment #3
RiBu-Nezz CreditAttribution: RiBu-Nezz commentedHi I have the same problem, my coupon type name/label doesn't be translated even I use i18n_field module. When the coupon line item is added at the checkout page, the coupon type name is still be in English. How can I change it to my language? Any advice will be appreciated!
Comment #4
Cristian.Andrei CreditAttribution: Cristian.Andrei commentedHere'a patch based on killua99's solution with an added context. Works just fine.
Comment #5
Cristian.Andrei CreditAttribution: Cristian.Andrei commentedchanged status
Comment #6
pcambraAs I said in #1, using t() for variables is not the right solution, i18n_fields and i18n_strings should be used instead
Comment #7
killua99 CreditAttribution: killua99 commentedSurprisingly I couldn't never put it work with i18n_fields and i18n_strings, maybe some miss configuration.
Thanks Cristian.Andrei I'm gonna update my patch url in my make file.
Comment #8
killua99 CreditAttribution: killua99 commentedThis patch work just great, none issue with the $variables use in t function.
It's clear some never get work the i18n_field correctly so, this solution just works.
Comment #9
pcambraPlease don't RTBC this, as I've mentioned in the above comments, t() shouldn't not be used for variables like this, the solution is using the other suggested methods.