function _features_language_save in Features 7.2
Same name and namespace in other branches
- 7 includes/features.locale.inc \_features_language_save()
Helper function to save the language to database.
Parameters
\stdClass $language: Language object to save.
See also
\locale_languages_edit_form_submit()
1 call to _features_language_save()
- language_features_rebuild in includes/
features.locale.inc - Implements hook_features_rebuild().
File
- includes/
features.locale.inc, line 116 - Features integration for 'locale' module.
Code
function _features_language_save($language) {
$current_language = db_select('languages')
->condition('language', $language->language)
->fields('languages')
->execute()
->fetchAssoc();
// Set the default language when needed.
$default = language_default();
// Insert new language via api function.
if (empty($current_language)) {
locale_add_language($language->language, $language->name, $language->native, $language->direction, $language->domain, $language->prefix, $language->enabled, $language->language == $default->language);
// Additional params, locale_add_language does not implement.
db_update('languages')
->fields(array(
'plurals' => empty($language->plurals) ? 0 : $language->plurals,
'formula' => empty($language->formula) ? '' : $language->formula,
'weight' => empty($language->weight) ? 0 : $language->weight,
))
->condition('language', $language->language)
->execute();
}
else {
// Get field list from table schema.
$properties = drupal_schema_fields_sql('languages');
// The javascript hash is not in the imported data but should be empty.
if (!isset($language->javascript)) {
$language->javascript = '';
}
$fields = array_intersect_key((array) $language, array_flip($properties));
db_update('languages')
->fields($fields)
->condition('language', $language->language)
->execute();
// Set the default language when needed.
$default = language_default();
if ($default->language == $language->language) {
variable_set('language_default', (object) $fields);
}
}
}