You are here

function lingotek_bulk_mt_download_batch_create in Lingotek Translation 7.2

Batch Create - Download: Create a Bulk Machine Translate DOWNLOAD Batch.

1 call to lingotek_bulk_mt_download_batch_create()
lingotek_dashboard_mt_download in ./lingotek.batch.inc
Batch Create: Bulk Machine Translate Download.

File

./lingotek.batch.inc, line 262

Code

function lingotek_bulk_mt_download_batch_create($lingotek_locale) {
  $operations = array();
  if ($lingotek_locale) {
    $drupal_language_code = Lingotek::convertLingotek2Drupal($lingotek_locale);

    // NOTE!!!   lingotek_download_document() does its OWN drupal to lingotek lookup.  So pass in the DRUPAL language code
    // Grab nodes that are currently marked 'PENDING'
    $query = db_select('lingotek', 'l')
      ->fields('l');
    $query
      ->condition('lingokey', 'node_sync_status');
    $query
      ->condition('lingovalue', LINGOTEK_TARGET_SYNC_STATUS_PENDING);
    $result = $query
      ->execute();
    while ($record = $result
      ->fetchAssoc()) {
      $operations[] = array(
        'lingotek_download_node_machine_translation',
        array(
          $record['nid'],
          $drupal_language_code,
        ),
      );
    }
    $batch = array(
      'title' => t('Downloading Lingotek Translated Content'),
      'operations' => $operations,
      'finished' => 'lingotek_bulk_mt_download_batch_finished',
      'file' => 'lingotek.batch.inc',
    );
    batch_set($batch);
    batch_process('<front>');

    // Needed if not inside a form _submit handler.  Setting redirect in batch_process.
  }

  // END:  if language_code
}