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_taxonomy_i18n_object_info() {
|
11 |
|
|
$info['taxonomy_term'] = array(
|
12 |
|
|
'title' => t('Taxonomy term'),
|
13 |
|
|
'class' => 'i18n_taxonomy_term',
|
14 |
|
|
'entity' => 'taxonomy_term',
|
15 |
|
|
'key' => 'tid',
|
16 |
|
|
'placeholders' => array(
|
17 |
|
|
'%taxonomy_term' => 'tid',
|
18 |
|
|
),
|
19 |
|
|
// Auto generate edit path
|
20 |
|
|
'edit path' => 'taxonomy/term/%taxonomy_term/edit',
|
21 |
|
|
// Auto-generate translate tab
|
22 |
|
|
'translate tab' => 'taxonomy/term/%taxonomy_term/translate',
|
23 |
|
|
'translation set' => TRUE,
|
24 |
|
|
'string translation' => array(
|
25 |
|
|
'textgroup' => 'taxonomy',
|
26 |
|
|
'type' => 'term',
|
27 |
|
|
'properties' => array(
|
28 |
|
|
'name' => t('Name'),
|
29 |
|
|
'description' => array(
|
30 |
|
|
'title' => t('Description'),
|
31 |
|
|
'format' => 'format',
|
32 |
|
|
),
|
33 |
|
|
),
|
34 |
|
|
)
|
35 |
|
|
);
|
36 |
|
|
$info['taxonomy_vocabulary'] = array(
|
37 |
|
|
'title' => t('Vocabulary'),
|
38 |
|
|
'entity' => 'taxonomy_vocabulary',
|
39 |
|
|
'key' => 'vid',
|
40 |
|
|
'placeholders' => array(
|
41 |
|
|
'%taxonomy_vocabulary_machine_name' => 'machine_name',
|
42 |
|
|
),
|
43 |
|
|
// Auto generate edit path
|
44 |
|
|
'edit path' => 'admin/structure/taxonomy/%taxonomy_vocabulary_machine_name/edit',
|
45 |
|
|
// Auto-generate translate tab
|
46 |
|
|
'translate tab' => 'admin/structure/taxonomy/%taxonomy_vocabulary_machine_name/translate',
|
47 |
|
|
// We can easily list all these objects
|
48 |
|
|
'list callback' => 'taxonomy_get_vocabularies',
|
49 |
|
|
// Metadata for string translation
|
50 |
|
|
'string translation' => array(
|
51 |
|
|
'textgroup' => 'taxonomy',
|
52 |
|
|
'type' => 'vocabulary',
|
53 |
|
|
'properties' => array(
|
54 |
|
|
'name' => t('Name'),
|
55 |
|
|
'description' => t('Description'),
|
56 |
|
|
),
|
57 |
|
|
),
|
58 |
|
|
'translation container' => array(
|
59 |
|
|
'name' => t('vocabulary'),
|
60 |
|
|
'item type' => 'taxonomy_term',
|
61 |
|
|
'item name' => t('terms'),
|
62 |
|
|
'options' => array(I18N_MODE_NONE, I18N_MODE_LOCALIZE, I18N_MODE_TRANSLATE, I18N_MODE_LANGUAGE),
|
63 |
|
|
),
|
64 |
|
|
);
|
65 |
|
|
return $info;
|
66 |
|
|
}
|
67 |
|
|
|
68 |
|
|
/**
|
69 |
|
|
* Implements hook_i18n_translation_set_info()
|
70 |
|
|
*/
|
71 |
|
|
function i18n_taxonomy_i18n_translation_set_info() {
|
72 |
|
|
$info['taxonomy_term'] = array(
|
73 |
|
|
'title' => t('Taxonomy term'),
|
74 |
|
|
'class' => 'i18n_taxonomy_translation_set',
|
75 |
|
|
'table' => 'taxonomy_term_data',
|
76 |
|
|
'field' => 'i18n_tsid',
|
77 |
|
|
'parent' => 'taxonomy_vocabulary',
|
78 |
|
|
'placeholder' => '%i18n_taxonomy_translation_set',
|
79 |
|
|
'list path' => 'admin/structure/taxonomy/%taxonomy_vocabulary_machine_name/list/sets',
|
80 |
|
|
'edit path' => 'admin/structure/taxonomy/%taxonomy_vocabulary_machine_name/list/sets/edit/%i18n_taxonomy_translation_set',
|
81 |
|
|
'delete path' => 'admin/structure/taxonomy/%taxonomy_vocabulary_machine_name/list/sets/delete/%i18n_taxonomy_translation_set',
|
82 |
|
|
'page callback' => 'i18n_taxonomy_term_translation_page',
|
83 |
|
|
);
|
84 |
|
|
return $info;
|
85 |
|
|
}
|
86 |
|
|
|
87 |
|
|
/**
|
88 |
|
|
* Implements hook_i18n_string_info()
|
89 |
|
|
*/
|
90 |
|
|
function i18n_taxonomy_i18n_string_info() {
|
91 |
|
|
$groups['taxonomy'] = array(
|
92 |
|
|
'title' => t('Taxonomy'),
|
93 |
|
|
'description' => t('Vocabulary titles and term names for localizable vocabularies.'),
|
94 |
|
|
'format' => FALSE, // This group doesn't have strings with format
|
95 |
|
|
'list' => FALSE, // This group cannot list all strings
|
96 |
|
|
'refresh callback' => 'i18n_taxonomy_i18n_string_refresh',
|
97 |
|
|
);
|
98 |
|
|
return $groups;
|
99 |
|
|
}
|
100 |
|
|
|
101 |
|
|
/**
|
102 |
|
|
* Implements hook_i18n_string_objects()
|
103 |
|
|
*/
|
104 |
|
|
function i18n_taxonomy_i18n_string_objects($type) {
|
105 |
|
|
if ($type == 'taxonomy_term') {
|
106 |
|
|
$terms = array();
|
107 |
|
|
foreach (taxonomy_get_vocabularies() as $vid => $vocabulary) {
|
108 |
|
|
if (isset($vocabulary->i18n_mode) && $vocabulary->i18n_mode & I18N_MODE_LOCALIZE) {
|
109 |
|
|
foreach (taxonomy_get_tree($vid, 0) as $term) {
|
110 |
|
|
$terms[] = $term;
|
111 |
|
|
}
|
112 |
|
|
}
|
113 |
|
|
}
|
114 |
|
|
return $terms;
|
115 |
|
|
}
|
116 |
|
|
}
|
117 |
|
|
|
118 |
|
|
/**
|
119 |
|
|
* Callback for term translation tab.
|
120 |
|
|
*
|
121 |
|
|
* @param $type
|
122 |
|
|
* Should be always 'taxonomy_term'
|
123 |
|
|
* @pram $term
|
124 |
|
|
* Taxonomy term object
|
125 |
|
|
*/
|
126 |
|
|
function i18n_taxonomy_term_translation_page($type, $term) {
|
127 |
|
|
module_load_include('admin.inc', 'i18n_taxonomy');
|
128 |
|
|
$vocabulary = taxonomy_vocabulary_load($term->vid);
|
129 |
|
|
$translation_set = !empty($term->i18n_tsid) ? i18n_translation_set_load($term->i18n_tsid) : NULL;
|
130 |
|
|
|
131 |
|
|
$translation_overview = i18n_taxonomy_translation_term_overview($term);
|
132 |
|
|
|
133 |
|
|
$translation_term_form = drupal_get_form('i18n_taxonomy_translation_term_form', $vocabulary, $translation_set, $term);
|
134 |
|
|
|
135 |
|
|
return $translation_overview + $translation_term_form;
|
136 |
|
|
} |