locale_translation_batch_fetch_import($project, $langcode, $options, &$context)
Implements callback_batch_operation().
Imports a gettext file from the translation directory. When successfully the translation status is updated.
Parameters
object $project: Source object of the translatable project.
string $langcode: Language code.
array $options: Array of import options.
array $context: The batch context.
See also
locale_translate_batch_import_files()
locale_translation_batch_fetch_download()
File
- core/modules/locale/locale.batch.inc, line 175
- Batch process to check the availability of remote or local po files.
Code
function locale_translation_batch_fetch_import($project, $langcode, $options, &$context) { $sources = locale_translation_get_status(array($project), array($langcode)); if (isset($sources[$project][$langcode])) { $source = $sources[$project][$langcode]; if (isset($source->type)) { if ($source->type == LOCALE_TRANSLATION_REMOTE || $source->type == LOCALE_TRANSLATION_LOCAL) { $file = $source->files[LOCALE_TRANSLATION_LOCAL]; module_load_include('bulk.inc', 'locale'); $options += array( 'message' => t('Importing translation for %project.', array('%project' => $source->project)), ); // Import the translation file. For large files the batch operations is // progressive and will be called repeatedly until finished. locale_translate_batch_import($file, $options, $context); // The import is finished. if (isset($context['finished']) && $context['finished'] == 1) { // The import is successful. if (isset($context['results']['files'][$file->uri])) { $context['message'] = t('Imported translation for %project.', array('%project' => $source->project)); // Save the data of imported source into the {locale_file} table and // update the current translation status. locale_translation_status_save($project, $langcode, LOCALE_TRANSLATION_CURRENT, $source->files[LOCALE_TRANSLATION_LOCAL]); } } } } } }
Please login to continue.