Projet

Général

Profil

Paste
Télécharger (3,57 ko) Statistiques
| Branche: | Révision:

root / htmltest / sites / all / modules / i18n / i18n.api.php @ a5572547

1
<?php
2
/**
3
 * @file
4
 * API documentation for Internationalization module
5
 *
6
 * Most i18n hooks can be placed on each module.i18n.inc file but in this case
7
 * such file must be listed in the module.info file.
8
 */
9

    
10

    
11
/**
12
 * Provide information about object types handled by i18n system.
13
 *
14
 * @see i18n_object_info()
15
 *
16
 * Other features like translation sets (i18n_translation) or string translation (i18n_string)
17
 * rely on the information provided by this hook for automating string translation
18
 */
19
function hook_i18n_object_info() {
20
  // Information for node type object, see i18n_node_i18n_object_info()
21
  $info['node_type'] = array(
22
    // Generic object properties, title, etc..
23
    'title' => t('Node type'),
24
    // Field to be used as key to index different node types
25
    'key' => 'type',
26
    // Mapping object fields and menu place holders
27
    'placeholders' => array(
28
            '%node_type' => 'type',
29
    ),
30
    // Path for automatically generated translation tabs. Note placeholders above are used here.
31
    'edit path' => 'admin/structure/types/manage/%node_type',
32
    'translate tab' => 'admin/structure/types/manage/%node_type/translate',
33
    // We can easily list all these objects because they should be limited and manageable
34
    // Only in this case we provide a 'list callback'.
35
    'list callback' => 'node_type_get_types',
36
    // Metadata for string translation
37
    // In this case we are defining fields and keys for string translation's string names
38
    // String ids are of the form: [textgroup]:[type]:[key]:[property]
39
    // Thus in this case we'll have string names like
40
    // - node:type:story:name
41
    // - node:type:story:description
42
    'string translation' => array(
43
      'textgroup' => 'node',
44
      'type' => 'type',
45
      'properties' => array(
46
        'name' => t('Name'),
47
        'title_label' => t('Title label'),
48
        'description' => t('Description'),
49
        'help' => t('Help text'),
50
      ),
51
      'translate path' => 'admin/structure/types/manage/%node_type/translate/%i18n_language',
52
    )
53
  );
54
  // Example information for taxonomy term object, see i18n_taxonomy_i18n_object_info().
55
  $info['taxonomy_term'] = array(
56
    'title' => t('Taxonomy term'),
57
    'class' => 'i18n_taxonomy_term',
58
    'entity' => 'taxonomy_term',
59
    'key' => 'tid',
60
    'placeholders' => array(
61
      '%taxonomy_term' => 'tid',
62
    ),
63
    // Auto generate edit path
64
    'edit path' => 'taxonomy/term/%taxonomy_term/edit',
65
    // Auto-generate translate tab
66
    'translate tab' => 'taxonomy/term/%taxonomy_term/translate',
67
    'string translation' => array(
68
      'textgroup' => 'taxonomy',
69
      'type' => 'term',
70
      'properties' => array(
71
        'name' => t('Name'),
72
        'description' => array(
73
          'title' => t('Description'),
74
          'format' => 'format',
75
        ),
76
      ),
77
    )
78
  );
79
  return $info;
80
}
81

    
82
/**
83
 * Alter i18n object information provided by modules with the previous hook
84
 *
85
 * @see i18n_object_info()
86
 */
87
function hook_i18n_object_info_alter(&$info) {
88
}
89

    
90
/**
91
 * Provide information about available translations for specific path.
92
 *
93
 * @see i18n_get_path_translations($path)
94
 *
95
 * @param $path
96
 *   Internal path to translate.
97
 * @return array
98
 *   Translations indexed by language code. Each translation is an array with:
99
 *   - 'path'
100
 *   - 'title'
101
 *   - 'options'
102
 */
103
function hook_i18n_translate_path($path) {
104
  if ($path == 'mypath') {
105
    $translations['es'] = array(
106
      'path' => 'mypath/spanish',
107
      'title' => t('My Spanish translation'),
108
    );
109
    return $translations;
110
  }
111
}
112

    
113
/**
114
 * Alter path translations
115
 */
116
function hook_i18n_translate_path_alter(&$translations, $path) {
117
}