You are here

i18n_boxes.module in Boxes translation 6

Same filename and directory in other branches
  1. 7 i18n_boxes.module

File

i18n_boxes.module
View source
<?php

// Tag for localizable block, cannot be any language.
define('I18N_BOXES_LOCALIZE', '__LOCALIZE__');

/**
 * Implementation of hook_ctools_plugin_api().
 */
function i18n_boxes_ctools_plugin_api($module, $api) {
  if ($module == 'boxes' && $api == 'plugins') {
    return array(
      'version' => 1,
    );
  }
}

/**
 * Implementation of hook_boxes_plugins().
 */
function i18n_boxes_boxes_plugins() {
  $info = array();
  $path = drupal_get_path('module', 'i18n_boxes') . '/plugins/boxes';
  $info['i18n'] = array(
    'title' => 'Box (translatable)',
    'handler' => array(
      'parent' => 'simple',
      'class' => 'boxes_i18n',
      'file' => 'boxes_i18n.inc',
      'path' => $path,
    ),
  );
  return $info;
}

/**
 * Implementation of hook_form_alter().
 */
function i18n_boxes_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'block_admin_configure' || $form_id == 'block_box_form' || $form_id == 'block_add_block_form') {

    // Hide the Multilingual fieldset from i18nblocks to avoid confusion.
    if (module_exists('i18nblocks')) {
      $form['i18n']['#access'] = FALSE;
    }
  }
}

/**
 * Implementation of hook_locale().
 */
function i18n_boxes_locale($op = 'groups', $group = NULL) {
  switch ($op) {
    case 'groups':
      return array(
        'boxes' => t('Boxes'),
      );
    case 'info':
      $info['boxes']['refresh callback'] = 'i18n_boxes_locale_refresh';
      $info['boxes']['format'] = TRUE;
      return $info;
  }
}

/**
 * Refresh all strings.
 */
function i18n_boxes_locale_refresh() {
  $boxes = boxes_load();
  if (!empty($boxes)) {
    foreach ($boxes as $delta => $box) {
      if ($box->plugin_key == 'i18n') {
        $box
          ->locale_refresh();
      }
    }
  }
  return TRUE;

  // Meaning it completed with no issues.
}

Functions

Namesort descending Description
i18n_boxes_boxes_plugins Implementation of hook_boxes_plugins().
i18n_boxes_ctools_plugin_api Implementation of hook_ctools_plugin_api().
i18n_boxes_form_alter Implementation of hook_form_alter().
i18n_boxes_locale Implementation of hook_locale().
i18n_boxes_locale_refresh Refresh all strings.

Constants