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.

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" } } ]
}
}
Comments
Comment #1
burkeker commentedNot 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.
Comment #2
chansionjoe commentedsub even zh-hans zh-hant both not work
Comment #3
tr commentedAfter 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 '-'.
Comment #4
tr commented