locale_translation_download_source($source_file, $directory = 'temporary://')
Downloads a translation file from a remote server.
Parameters
object $source_file: Source file object with at least:
- "uri": uri to download the file from.
- "project": Project name.
- "langcode": Translation language.
- "version": Project version.
- "filename": File name.
string $directory: Directory where the downloaded file will be saved. Defaults to the temporary file path.
Return value
object File object if download was successful. FALSE on failure.
File
- core/modules/locale/locale.batch.inc, line 292
- Batch process to check the availability of remote or local po files.
Code
1 2 3 4 5 6 7 8 9 10 11 12 | if ( $uri = system_retrieve_file( $source_file ->uri, $directory )) { $file = clone ( $source_file ); $file ->type = LOCALE_TRANSLATION_LOCAL; $file ->uri = $uri ; $file ->directory = $directory ; $file ->timestamp = filemtime ( $uri ); return $file ; } \Drupal::logger( 'locale' )->error( 'Unable to download translation file @uri.' , array ( '@uri' => $source_file ->uri)); return FALSE; } |
Please login to continue.