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.
It is nice to be able to set the messages (Out of stock etc.) yourself in the v2 of the module. The only problem I'm experiencing is translating these messages. The only values I can translate are the names of rules (Stock: disable add to cart etc.). As far as I can understand one can not translate rules messages yet. Or am I missing something really obvious?
Comment | File | Size | Author |
---|---|---|---|
#8 | commerce_stock-support_rules_translation-1567214.patch | 11.08 KB | xiukun.zhou |
#2 | out-of-stock.png | 12.51 KB | guy_schneerson |
Comments
Comment #1
guy_schneerson CreditAttribution: guy_schneerson commentedgood point ranx,
i don't think you are missing something, its me that missed this one out.
I think their is an i18n module for translating rules but i haven't used it another option is for me to put the text set by rules through t().
I will look into this and try and find the best approach
Comment #2
guy_schneerson CreditAttribution: guy_schneerson commentedok i gave the i18n module a go and it rocks (see image attached my out of stock translated to french using Google so sorry if its ...)
checkout http://drupal.org/node/1485738
not sure if this is the best approach for the module but it is the way get thing working at the moment.
Comment #3
ranx CreditAttribution: ranx commentedCould you please elaborate how exactly you were able to translate the message.
I have the rules_i18n module enabled together with the latest dev version of entity API and ver. 1.5 of i18n. A "Translate" tab appears in the rule settings together with new "Translate" actions. But where can I translate the message? Do I need to add a new action or what? The message certainly did not appear to the "translate interface" page.
Comment #4
guy_schneerson CreditAttribution: guy_schneerson commentedranx,
you need to add a "Translate a text" action before the "Set the state of the add to cart form" one.
Set the text to "Out of stock" and give a name to the variable.
you can then use this variable as the "The text to set the action to" of the "Set the state of the add to cart form" (switch to data selection so you can select your variable)
Comment #5
ranx CreditAttribution: ranx commentedGot it working just fine with the instructions. Thank you very much!
Comment #7
guy_schneerson CreditAttribution: guy_schneerson commentedI am considering a new approach to this using translatable text and tokens, will post updates when news.
Comment #8
xiukun.zhou CreditAttribution: xiukun.zhou commentedThis patch will check wether the rules_i18n enabled or not.
If enabled, an aciton "translate a text" will be added in the action list for translating the message.
if not, it use the default rules config as before.
Comment #9
guy_schneerson CreditAttribution: guy_schneerson commentedThanks xiukun.zhou
Useful patch however I will not commit for now as I am not sure this is the best way for Stock and the existing rules can be modified to use rules_i18n.
Comment #10
guy_schneerson CreditAttribution: guy_schneerson commentedxiukun.zhou
I didn't get time to do much with other approaches and this needs to go in, so will have another look
Comment #12
guy_schneerson CreditAttribution: guy_schneerson commentedThanks xiukun.zhou and sorry its taken so long.
Comment #13
xiukun.zhou CreditAttribution: xiukun.zhou commentedThanks guy_schneerson push the patch.
Comment #15
OFF CreditAttribution: OFF commentedДОКОЛЕ?
Why "out of stock" is not translatable after four years?
Comment #16
guy_schneerson CreditAttribution: guy_schneerson commentedOFF: так долго, как необходимо, чтобы прочитать несколько комментариев до ;)
http://cgit.drupalcode.org/commerce_stock/commit/?id=b9e2bcb
Comment #17
drupbasic CreditAttribution: drupbasic commentedHi, I read #16, checked the file. Seems that update was already there. But still, no way to translate the message that pops up to the user when trying to add a quantity of a product that exceeds the stock available. I have been able to translate everything else on my website so I am pretty sure that I have all the modules needed and the right settings. There is no translate button on the rules page. And the text 'Maximum quantity...' is not found on the translation page neither. Also I tried to apply #4 but the 'translate text action' is not there. What I am I missing? Thx!
Comment #18
guy_schneerson CreditAttribution: guy_schneerson commentedHi I think the i18n integration in the commit only takes effect on a new install as the condition is on the crtesating of the rule so if no i18n at the point of installing the rule gets created without i18n support. although I think you can revert the rule and that should also sort it out.
Comment #19
adam1 CreditAttribution: adam1 commentedConcerning #18, reverting does not sort it out, strings are not translatable (before trying to translate, I cleared cache and invoked the message I wanted to translated by hitting the corresponding event/page). What else can I do to make the patch work without uninstalling the module?
Comment #20
guy_schneerson CreditAttribution: guy_schneerson commented@adam1 you can try installing it on another instance (you can use simplytest.me) and exporting the rule to be imported into your site.
Comment #21
adam1 CreditAttribution: adam1 commentedThank you, @guy_schneerson. When I tried your solution and again had no success, I realised that rules_i18n wasn't enabled and the else-part of the if-statement was used.