Révision 8c72e82a
Ajouté par Assos Assos il y a environ 7 ans
drupal7/sites/all/modules/i18n/i18n_string/i18n_string.module | ||
---|---|---|
258 | 258 |
} |
259 | 259 |
} |
260 | 260 |
|
261 |
/** |
|
262 |
* Implements hook_element_info_alter(). |
|
263 |
* |
|
264 |
* We need to do this on the element info level as wysiwyg also does so and form |
|
265 |
* API (incorrectly) does not merge in the defaults for values that are arrays. |
|
266 |
*/ |
|
267 |
function i18n_string_element_info_alter(&$types) { |
|
268 |
$types['text_format']['#pre_render'][] = 'i18n_string_pre_render_text_format'; |
|
269 |
} |
|
270 |
|
|
271 |
/** |
|
272 |
* The '#pre_render' function to alter the text format element in a translation. |
|
273 |
* The text format for a translation is taken form the original, so the text |
|
274 |
* format drop down should be disabled. |
|
275 |
* |
|
276 |
* @param array $element |
|
277 |
* The text_format element which will be rendered. |
|
278 |
* |
|
279 |
* @return array |
|
280 |
* The altered text_format element with a disabled "Text format" select. |
|
281 |
*/ |
|
282 |
function i18n_string_pre_render_text_format($element) { |
|
283 |
if (!empty($element['#i18n_string_is_translation'])) { |
|
284 |
$element['format']['format']['#attributes']['disabled'] = TRUE; |
|
285 |
} |
|
286 |
return $element; |
|
287 |
} |
|
288 |
|
|
261 | 289 |
/** |
262 | 290 |
* Check if translation is required for this language code. |
263 | 291 |
* |
... | ... | |
334 | 362 |
} |
335 | 363 |
|
336 | 364 |
/** |
337 |
* Get textgroup handler |
|
365 |
* Get textgroup handler. |
|
366 |
* |
|
367 |
* @return i18n_string_textgroup_default |
|
368 |
* |
|
338 | 369 |
*/ |
339 | 370 |
function i18n_string_textgroup($textgroup) { |
340 | 371 |
$groups = &drupal_static(__FUNCTION__); |
... | ... | |
519 | 550 |
* |
520 | 551 |
* This function is intended to return translations for plain strings that have NO text format |
521 | 552 |
* |
522 |
* @param $name
|
|
553 |
* @param array|string name
|
|
523 | 554 |
* Array or string concatenated with ':' that contains textgroup and string context |
524 |
* @param $string |
|
525 |
* String in default language or array of strings to be translated |
|
526 |
* @param $options |
|
555 |
* @param array|string $string |
|
556 |
* A string in the default language, a string wth format (array with keys |
|
557 |
* value and format),or an array of strings (without format) to be translated. |
|
558 |
* @param array $options |
|
527 | 559 |
* An associative array of additional options, with the following keys: |
528 | 560 |
* - 'langcode' (defaults to the current language) The language code to translate to a language other than what is used to display the page. |
529 | 561 |
* - 'filter' Filtering callback to apply to the translated string only |
... | ... | |
531 | 563 |
* - 'callback' Callback to apply to the result (both to translated or untranslated string |
532 | 564 |
* - 'sanitize' Whether to filter the translation applying the text format if any, default is TRUE |
533 | 565 |
* - 'sanitize default' Whether to filter the default value if no translation found, default is FALSE |
566 |
* |
|
567 |
* @return string |
|
534 | 568 |
*/ |
535 | 569 |
function i18n_string_translate($name, $string, $options = array()) { |
570 |
if (is_array($string) && isset($string['value'])) { |
|
571 |
$string = $string['value']; |
|
572 |
} |
|
536 | 573 |
if (is_array($string)) { |
537 | 574 |
return i18n_string_translate_list($name, $string, $options); |
538 | 575 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules