1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
* @file
|
4 |
|
|
* Internationalization (i18n) hooks
|
5 |
|
|
*/
|
6 |
|
|
|
7 |
|
|
/**
|
8 |
|
|
* Implements hook_i18n_object_info().
|
9 |
|
|
*/
|
10 |
|
|
function i18n_menu_i18n_object_info() {
|
11 |
|
|
$info['menu'] = array(
|
12 |
|
|
'title' => t('Menu'),
|
13 |
|
|
'key' => 'menu_name',
|
14 |
|
|
'load callback' => 'menu_load',
|
15 |
|
|
'base path' => 'admin/structure/menu/manage',
|
16 |
|
|
'placeholders' => array(
|
17 |
|
|
'%menu' => 'menu_name',
|
18 |
|
|
),
|
19 |
|
|
'edit path' => 'admin/structure/menu/manage/%menu/edit',
|
20 |
|
|
// Auto-generate translate tab.
|
21 |
|
|
'translate tab' => 'admin/structure/menu/manage/%menu/translate',
|
22 |
|
|
// We can easily list all these objects
|
23 |
|
|
'list callback' => 'menu_load_all',
|
24 |
|
|
// Metadata for string translation
|
25 |
|
|
'string translation' => array(
|
26 |
|
|
'textgroup' => 'menu',
|
27 |
|
|
'type' => 'menu',
|
28 |
|
|
'properties' => array(
|
29 |
|
|
'title' => t('Title'),
|
30 |
|
|
'description' => t('Description'),
|
31 |
|
|
),
|
32 |
|
|
),
|
33 |
|
|
'translation container' => array(
|
34 |
|
|
'name' => t('menu'),
|
35 |
|
|
'item type' => 'menu_link',
|
36 |
|
|
'item name' => t('menu items'),
|
37 |
|
|
'options' => array(I18N_MODE_NONE, I18N_MODE_MULTIPLE, I18N_MODE_LANGUAGE),
|
38 |
|
|
),
|
39 |
|
|
);
|
40 |
|
|
$info['menu_link'] = array(
|
41 |
|
|
'title' => t('Menu link'),
|
42 |
|
|
'class' => 'i18n_menu_link',
|
43 |
|
|
'key' => 'mlid',
|
44 |
|
|
'load callback' => 'menu_link_load',
|
45 |
|
|
'base path' => 'admin/structure/menu/item',
|
46 |
|
|
'edit path' => 'admin/structure/menu/item/%menu_link/edit',
|
47 |
|
|
// Auto-generate translate tab
|
48 |
|
|
'translate tab' => 'admin/structure/menu/item/%menu_link/translate',
|
49 |
|
|
'placeholders' => array(
|
50 |
|
|
'%menu_link' => 'mlid',
|
51 |
|
|
'%menu' => 'menu_name',
|
52 |
|
|
),
|
53 |
|
|
'string translation' => array(
|
54 |
|
|
'textgroup' => 'menu',
|
55 |
|
|
'type' => 'item',
|
56 |
|
|
'properties' => array(
|
57 |
|
|
'title' => array(
|
58 |
|
|
'title' => t('Title'),
|
59 |
|
|
'field' => 'link_title',
|
60 |
|
|
),
|
61 |
|
|
'description' => array(
|
62 |
|
|
'title' => t('Description'),
|
63 |
|
|
'field' => 'options.attributes.title',
|
64 |
|
|
),
|
65 |
|
|
),
|
66 |
|
|
),
|
67 |
|
|
'translation set' => TRUE,
|
68 |
|
|
);
|
69 |
|
|
return $info;
|
70 |
|
|
}
|
71 |
|
|
|
72 |
|
|
/**
|
73 |
|
|
* Implements hook_i18n_translation_set_info()
|
74 |
|
|
*/
|
75 |
|
|
function i18n_menu_i18n_translation_set_info() {
|
76 |
|
|
$info['menu_link'] = array(
|
77 |
|
|
'title' => t('Menu link'),
|
78 |
|
|
'class' => 'i18n_menu_link_translation_set',
|
79 |
|
|
'table' => 'menu_links',
|
80 |
|
|
'field' => 'i18n_tsid',
|
81 |
|
|
'parent' => 'menu',
|
82 |
|
|
'placeholder' => '%i18n_menu_translation',
|
83 |
|
|
'list path' => 'admin/structure/menu/manage/translation',
|
84 |
|
|
'edit path' => 'admin/structure/menu/manage/translation/edit/%i18n_menu_translation',
|
85 |
|
|
'delete path' => 'admin/structure/menu/manage/translation/delete/%i18n_menu_translation',
|
86 |
|
|
'page callback' => 'i18n_menu_item_translation_page',
|
87 |
|
|
);
|
88 |
|
|
return $info;
|
89 |
|
|
}
|
90 |
|
|
|
91 |
|
|
/**
|
92 |
|
|
* Implements hook_i18n_string_info()
|
93 |
|
|
*/
|
94 |
|
|
function i18n_menu_i18n_string_info() {
|
95 |
|
|
$groups['menu'] = array(
|
96 |
|
|
'title' => t('Menu'),
|
97 |
|
|
'description' => t('Translatable menu items: title and description.'),
|
98 |
|
|
'format' => FALSE, // This group doesn't have strings with format
|
99 |
|
|
'list' => TRUE, // This group can list all strings
|
100 |
|
|
);
|
101 |
|
|
return $groups;
|
102 |
|
|
}
|
103 |
|
|
|
104 |
|
|
/**
|
105 |
|
|
* Implements hook_i18n_string_objects()
|
106 |
|
|
*/
|
107 |
|
|
function i18n_menu_i18n_string_objects($type) {
|
108 |
|
|
if ($type == 'menu_link') {
|
109 |
|
|
// All menu items that have no language and are customized.
|
110 |
|
|
return db_select('menu_links', 'm')
|
111 |
|
|
->fields('m')
|
112 |
|
|
->condition('language', LANGUAGE_NONE)
|
113 |
|
|
->condition('customized', 1)
|
114 |
|
|
->execute()
|
115 |
|
|
->fetchAllAssoc('mlid', PDO::FETCH_ASSOC);
|
116 |
|
|
}
|
117 |
|
|
}
|
118 |
|
|
|
119 |
|
|
/**
|
120 |
|
|
* Callback for menu item translation tab.
|
121 |
|
|
*/
|
122 |
|
|
function i18n_menu_item_translation_page($type, $item) {
|
123 |
|
|
module_load_include('admin.inc', 'i18n_menu');
|
124 |
|
|
// If the item has a language code, we can only support translation sets.
|
125 |
|
|
$translation_set = !empty($item['i18n_tsid']) ? i18n_translation_set_load($item['i18n_tsid']) : NULL;
|
126 |
6331c987
|
Assos Assos
|
$overview = i18n_menu_translation_item_overview($item, $translation_set);
|
127 |
|
|
$translation_form = drupal_get_form('i18n_menu_translation_form', $translation_set, $item);
|
128 |
|
|
return $overview + $translation_form;
|
129 |
85ad3d82
|
Assos Assos
|
}
|