Hi,

I have made a rule that changes the account language (Profile language) based on a field in the account.
This only works when the language to be set by the rule is a predefined language, and doesn't work when the language to be set by the rule is a custom language.

I added to include/iso.inc the custom language, but this didn't solve the problem.

Below is the rule:

{ "rules_change_language" : {
    "LABEL" : "Change Language",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "user_presave" : [] },
    "IF" : [
      { "text_matches" : {
          "text" : [ "account:field-gender" ],
          "match" : "Female",
          "operation" : "starts"
        }
      }
    ],
    "DO" : [
      { "data_set" : { "data" : [ "account:language" ], "value" : "Female" } }
    ]
  }
}

I would appreciate any help on the matter.

Comments

tr’s picture

Version: 7.x-2.9 » 7.x-2.x-dev
Category: Bug report » Support request
Status: Active » Postponed (maintainer needs more info)

Well, I didn't set up a field on a user, I simply created a custom language called "T2" at /admin/ and tried to set the node language to that when the node was viewed. This worked. I suspect your problem might be the capitalization of your language code?

{ "rules_set_language_to_t2" : {
    "LABEL" : "Set language to T2",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_view" : [] },
    "DO" : [ { "data_set" : { "data" : [ "node:language" ], "value" : "t2" } } ]
  }
}
tr’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)

Actually, this *is* because of the capital letter in the language code. Turns out that capital letters and '-' are not allowed (but they should be!). It's the same problem as in #2142475: Set language values with a dash (eg: pt-br, pt-pt, en-gb) fails. You can help out in that issue if you want to get this resolved.