View source
<?php
_i18n_test_variable_init();
function i18n_test_init() {
}
function _i18n_test_variable_init() {
global $conf;
$conf['i18n_variables'] = array_merge(array(
'site_name',
'site_frontpage',
), variable_get('i18n_variables_test', array()));
}
function i18n_test_i18n_string_info() {
$groups['test'] = array(
'title' => t('Test'),
'description' => t('Translatable menu items: title and description.'),
'format' => FALSE,
'refresh callback' => 'i18n_test_i18n_string_refresh',
);
$groups['test_cached'] = array(
'title' => t('Test Cached Strings'),
'description' => t('Translatable items of a textgroup with caching enabled.'),
'format' => FALSE,
'class' => variable_get('i18n_string_textgroup_class_test_cached', 'i18n_string_textgroup_cached_logged'),
);
return $groups;
}
function i18n_test_i18n_string_refresh() {
return TRUE;
}
function i18n_test_menu() {
$items['tests/i18n/i18n_string_build/%'] = array(
'title' => 'Load string',
'access callback' => TRUE,
'page callback' => 'i18n_string_build',
'page arguments' => array(
3,
),
'type' => MENU_CALLBACK,
'delivery callback' => 'drupal_json_output',
);
$items['tests/i18n/i18n_string_build/%/%'] = array(
'title' => 'Load string',
'access callback' => TRUE,
'page callback' => 'i18n_string_build',
'page arguments' => array(
3,
4,
),
'type' => MENU_CALLBACK,
'delivery callback' => 'drupal_json_output',
);
$items['tests/i18n/i18n_string_translation_search/%'] = array(
'title' => 'Search string translations',
'access callback' => TRUE,
'page callback' => 'i18n_string_translation_search',
'page arguments' => array(
3,
),
'type' => MENU_CALLBACK,
'delivery callback' => 'drupal_json_output',
);
$items['tests/i18n/i18n_string_translation_search/%/%'] = array(
'title' => 'Search string translations',
'access callback' => TRUE,
'page callback' => 'i18n_string_translation_search',
'page arguments' => array(
3,
4,
),
'type' => MENU_CALLBACK,
'delivery callback' => 'drupal_json_output',
);
return $items;
}
class i18n_string_textgroup_cached_logged extends i18n_string_textgroup_cached {
public static function load_translation($i18nstring, $langcode) {
$strings = variable_get('i18n_loaded_translations', array());
$strings[$i18nstring
->get_name()] = true;
variable_set('i18n_loaded_translations', $strings);
parent::load_translation($i18nstring, $langcode);
}
}