Révision 5d12d676
Ajouté par Assos Assos il y a environ 6 ans
drupal7/sites/all/modules/views/plugins/views_plugin_localization.inc | ||
---|---|---|
2 | 2 |
|
3 | 3 |
/** |
4 | 4 |
* @file |
5 |
* Contains the base class for views localization plugins.
|
|
5 |
* Definition of views_plugin_localization.
|
|
6 | 6 |
*/ |
7 | 7 |
|
8 | 8 |
/** |
... | ... | |
17 | 17 |
* The base plugin to handle localization of Views strings. |
18 | 18 |
*/ |
19 | 19 |
class views_plugin_localization extends views_plugin { |
20 |
// Store for exported strings |
|
21 |
var $export_strings = array(); |
|
22 |
var $translate = TRUE; |
|
20 |
|
|
21 |
/** |
|
22 |
* Store for exported strings. |
|
23 |
*/ |
|
24 |
public $export_strings = array(); |
|
25 |
|
|
26 |
/** |
|
27 |
* |
|
28 |
*/ |
|
29 |
public $translate = TRUE; |
|
23 | 30 |
|
24 | 31 |
/** |
25 | 32 |
* Initialize the plugin. |
26 | 33 |
* |
27 |
* @param $view |
|
34 |
* @param view $view
|
|
28 | 35 |
* The view object. |
29 | 36 |
*/ |
30 |
function init(&$view) { |
|
37 |
public function init(&$view) {
|
|
31 | 38 |
$this->view = &$view; |
32 | 39 |
} |
33 | 40 |
|
34 | 41 |
/** |
35 |
* Translate a string / text with format |
|
42 |
* Translate a string / text with format.
|
|
36 | 43 |
* |
37 | 44 |
* The $source parameter is an array with the following elements: |
38 | 45 |
* - value, source string |
... | ... | |
40 | 47 |
* - keys. An array of keys to identify the string. Generally constructed from |
41 | 48 |
* view name, display_id, and a property, e.g., 'header'. |
42 | 49 |
* |
43 |
* @param $source |
|
50 |
* @param string $source
|
|
44 | 51 |
* Full data for the string to be translated. |
45 | 52 |
* |
46 | 53 |
* @return string |
47 |
* Translated string / text |
|
54 |
* Translated string / text.
|
|
48 | 55 |
*/ |
49 |
function translate($source) { |
|
50 |
// Allow other modules to make changes to the string before and after translation |
|
56 |
public function translate($source) { |
|
57 |
// Allow other modules to make changes to the string before and after |
|
58 |
// translation. |
|
51 | 59 |
$source['pre_process'] = $this->invoke_translation_process($source, 'pre'); |
52 | 60 |
$source['translation'] = $this->translate_string($source['value'], $source['keys'], $source['format']); |
53 | 61 |
$source['post_process'] = $this->invoke_translation_process($source, 'post'); |
... | ... | |
57 | 65 |
/** |
58 | 66 |
* Translate a string. |
59 | 67 |
* |
60 |
* @param $string |
|
68 |
* @param string $string
|
|
61 | 69 |
* The string to be translated. |
62 |
* @param $keys |
|
70 |
* @param array $keys
|
|
63 | 71 |
* An array of keys to identify the string. Generally constructed from |
64 |
* view name, display_id, and a property, e.g., 'header'.
|
|
65 |
* @param $format |
|
72 |
* view name, display_id, and a property, e.g. 'header'. |
|
73 |
* @param string $format
|
|
66 | 74 |
* The input format of the string. This is optional. |
67 | 75 |
*/ |
68 |
function translate_string($string, $keys = array(), $format = '') {} |
|
76 |
public function translate_string($string, $keys = array(), $format = '') {}
|
|
69 | 77 |
|
70 | 78 |
/** |
71 | 79 |
* Save string source for translation. |
72 | 80 |
* |
73 |
* @param $source |
|
81 |
* @param string $source
|
|
74 | 82 |
* Full data for the string to be translated. |
75 | 83 |
*/ |
76 |
function save($source) { |
|
77 |
// Allow other modules to make changes to the string before saving |
|
84 |
public function save($source) {
|
|
85 |
// Allow other modules to make changes to the string before saving.
|
|
78 | 86 |
$source['pre_process'] = $this->invoke_translation_process($source, 'pre'); |
79 | 87 |
$this->save_string($source['value'], $source['keys'], isset($source['format']) ? $source['format'] : ''); |
80 | 88 |
} |
81 | 89 |
|
82 | 90 |
/** |
83 |
* Save a string for translation |
|
91 |
* Save a string for translation.
|
|
84 | 92 |
* |
85 |
* @param $string |
|
93 |
* @param string $string
|
|
86 | 94 |
* The string to be translated. |
87 |
* @param $keys |
|
95 |
* @param array $keys
|
|
88 | 96 |
* An array of keys to identify the string. Generally constructed from |
89 | 97 |
* view name, display_id, and a property, e.g., 'header'. |
90 |
* @param $format |
|
98 |
* @param string $format
|
|
91 | 99 |
* The input format of the string. This is optional. |
92 | 100 |
*/ |
93 |
function save_string($string, $keys = array(), $format = '') {} |
|
101 |
public function save_string($string, $keys = array(), $format = '') {}
|
|
94 | 102 |
|
95 | 103 |
/** |
96 | 104 |
* Delete a string. |
97 | 105 |
* |
98 |
* @param $source |
|
106 |
* @param string $source
|
|
99 | 107 |
* Full data for the string to be translated. |
100 | 108 |
*/ |
101 |
function delete($source) { } |
|
109 |
public function delete($source) { |
|
110 |
} |
|
102 | 111 |
|
103 | 112 |
/** |
104 | 113 |
* Collect strings to be exported to code. |
105 | 114 |
* |
106 |
* @param $source |
|
115 |
* @param string $source
|
|
107 | 116 |
* Full data for the string to be translated. |
108 | 117 |
*/ |
109 |
function export($source) { } |
|
118 |
public function export($source) { |
|
119 |
} |
|
110 | 120 |
|
111 | 121 |
/** |
112 | 122 |
* Render any collected exported strings to code. |
113 | 123 |
* |
114 |
* @param $indent |
|
124 |
* @param string $indent
|
|
115 | 125 |
* An optional indentation for prettifying nested code. |
116 | 126 |
*/ |
117 |
function export_render($indent = ' ') { } |
|
127 |
public function export_render($indent = ' ') { |
|
128 |
} |
|
118 | 129 |
|
119 | 130 |
/** |
120 | 131 |
* Invoke hook_translation_pre_process() or hook_translation_post_process(). |
... | ... | |
122 | 133 |
* Like node_invoke_nodeapi(), this function is needed to enable both passing |
123 | 134 |
* by reference and fetching return values. |
124 | 135 |
*/ |
125 |
function invoke_translation_process(&$value, $op) { |
|
136 |
public function invoke_translation_process(&$value, $op) {
|
|
126 | 137 |
$return = array(); |
127 | 138 |
$hook = 'translation_' . $op . '_process'; |
128 | 139 |
foreach (module_implements($hook) as $module) { |
... | ... | |
135 | 146 |
return $return; |
136 | 147 |
} |
137 | 148 |
|
138 |
function process_locale_strings($op) { |
|
149 |
/** |
|
150 |
* |
|
151 |
*/ |
|
152 |
public function process_locale_strings($op) { |
|
139 | 153 |
$this->view->init_display(); |
140 | 154 |
|
141 | 155 |
foreach ($this->view->display as $display_id => $display) { |
... | ... | |
154 | 168 |
case 'save': |
155 | 169 |
$this->save($data); |
156 | 170 |
break; |
171 |
|
|
157 | 172 |
case 'delete': |
158 | 173 |
$this->delete($data); |
159 | 174 |
break; |
175 |
|
|
160 | 176 |
case 'export': |
161 | 177 |
$this->export($data); |
162 | 178 |
break; |
... | ... | |
164 | 180 |
} |
165 | 181 |
} |
166 | 182 |
} |
183 |
|
|
167 | 184 |
} |
168 | 185 |
|
169 | 186 |
/** |
Formats disponibles : Unified diff
Weekly update of contrib modules