function locale_translate_batch_import

Same name and namespace in other branches
  1. 10 core/modules/locale/locale.bulk.inc \locale_translate_batch_import()
  2. 11.x core/modules/locale/locale.bulk.inc \locale_translate_batch_import()
  3. 9 core/modules/locale/locale.bulk.inc \locale_translate_batch_import()
  4. 8.9.x core/modules/locale/locale.bulk.inc \locale_translate_batch_import()

Implements callback_batch_operation().

Perform interface translation import.

Parameters

object $file: A file object of the gettext file to be imported. The file object must contain a language parameter (other than LanguageInterface::LANGCODE_NOT_SPECIFIED). This is used as the language of the import.

array $options: An array with options that can have the following elements:

  • 'langcode': The language code.
  • 'overwrite_options': Overwrite options array as defined in Drupal\locale\PoDatabaseWriter. Optional, defaults to an empty array.
  • 'customized': Flag indicating whether the strings imported from $file are customized translations or come from a community source. Use LOCALE_CUSTOMIZED or LOCALE_NOT_CUSTOMIZED. Optional, defaults to LOCALE_NOT_CUSTOMIZED.
  • 'message': Alternative message to display during import. Note, this must be sanitized text.

array|\ArrayAccess $context: Contains a list of files imported.

Deprecated

in drupal:11.4.0 and is removed from drupal:13.0.0. Use \Drupal::service(LocaleImportBatch::class)->batchImport() instead.

See also

https://www.drupal.org/node/3589759

File

core/modules/locale/locale.bulk.inc, line 103

Code

function locale_translate_batch_import($file, array $options, &$context) : void {
  @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.4.0 and is removed from drupal:13.0.0. Use \\Drupal::service(LocaleImportBatch::class)->batchImport(). See https://www.drupal.org/node/3589759', E_USER_DEPRECATED);
  if (!$file instanceof LocaleFile) {
    $hash = hash_file(LocaleSource::LOCAL_FILE_HASH_ALGO, $file->uri);
    $file = new LocaleFile($file->filename, $file->uri, $hash);
  }
  \Drupal::service(LocaleImportBatch::class)->batchImport($file, $options, $context);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.