summaryrefslogtreecommitdiffstats
path: root/i18n_string/i18n_string.variable.inc
blob: f6a7a8cb2fbb5a3f1343d69442c8b5f689e35de7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
/**
 * @file
 * Variable information
 */

/**
 * Implements hook_variable_info().
 */
function i18n_string_variable_info($options = array()) {
  $variables['i18n_string_translate_langcode_[language]'] = array(
    'type' => 'multiple_language',
    'title' => t('Enable translation for language'),
    'multiple values' => array('type' => 'boolean'),
    'group' => 'i18n',
  );
  $variables['i18n_string_allowed_formats'] = array(
    'title' => t('Translatable text formats'),
    'options callback' => 'i18n_string_variable_format_list',
    'type' => 'options',
    'default callback' => 'i18n_string_variable_format_default',
    'description' => t('Only the strings that have the text formats selected will be allowed by the translation system. All the others will be deleted next time the strings are refreshed.'),
  );
  $variables['i18n_string_source_language'] = array(
    'title' => t('Source language'),
    'type' => 'language',
    'default callback' => 'i18n_string_source_language',
    'description' => t('Language that will be used as the source language for string translations. The default is the site default language.'),
  );
  $variables['i18n_string_debug'] = array(
    'type' => 'enable',
    'title' => t('Debug string translation', array(), $options),
    'default' => 0,
    'group' => 'debug',
  );
  return $variables;
}

/**
 * Options callback, format list
 */
function i18n_string_variable_format_list() {
  $list = array();
  // As the user has administer filters permissions we get a full list here
  foreach (filter_formats() as $fid => $format) {
    $list[$fid] = $format->name;
  }
  return $list;
}

/**
 * Allowed formats default value
 */
function i18n_string_variable_format_default() {
  return array(filter_fallback_format());
}