function lingotek_add_missing_locales in Lingotek Translation 7.6
Same name and namespace in other branches
- 7.7 lingotek.util.inc \lingotek_add_missing_locales()
- 7.2 lingotek.util.inc \lingotek_add_missing_locales()
- 7.3 lingotek.util.inc \lingotek_add_missing_locales()
- 7.4 lingotek.util.inc \lingotek_add_missing_locales()
- 7.5 lingotek.util.inc \lingotek_add_missing_locales()
Fills in any missing lingotek_locale values to the languages table
3 calls to lingotek_add_missing_locales()
- Lingotek::getLanguages in lib/
Drupal/ lingotek/ Lingotek.php - Gets the site's available target languages for Lingotek translation.
- lingotek_add_target_language in ./
lingotek.util.inc - Adds the target language as being enabled.
- lingotek_update_7210 in ./
lingotek.install - Extend languages table to have lingotek_locale field
File
- ./
lingotek.util.inc, line 885 - Utility functions.
Code
function lingotek_add_missing_locales($show_message = TRUE) {
LingotekLog::trace(__METHOD__);
$languages = language_list();
$default_language = language_default();
$update_static_language_list = FALSE;
$added_locales = array();
foreach ($languages as $target) {
if (isset($target->lingotek_locale) && !strlen($target->lingotek_locale)) {
$drupal_language_code = $target->language;
$lingotek_locale = Lingotek::convertDrupal2Lingotek($drupal_language_code, FALSE);
lingotek_enable_language_by_code($drupal_language_code, $lingotek_locale);
$update_static_language_list = TRUE;
$added_locales[] = $lingotek_locale;
}
}
if ($update_static_language_list) {
drupal_static_reset('language_list');
}
if (!empty($added_locales)) {
drupal_set_message(t('Added the following locales to the languages table: @added.', array(
'@added' => implode(', ', $added_locales),
)));
}
else {
if ($show_message) {
drupal_set_message(t('All locales already set in the languages table.'));
}
}
}