1
|
|
2
|
This module provides by default the ability to translate panel display and
|
3
|
panel pane titles.
|
4
|
Further it introduced an extension to the ctools content_types plugin.
|
5
|
You can now define translatable settings which will be registered in i18n.
|
6
|
Out of the box the module extends the custom content content_type to allow
|
7
|
translation of the content.
|
8
|
|
9
|
Requirements:
|
10
|
Ctools 7.x-1.x-dev (Jan 28-2014 or newer)
|
11
|
Panels 7.x-3.x-dev (Jan 28-2014 or newer)
|
12
|
|
13
|
Plugin definition extension:
|
14
|
------------------------------
|
15
|
|
16
|
This example shows how the content_type custom is extended:
|
17
|
|
18
|
#### Default: ####
|
19
|
/**
|
20
|
* Plugins are described by creating a $plugin array which will be used
|
21
|
* by the system that includes this file.
|
22
|
*/
|
23
|
$plugin = array(
|
24
|
'title' => t('Custom content'),
|
25
|
'no title override' => TRUE,
|
26
|
'defaults' => array('admin_title' => '', 'title' => '', 'body' => '', 'format' => filter_fallback_format(), 'substitute' => TRUE),
|
27
|
'js' => array('misc/autocomplete.js', 'misc/textarea.js', 'misc/collapse.js'),
|
28
|
// Make sure the edit form is only used for some subtypes.
|
29
|
'edit form' => '',
|
30
|
'add form' => '',
|
31
|
'edit text' => t('Edit'),
|
32
|
'all contexts' => TRUE,
|
33
|
);
|
34
|
|
35
|
#### Extended Configuration: ####
|
36
|
/**
|
37
|
* Plugins are described by creating a $plugin array which will be used
|
38
|
* by the system that includes this file.
|
39
|
*/
|
40
|
$plugin = array(
|
41
|
'title' => t('Custom content'),
|
42
|
'no title override' => TRUE,
|
43
|
'defaults' => array('admin_title' => '', 'title' => '', 'body' => '', 'format' => filter_fallback_format(), 'substitute' => TRUE),
|
44
|
'js' => array('misc/autocomplete.js', 'misc/textarea.js', 'misc/collapse.js'),
|
45
|
// Make sure the edit form is only used for some subtypes.
|
46
|
'edit form' => '',
|
47
|
'add form' => '',
|
48
|
'edit text' => t('Edit'),
|
49
|
'all contexts' => TRUE,
|
50
|
'i18n_settings' = array(
|
51
|
'title',
|
52
|
'body' => array('format' => 'plain_text'),
|
53
|
'items|0|title'
|
54
|
),
|
55
|
);
|
56
|
|
57
|
The new key "i18n_settings" defines an array with the settings that are
|
58
|
translatable. The array contains the names of the settings, they have to be
|
59
|
available in the "defaults" array of the content definition. If you need to
|
60
|
define a format use the name of the setting as the array item key and as item
|
61
|
another array with the detail configuration. E.g
|
62
|
'i18n_settings' = array('body' => array('format' => 'plain_text'))
|
63
|
|
64
|
If i18n_settings is a string it's used as callback. The expected return is an
|
65
|
array equal to the one used in the fix configuration.
|
66
|
You can even declare nested settings as translatable, to do so use '|' as
|
67
|
delimiter.
|
68
|
E.g. 'items|0|title' is evaluated as $settings['items'][0]['title']
|
69
|
|
70
|
#### Callback: ####
|
71
|
/**
|
72
|
* Plugins are described by creating a $plugin array which will be used
|
73
|
* by the system that includes this file.
|
74
|
*/
|
75
|
$plugin = array(
|
76
|
'title' => t('Custom content'),
|
77
|
'no title override' => TRUE,
|
78
|
'defaults' => array('admin_title' => '', 'title' => '', 'body' => '', 'format' => filter_fallback_format(), 'substitute' => TRUE),
|
79
|
'js' => array('misc/autocomplete.js', 'misc/textarea.js', 'misc/collapse.js'),
|
80
|
// Make sure the edit form is only used for some subtypes.
|
81
|
'edit form' => '',
|
82
|
'add form' => '',
|
83
|
'edit text' => t('Edit'),
|
84
|
'all contexts' => TRUE,
|
85
|
'i18n_settings' => 'ctools_custom_content_type_i18n_settings',
|
86
|
);
|
87
|
|
88
|
function ctools_custom_content_type_i18n_settings($conf) {
|
89
|
return array(
|
90
|
'title',
|
91
|
'body' => array('format' => $conf['format']),
|
92
|
);
|
93
|
}
|