I've tried this bug on new Drupal 7.21.

I installed Locale and Rules, created a custom language: zh-TW as there is no zh-TW in predefined language.
then I enabled it. So now I have English and zh-TW.

Then I added a new rule: when viewing a content, change the language to zh-TW, but it gave me:
1.663 ms Unable to modify data "node:language": Invalid data value given. Be sure it matches the required data type and format.
2.327 ms Unable to evaluate action data_set.
Rules evaluation log

This is my rule:

{ "rules_set_language_to_zh_tw" : {
    "LABEL" : "Set language to zh-TW",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules" ],
    "ON" : [ "node_view" ],
    "DO" : [ { "data_set" : { "data" : [ "node:language" ], "value" : "zh-TW" } } ]
  }
}
CommentFileSizeAuthor
Screen Shot 2013-03-23 at 16.04.03.png69.54 KBhanamizuki
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

burkeker’s picture

Not sure if this solves your problem but at least I can spot that "zh-TW" is not the supported tag for Traditional Chinese in Drupal 7. In includes/iso.inc, 'zh-hant' is for Traditional Chinese. This is non-ISO way, so it's a bit misleading. See http://drupal.org/node/1231402, something that might be addressed in Drupal 8.

chansionjoe’s picture

Issue summary: View changes

sub even zh-hans zh-hant both not work

TR’s picture

Version: 7.x-2.2 » 7.x-2.x-dev
Status: Active » Closed (duplicate)

After defining a custom language zh-TW at /admin/config/regional/language, I can confirm that importing the Rule in the original post results in the stated error. This seems to be cause by using a '-' in the language code. If you define the language code without the '-' then it works properly.

Note that this also fails for predefined languages with a '-' in the language code. For example, en-GB. Thus, this issue is not a problem with custom languages, it's a problem with language codes that have '-' in them.

Marking this as duplicate of #2142475: Set language values with a dash (eg: pt-br, pt-pt, en-gb) fails. Even though that issue is a lot newer, it has more information about the error and correctly identifies it as a problem with '-'.

TR’s picture

Issue summary: View changes