Install, update and uninstall functions for the Translation module.
<?php /** * @file * Install, update and uninstall functions for the Translation module. */ /** * Implements hook_update_dependencies(). */ function translation_update_dependencies() { // Do not fix language fields until after Views are converted to config. $dependencies['translation'][1001] = array( 'views' => 1001, ); return $dependencies; } /** * @addtogroup updates-7.x-to-1.x * @{ */ /** * Convert translation settings to config. */ function translation_update_1000() { // Create the new config file. $config = config('translation.settings'); $config->set('language_type', update_variable_get('translation_language_type', 'language')); $config->save(); update_variable_del('translation_language_type'); } /** * Fix Views which still have the Drupal 7 version of the language field and * filter. Change from "language" to "langcode". */ function translation_update_1001() { $configs = config_get_names_with_prefix('views.view.'); foreach ($configs as $config_file) { $config = config($config_file); $displays = $config->get('display'); foreach ($displays as $display => $display_details) { if (isset($display_details['display_options']['filters'])) { foreach ($display_details['display_options']['filters'] as $key => $filter) { if ($filter['id'] == 'language') { $config->set('display.' . $display . '.display_options.filters.' . $key . '.field', 'langcode'); } } } if (isset($display_details['display_options']['fields'])) { foreach ($display_details['display_options']['fields'] as $key => $field) { if ($field['id'] == 'language') { $config->set('display.' . $display . '.display_options.fields.' . $key . '.field', 'langcode'); } } } } $config->save(); } } /** * Add "Show content translation links" setting to each content type. */ function translation_update_1002() { $types = config_get_names_with_prefix('node.type.'); foreach ($types as $config_name) { $config = config($config_name); if ($config->get('settings.translation_show_links') === NULL) { $config->set('settings.translation_show_links', TRUE); $config->save(); } } } /** * @} End of "addtogroup updates-7.x-to-1.x" * The next series of updates should start at 2000. */