function locale_requirements in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/locale/locale.install \locale_requirements()
Implements hook_requirements().
File
- core/
modules/ locale/ locale.install, line 237 - Install, update, and uninstall functions for the Locale module.
Code
function locale_requirements($phase) {
$requirements = array();
if ($phase == 'runtime') {
$available_updates = array();
$untranslated = array();
$languages = locale_translatable_language_list();
if ($languages) {
// Determine the status of the translation updates per language.
$status = locale_translation_get_status();
if ($status) {
foreach ($status as $project) {
foreach ($project as $langcode => $project_info) {
if (empty($project_info->type)) {
$untranslated[$langcode] = $languages[$langcode]
->getName();
}
elseif ($project_info->type == LOCALE_TRANSLATION_LOCAL || $project_info->type == LOCALE_TRANSLATION_REMOTE) {
$available_updates[$langcode] = $languages[$langcode]
->getName();
}
}
}
if ($available_updates || $untranslated) {
if ($available_updates) {
$requirements['locale_translation'] = array(
'title' => 'Translation update status',
'value' => \Drupal::l(t('Updates available'), new Url('locale.translate_status')),
'severity' => REQUIREMENT_WARNING,
'description' => t('Updates available for: @languages. See the <a href=":updates">Available translation updates</a> page for more information.', array(
'@languages' => implode(', ', $available_updates),
':updates' => \Drupal::url('locale.translate_status'),
)),
);
}
else {
$requirements['locale_translation'] = array(
'title' => 'Translation update status',
'value' => t('Missing translations'),
'severity' => REQUIREMENT_INFO,
'description' => t('Missing translations for: @languages. See the <a href=":updates">Available translation updates</a> page for more information.', array(
'@languages' => implode(', ', $untranslated),
':updates' => \Drupal::url('locale.translate_status'),
)),
);
}
}
else {
$requirements['locale_translation'] = array(
'title' => 'Translation update status',
'value' => t('Up to date'),
'severity' => REQUIREMENT_OK,
);
}
}
else {
$requirements['locale_translation'] = array(
'title' => 'Translation update status',
'value' => \Drupal::l(t('Can not determine status'), new Url('locale.translate_status')),
'severity' => REQUIREMENT_WARNING,
'description' => t('No translation status is available. See the <a href=":updates">Available translation updates</a> page for more information.', array(
':updates' => \Drupal::url('locale.translate_status'),
)),
);
}
}
}
return $requirements;
}