1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Internationalization integration based upon the entity API i18n stuff.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Rules i18n integration controller.
|
10 |
|
|
*/
|
11 |
|
|
class RulesI18nStringController extends EntityDefaultI18nStringController {
|
12 |
|
|
|
13 |
|
|
/**
|
14 |
|
|
* Overriden to customize i18n object info.
|
15 |
|
|
*
|
16 |
|
|
* @see EntityDefaultI18nStringController::hook_object_info()
|
17 |
|
|
*/
|
18 |
|
|
public function hook_object_info() {
|
19 |
|
|
$info = parent::hook_object_info();
|
20 |
|
|
$info['rules_config']['class'] = 'RulesI18nStringObjectWrapper';
|
21 |
|
|
return $info;
|
22 |
|
|
}
|
23 |
|
|
|
24 |
|
|
/**
|
25 |
|
|
* Overriden to customize the used menu wildcard.
|
26 |
|
|
*/
|
27 |
|
|
protected function menuWildcard() {
|
28 |
|
|
return '%rules_config';
|
29 |
|
|
}
|
30 |
|
|
|
31 |
|
|
/**
|
32 |
|
|
* Provide the menu base path. We can provide only one though.
|
33 |
|
|
*/
|
34 |
|
|
protected function menuBasePath() {
|
35 |
|
|
return 'admin/config/workflow/rules/reaction';
|
36 |
|
|
}
|
37 |
|
|
}
|
38 |
|
|
|
39 |
|
|
/**
|
40 |
|
|
* Custom I18n String object wrapper, which register custom properties per config.
|
41 |
|
|
*/
|
42 |
|
|
class RulesI18nStringObjectWrapper extends i18n_string_object_wrapper {
|
43 |
|
|
|
44 |
|
|
/**
|
45 |
|
|
* Get translatable properties
|
46 |
|
|
*/
|
47 |
|
|
protected function build_properties() {
|
48 |
|
|
$strings = parent::build_properties();
|
49 |
|
|
$properties = array();
|
50 |
|
|
|
51 |
|
|
// Also add in the configuration label, as the i18n String UI requires
|
52 |
|
|
// a String to be available always.
|
53 |
|
|
$properties['label'] = array(
|
54 |
|
|
'title' => t('Configuration name'),
|
55 |
|
|
'string' => $this->object->label,
|
56 |
|
|
);
|
57 |
|
|
|
58 |
|
|
$this->buildElementProperties($this->object, $properties);
|
59 |
|
|
|
60 |
|
|
// Add in translations for all elements.
|
61 |
|
|
foreach ($this->object->elements() as $element) {
|
62 |
|
|
$this->buildElementProperties($element, $properties);
|
63 |
|
|
}
|
64 |
|
|
$strings[$this->get_textgroup()]['rules_config'][$this->object->name] = $properties;
|
65 |
|
|
return $strings;
|
66 |
|
|
}
|
67 |
|
|
|
68 |
|
|
/**
|
69 |
|
|
* Adds in translatable properties of the given element.
|
70 |
|
|
*/
|
71 |
|
|
protected function buildElementProperties($element, &$properties) {
|
72 |
|
|
|
73 |
|
|
foreach ($element->pluginParameterInfo() as $name => $info) {
|
74 |
|
|
// Add in all directly provided input variables.
|
75 |
|
|
if (!empty($info['translatable']) && isset($element->settings[$name])) {
|
76 |
|
|
// If its an array of textual values, translate each value on its own.
|
77 |
|
|
if (is_array($element->settings[$name])) {
|
78 |
|
|
foreach ($element->settings[$name] as $i => $value) {
|
79 |
|
|
$properties[$element->elementId() . ':' . $name . ':' . $i] = array(
|
80 |
|
|
'title' => t('@plugin "@label" (id @id), @parameter, Value @delta', array('@plugin' => drupal_ucfirst($element->plugin()), '@label' => $element->label(), '@id' => $element->elementId(), '@parameter' => $info['label'], '@delta' => $i + 1)),
|
81 |
|
|
'string' => $value,
|
82 |
|
|
);
|
83 |
|
|
}
|
84 |
|
|
}
|
85 |
|
|
else {
|
86 |
|
|
$properties[$element->elementId() . ':' . $name] = array(
|
87 |
|
|
'title' => t('@plugin "@label" (id @id), @parameter', array('@plugin' => drupal_ucfirst($element->plugin()), '@label' => $element->label(), '@id' => $element->elementId(), '@parameter' => $info['label'])),
|
88 |
|
|
'string' => $element->settings[$name],
|
89 |
|
|
);
|
90 |
|
|
}
|
91 |
|
|
}
|
92 |
|
|
}
|
93 |
|
|
}
|
94 |
|
|
} |