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?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

guy_schneerson’s picture

Category: support » feature

good 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

guy_schneerson’s picture

Category: feature » support
Status: Active » Fixed
FileSize
12.51 KB

ok 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.

ranx’s picture

Could 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.

guy_schneerson’s picture

ranx,
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)

ranx’s picture

Got it working just fine with the instructions. Thank you very much!

Status: Fixed » Closed (fixed)

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

guy_schneerson’s picture

I am considering a new approach to this using translatable text and tokens, will post updates when news.

xiukun.zhou’s picture

Category: support » bug
Status: Closed (fixed) » Needs review
FileSize
11.08 KB

This 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.

guy_schneerson’s picture

Category: bug » feature

Thanks 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.

guy_schneerson’s picture

Issue summary: View changes

xiukun.zhou
I didn't get time to do much with other approaches and this needs to go in, so will have another look

guy_schneerson’s picture

Status: Needs review » Fixed

Thanks xiukun.zhou and sorry its taken so long.

xiukun.zhou’s picture

Thanks guy_schneerson push the patch.

Status: Fixed » Closed (fixed)

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

OFF’s picture

ДОКОЛЕ?

Why "out of stock" is not translatable after four years?

guy_schneerson’s picture

OFF: так долго, как необходимо, чтобы прочитать несколько комментариев до ;)
http://cgit.drupalcode.org/commerce_stock/commit/?id=b9e2bcb

drupbasic’s picture

Hi, 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!

guy_schneerson’s picture

Hi 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.

adam1’s picture

Concerning #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?

guy_schneerson’s picture

@adam1 you can try installing it on another instance (you can use simplytest.me) and exporting the rule to be imported into your site.

adam1’s picture

Thank 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.