function _drush_l10n_update_validate_languages in Localization update 7
Same name and namespace in other branches
- 6 l10n_update.drush.inc \_drush_l10n_update_validate_languages()
- 7.2 l10n_update.drush.inc \_drush_l10n_update_validate_languages()
Helper function to validate languages.
Used by _validate hooks. 1. Check other languages than english are available. 2. Check user provided languages are valid.
2 calls to _drush_l10n_update_validate_languages()
- drush_l10n_update_status_validate in ./
l10n_update.drush.inc - Validate command l10n-update-status.
- drush_l10n_update_validate in ./
l10n_update.drush.inc - Validate command l10n-update.
File
- ./
l10n_update.drush.inc, line 160 - Drush interface to l10n-update functionalities.
Code
function _drush_l10n_update_validate_languages() {
// Check there're installed other languages than english.
$installed_languages = l10n_update_language_list();
if (empty($installed_languages)) {
return drush_set_error('L10N_UPDATE_NO_LANGUAGES', dt('No languages to update.'));
}
// Check provided languages are valid.
$languages = drush_get_option('languages', '');
$languages = array_map('trim', _convert_csv_to_array($languages));
if (count($languages)) {
foreach ($languages as $key => $lang) {
if (!isset($installed_languages[$lang])) {
drush_set_error('L10N_UPDATE_INVALID_LANGUAGE', dt('Language @lang is not installed.', array(
'@lang' => $lang,
)));
}
else {
unset($languages[$key]);
$languages[$lang] = $installed_languages[$lang];
}
}
if (drush_get_error() != DRUSH_SUCCESS) {
drush_print(dt('Available languages: @languages', array(
'@languages' => implode(', ', array_keys($installed_languages)),
)));
}
}
else {
$languages = $installed_languages;
}
drush_set_option('languages', $languages);
}