function _features_language_save in Features 7
Same name and namespace in other branches
- 7.2 includes/features.locale.inc \_features_language_save()
Helper function to save the language to database.
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 111 - Features hooks for language.
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,
))
->condition('language', $language->language)
->execute();
}
else {
// @TODO: get properties from schema.
$properties = array(
'language',
'name',
'native',
'direction',
'enabled',
'plurals',
'formula',
'domain',
'prefix',
'weight',
);
$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);
}
}
}