function RulesI18nStringEvaluator::evaluate

Translate the value.

If the element provides a language parameter, we are using this target language provided via $options['language']. Sanitizing is handled by Rules, so disable that for i18n.

Overrides RulesDataInputEvaluator::evaluate

1 call to RulesI18nStringEvaluator::evaluate()
RulesI18nStringEvaluator::process in rules_i18n/rules_i18n.rules.inc
Prepare the i18n-context string.

File

rules_i18n/rules_i18n.rules.inc, line 176

Class

RulesI18nStringEvaluator
A class implementing a rules input evaluator processing tokens.

Code

public function evaluate($value, $options, RulesState $state) {
    $langcode = isset($options['language']) ? $options['language']->language : NULL;
    if (is_array($value)) {
        foreach ($value as $key => $text) {
            $value[$key] = i18n_string($options['i18n context'] . ':' . $key, $text, array(
                'langcode' => $langcode,
                'sanitize' => FALSE,
            ));
        }
    }
    else {
        $value = i18n_string($options['i18n context'], $value, array(
            'langcode' => $langcode,
            'sanitize' => FALSE,
        ));
    }
    return $value;
}