2011-08-02 00:37:34 +00:00
< ? php
/**
2011-08-07 13:10:57 +00:00
* @ file
* Interface translation summary , editing and deletion user interfaces .
2011-08-02 00:37:34 +00:00
*/
2019-07-24 15:48:42 +00:00
use Drupal\Core\Link ;
2014-09-29 13:41:29 +00:00
use Drupal\Core\Url ;
Issue #1668866 by ParisLiakos, aspilicious, tim.plunkett, pdrake, g.oechsler, dawehner, Berdir, corvus_ch, damiankloip, disasm, marcingy, neclimdul: Replace drupal_goto() with RedirectResponse.
2013-06-19 16:07:30 +00:00
use Symfony\Component\HttpFoundation\RedirectResponse ;
2012-06-02 19:41:40 +00:00
2011-08-02 00:37:34 +00:00
/**
2013-09-11 08:14:17 +00:00
* Page callback : Checks for translation updates and displays the status .
2012-10-05 15:42:46 +00:00
*
2013-09-11 08:14:17 +00:00
* Manually checks the translation status without the use of cron .
2012-10-05 15:42:46 +00:00
*
2017-12-20 20:49:05 +00:00
* @ deprecated in Drupal 8.5 . 0 and will be removed before 9.0 . 0. It is unused by
* Drupal core . Duplicate this function in your own extension if you need its
* behavior .
*
* @ see https :// www . drupal . org / node / 2931188
2011-08-02 00:37:34 +00:00
*/
2013-09-11 08:14:17 +00:00
function locale_translation_manual_status () {
2017-12-20 20:49:05 +00:00
@ trigger_error ( 'locale_translation_manual_status() is deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0. It is unused by Drupal core. Duplicate this function in your own extension if you need its behavior.' , E_USER_DEPRECATED );
2013-09-11 08:14:17 +00:00
module_load_include ( 'compare.inc' , 'locale' );
2011-08-02 00:37:34 +00:00
2013-09-11 08:14:17 +00:00
// Check the translation status of all translatable projects in all languages.
// First we clear the cached list of projects. Although not strictly
// necessary, this is helpful in case the project list is out of sync.
locale_translation_flush_projects ();
locale_translation_check_projects ();
Issue #1452188 by Schnitzel, droplet, Sutharsan, Bojhan, Kristen Pol, Gábor Hojtsy, ershov.andrey, perusio, nod_, rvilar, andypost: Added New UI for string translation.
2012-06-15 10:01:31 +00:00
2013-09-11 08:14:17 +00:00
// Execute a batch if required. A batch is only used when remote files
// are checked.
if ( batch_get ()) {
return batch_process ( 'admin/reports/translations' );
Issue #1452188 by Schnitzel, droplet, Sutharsan, Bojhan, Kristen Pol, Gábor Hojtsy, ershov.andrey, perusio, nod_, rvilar, andypost: Added New UI for string translation.
2012-06-15 10:01:31 +00:00
}
2019-04-16 05:38:27 +00:00
return new RedirectResponse ( Url :: fromRoute ( 'locale.translate_status' , [], [ 'absolute' => TRUE ]) -> toString ());
2011-08-02 00:37:34 +00:00
}
2012-12-19 22:11:34 +00:00
/**
2013-06-16 23:54:01 +00:00
* Prepares variables for translation status information templates .
*
* Translation status information is displayed per language .
*
* Default template : locale - translate - edit - form - strings . html . twig .
2012-12-19 22:11:34 +00:00
*
* @ param array $variables
* An associative array containing :
* - updates : The projects which have updates .
* - not_found : The projects which updates are not found .
*
2014-07-15 11:13:13 +00:00
* @ see \Drupal\locale\Form\TranslationStatusForm
2012-12-19 22:11:34 +00:00
*/
2014-10-22 09:58:00 +00:00
function template_preprocess_locale_translation_update_info ( array & $variables ) {
2015-09-27 12:06:27 +00:00
foreach ( $variables [ 'updates' ] as $update ) {
$variables [ 'modules' ][] = $update [ 'name' ];
2012-12-19 22:11:34 +00:00
}
}
/**
2013-06-16 23:54:01 +00:00
* Prepares variables for most recent translation update templates .
*
* Displays the last time we checked for locale update data . In addition to
* properly formatting the given timestamp , this function also provides a " Check
* manually " link that refreshes the available update and redirects back to the
* same page .
2012-12-19 22:11:34 +00:00
*
2013-06-16 23:54:01 +00:00
* Default template : locale - translation - last - check . html . twig .
2012-12-19 22:11:34 +00:00
*
2014-10-22 09:58:00 +00:00
* @ param array $variables
2012-12-19 22:11:34 +00:00
* An associative array containing :
* - last : The timestamp when the site last checked for available updates .
*
2014-07-15 11:13:13 +00:00
* @ see \Drupal\locale\Form\TranslationStatusForm
2012-12-19 22:11:34 +00:00
*/
2014-10-22 09:58:00 +00:00
function template_preprocess_locale_translation_last_check ( array & $variables ) {
2012-12-19 22:11:34 +00:00
$last = $variables [ 'last' ];
2013-06-16 23:54:01 +00:00
$variables [ 'last_checked' ] = ( $last != NULL );
2015-06-09 14:12:03 +00:00
$variables [ 'time' ] = \Drupal :: service ( 'date.formatter' ) -> formatTimeDiffSince ( $last );
2019-07-24 15:48:42 +00:00
$variables [ 'link' ] = Link :: fromTextAndUrl ( t ( 'Check manually' ), Url :: fromRoute ( 'locale.check_translation' , [], [ 'query' => \Drupal :: destination () -> getAsArray ()])) -> toString ();
2012-12-19 22:11:34 +00:00
}