locale_translation_status_save($project, $langcode, $type, $data)
Saves the status of translation sources in static cache.
Parameters
string $project: Machine readable project name.
string $langcode: Language code.
string $type: Type of data to be stored.
array $data: File object also containing timestamp when the translation is last updated.
File
- core/modules/locale/locale.module, line 919
- Enables the translation of the user interface to languages other than English.
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | function locale_translation_status_save( $project , $langcode , $type , $data ) { // Follow-up issue: https://www.drupal.org/node/1842362. // Split status storage per module/language and expire individually. This will // improve performance for large sites. // Load the translation status or build it if not already available. module_load_include( 'translation.inc' , 'locale' ); $status = locale_translation_get_status(); if ( empty ( $status )) { $projects = locale_translation_get_projects( array ( $project )); if (isset( $projects [ $project ])) { $status [ $project ][ $langcode ] = locale_translation_source_build( $projects [ $project ], $langcode ); } } // Merge the new status data with the existing status. if (isset( $status [ $project ][ $langcode ])) { switch ( $type ) { case LOCALE_TRANSLATION_REMOTE: case LOCALE_TRANSLATION_LOCAL: // Add the source data to the status array. $status [ $project ][ $langcode ]->files[ $type ] = $data ; // Check if this translation is the most recent one. Set timestamp and // data type of the most recent translation source. if (isset( $data ->timestamp) && $data ->timestamp) { if ( $data ->timestamp > $status [ $project ][ $langcode ]->timestamp) { $status [ $project ][ $langcode ]->timestamp = $data ->timestamp; $status [ $project ][ $langcode ]->last_checked = REQUEST_TIME; $status [ $project ][ $langcode ]->type = $type ; } } break ; case LOCALE_TRANSLATION_CURRENT: $data ->last_checked = REQUEST_TIME; $status [ $project ][ $langcode ]->timestamp = $data ->timestamp; $status [ $project ][ $langcode ]->last_checked = $data ->last_checked; $status [ $project ][ $langcode ]->type = $type ; locale_translation_update_file_history( $data ); break ; } \Drupal::state()->set( 'locale.translation_status' , $status ); \Drupal::state()->set( 'locale.translation_last_checked' , REQUEST_TIME); } } |
Please login to continue.