forked from backdrop/backdrop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
translation.install
68 lines (61 loc) · 1.91 KB
/
translation.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?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();
}
}
/**
* @} End of "addtogroup updates-7.x-to-1.x"
* The next series of updates should start at 2000.
*/