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.
Parameters
string $text: The text to evaluate.
array $options: A keyed array of settings and flags to control the processing. Supported options are:
- language: A language object to be used when processing.
- callback: A callback function that will be used to post-process replacements that might be incorporated, so they can be cleaned in a certain way.
- sanitize: A boolean flag indicating whether incorporated replacements should be sanitized.
RulesState $state: The rules evaluation state.
Return value
The evaluated text.
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;
}