Skip to content

Commit

Permalink
Fixes #71: Creating vocabulary with multilingual turned off
Browse files Browse the repository at this point in the history
  • Loading branch information
indigoxela committed Apr 22, 2021
1 parent 2a06317 commit 3056b17
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions i18n_taxonomy/i18n_taxonomy.module
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,10 @@ function i18n_taxonomy_taxonomy_term_delete($term) {
* Implements hook_taxonomy_vocabulary_insert().
*/
function i18n_taxonomy_taxonomy_vocabulary_insert($vocabulary) {
i18n_taxonomy_taxonomy_vocabulary_update($vocabulary);
// Update strings.
if ($vocabulary->language && !i18n_object_langcode($vocabulary)) {
i18n_string_object_update('taxonomy_vocabulary', $vocabulary);
}
}

/**
Expand Down Expand Up @@ -768,16 +771,17 @@ function i18n_taxonomy_form_taxonomy_form_vocabulary_alter(&$form, &$form_state)
* Form submit callback to redirect when using the save and translate button.
*/
function i18n_taxonomy_form_vocabulary_submit($form, &$form_state) {
$config = config('taxonomy.vocabulary.' . $form_state['values']['machine_name']);
if (!$form_state['values']['language']) {
$config = config('taxonomy.vocabulary.' . $form_state['values']['machine_name']);
if (!$config->isNew()) {
if ($config->get('i18n_mode') != NULL) {
// Multilingual support has been disabled for this vocab.
$config->delete();
$config->clear('i18n_mode');
$config->clear('langcode');
$config->save();
}
}
else {
if (isset($form_state['values']['i18n_mode'])) {
$config = config('taxonomy.vocabulary.' . $form_state['values']['machine_name']);
$config->set('i18n_mode', $form_state['values']['i18n_mode']);

if (isset($form_state['values']['langcode'])) {
Expand Down

0 comments on commit 3056b17

Please sign in to comment.