5 * Contains Drupal\Console\Command\Shared\LocaleTrait.
8 namespace Drupal\Console\Command\Shared;
13 * Provides debug info for projects in case translation files are not found.
15 * Translations files are being fetched either from Drupal translation server
16 * and local files or only from the local filesystem depending on the
17 * "Translation source" setting at admin/config/regional/translate/settings.
18 * This method will produce debug information including the respective path(s)
19 * based on this setting.
21 * Translations for development versions are never fetched, so the debug info
22 * for that is a fixed message.
24 * @param array $project_info
25 * An array which is the project information of the source.
28 * The string which contains debug information.
30 protected function createInfoString($project_info)
32 $remote_path = isset($project_info->files['remote']->uri) ? $project_info->files['remote']->uri : false;
33 $local_path = isset($project_info->files['local']->uri) ? $project_info->files['local']->uri : false;
35 if (strpos($project_info->version, 'dev') !== false) {
36 return $this->trans('commands.locale.translation.status.messages.no-translation-files');
38 if (locale_translation_use_remote_source() && $remote_path && $local_path) {
40 $this->trans('commands.locale.translation.status.messages.file-not-found'),
44 } elseif ($local_path) {
47 $this->trans('commands.locale.translation.status.messages.local-file-not-found'),
52 return $this->trans('commands.locale.translation.status.messages.translation-not-determined');
56 * LOCALE_TRANSLATION_REMOTE
57 * and LOCALE_TRANSLATION_LOCAL indicate available new translations,
58 * LOCALE_TRANSLATION_CURRENT indicate that the current translation is them
61 protected function projectsStatus()
64 $status = locale_translation_get_status();
65 foreach ($status as $project_id => $project) {
66 foreach ($project as $langcode => $project_info) {
68 if ($project_info->type == LOCALE_TRANSLATION_LOCAL || $project_info->type == LOCALE_TRANSLATION_REMOTE) {
69 $local = isset($project_info->files[LOCALE_TRANSLATION_LOCAL]) ? $project_info->files[LOCALE_TRANSLATION_LOCAL] : null;
70 $remote = isset($project_info->files[LOCALE_TRANSLATION_REMOTE]) ? $project_info->files[LOCALE_TRANSLATION_REMOTE] : null;
71 $local_age = $local->timestamp? format_date($local->timestamp, 'html_date'): '';
72 $remote_age = $remote->timestamp? format_date($remote->timestamp, 'html_date'): '';
74 if ($local_age >= $remote_age) {
75 $info = $this->trans('commands.locale.translation.status.messages.translation-project-updated');
77 $info = $this->trans('commands.locale.translation.status.messages.translation-project-available');
79 } elseif ($project_info->type == LOCALE_TRANSLATION_CURRENT) {
80 $info = $this->trans('commands.locale.translation.status.messages.translation-project-updated');
84 $info = $this->createInfoString($project_info);
87 $status_report[$langcode][] = [$project_info->name, $project_info->version, $local_age, $remote_age ,$info ];
91 return $status_report;