function lingotek_admin_additional_translation_settings_form in Lingotek Translation 7.7
Same name and namespace in other branches
- 7.3 lingotek.admin.inc \lingotek_admin_additional_translation_settings_form()
- 7.4 lingotek.admin.inc \lingotek_admin_additional_translation_settings_form()
- 7.5 lingotek.admin.inc \lingotek_admin_additional_translation_settings_form()
- 7.6 lingotek.admin.inc \lingotek_admin_additional_translation_settings_form()
Additional translation form
1 call to lingotek_admin_additional_translation_settings_form()
1 string reference to 'lingotek_admin_additional_translation_settings_form'
File
- ./
lingotek.admin.inc, line 729
Code
function lingotek_admin_additional_translation_settings_form($form, &$form_state, $show_fieldset = FALSE) {
global $base_url;
$api = LingotekApi::instance();
$site = variable_get('site_name', 'Drupal Site');
$setup_complete = !lingotek_is_config_missing();
$account = LingotekAccount::instance();
$show_advanced = $account
->showAdvanced();
$title_str = $setup_complete ? t('Configuration Translation') : t('Which additional items do you want translated?');
// Configuration translation (ie. taxonomies, menus, etc.)
$form['additional_translation'] = array(
'#type' => $show_fieldset ? 'fieldset' : 'item',
'#title' => check_plain($title_str),
//'#description' => t('Enable/disable and set defaults for comment translation.'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => 'administrative_settings',
'actions' => array(
'#type' => 'actions',
'submit' => array(
'#type' => 'submit',
'#value' => t('Save'),
),
),
'#validate' => array(
'lingotek_admin_additional_translation_settings_form_validate',
),
'#submit' => array(
'lingotek_admin_additional_translation_settings_form_submit',
),
);
$header = array(
'Type',
'Description',
);
$prep_blocks_chbx = array(
'#id' => 'lingotek_prepare_config_blocks',
'#type' => 'checkbox',
'#title' => t('Update all blocks to be translatable in the Languages settings.'),
'#attributes' => array(
'id' => array(
'lingotek_prepare_config_blocks',
),
'name' => 'lingotek_prepare_config_blocks',
'class' => array(
'field',
),
),
'#default_value' => 1,
);
$prep_taxonomy_chbx = array(
'#id' => 'lingotek_prepare_config_taxonomies',
'#type' => 'checkbox',
'#title' => t('Update all taxonomy vocabularies that are not currently enabled for multilingual to use translation mode \'Localize\' in the Multilingual Options. (Note: Translation mode \'Localize\' does not support translation of custom fields within taxonomy terms.)'),
'#attributes' => array(
'id' => array(
'lingotek_prepare_config_taxonomies',
),
'name' => 'lingotek_prepare_config_taxonomies',
'class' => array(
'field',
),
),
'#default_value' => 1,
);
$prep_menus_chbx = array(
'#id' => 'lingotek_prepare_config_menus',
'#type' => 'checkbox',
'#title' => t('Update all menus to use \'Translate and Localize\' in the Multilingual Options.'),
'#attributes' => array(
'id' => array(
'lingotek_prepare_config_menus',
),
'name' => 'lingotek_prepare_config_menus',
'class' => array(
'field',
),
),
'#default_value' => 1,
);
$hidden_i18nviews_value = array(
'#id' => 'lingotek_i18nviews_enabled',
'#type' => 'hidden',
'#value' => module_exists('i18nviews'),
);
$hidden_i18n_field_value = array(
'#id' => 'lingotek_i18n_field_enabled',
'#type' => 'hidden',
'#value' => module_exists('i18n_field'),
);
$options = array(
'lingotek_translate_config_blocks' => array(
t('Blocks'),
t('Include translation for all translatable blocks.') . drupal_render($prep_blocks_chbx),
),
'lingotek_translate_config_taxonomies' => array(
t('Taxonomy'),
t('Include translation for all translatable taxonomy vocabularies and terms.') . drupal_render($prep_taxonomy_chbx),
),
'lingotek_translate_config_menus' => array(
t('Menus'),
t('Include translation for all menus set to \'Translate and Localize\'.') . drupal_render($prep_menus_chbx),
),
'lingotek_translate_config_views' => array(
t('Views'),
t('Include translation of all translatable strings within views. This will not generally include translation of all results generated by each view, which is usually configurable by selecting localizable fields within the view itself. (Note: You must have the <a href="https://drupal.org/project/i18nviews" target="_blank">i18nviews</a> module enabled in order to use this.)') . drupal_render($hidden_i18nviews_value),
),
'lingotek_translate_config_fields' => array(
t('Field Labels'),
t('Include translation of all translatable field labels. (Note: You must have the <a href="https://drupal.org/project/i18n" target="_blank">i18n_field</a> sub-module enabled in order to use this.)') . drupal_render($hidden_i18n_field_value),
),
'lingotek_translate_config_builtins' => array(
t('Built-in Interface'),
t('Include translation of built-in strings. (Note: Indexing all of these may take several minutes or longer.)'),
),
'lingotek_translate_config_misc' => array(
t('Miscellaneous Strings'),
t('Include translation of any other miscellaneous strings found by the Internationalization (i18n) module.'),
),
);
if (module_exists('webform') && module_exists('webform_localization')) {
$options['lingotek_translate_config_webform'] = array(
t('Webform'),
t('Include translation of Webform components. (Note: Requires <i>Webform</i> and <i>Webform Localization</i> modules.)'),
);
}
$defaults = array();
foreach (array_keys($options) as $config_type) {
$defaults[$config_type] = variable_get($config_type, 0);
}
$form['additional_translation']['config'] = array(
'#type' => 'tableselect',
'#header' => $header,
'#options' => $options,
'#default_value' => $defaults,
);
$profiles = variable_get('lingotek_profiles');
$workflows = $api
->listWorkflows();
$config_profile = LingotekProfile::loadById(LingotekSync::PROFILE_CONFIG);
if (is_array($workflows) && count($workflows) > 1 && $setup_complete) {
$stored_workflow_id = $config_profile
->getWorkflow();
$selected_workflow_id = isset($form_state['values']['addtl_workflow_id']) ? $form_state['values']['addtl_workflow_id'] : $stored_workflow_id;
$curr_workflow = $api
->getWorkflow($stored_workflow_id);
if (!empty($curr_workflow)) {
// append the current workflow to the top of the workflow list, if it's not already there
$workflows = array(
$stored_workflow_id => $curr_workflow->name,
) + $workflows;
}
$form['additional_translation']['addtl_workflow_id'] = array(
'#type' => 'select',
'#title' => t('Workflow'),
'#description' => t('This workflow will be used for handling these additional translation items.'),
'#default_value' => $stored_workflow_id,
'#options' => $workflows,
'#ajax' => array(
'callback' => 'lingotek_config_default_workflow_form_callback',
'wrapper' => 'addtl-prefill-phases-div',
'method' => 'replace',
'effect' => 'fade',
),
'#prefix' => '<div id="addtl-prefill-phases-div">',
);
$form['additional_translation']['addtl_prefill_phases_checkbox'] = array(
'#type' => 'checkbox',
// '#title' => t('Change all current content in this profile (@total in total) to use the new workflow', array('@total' => array_sum(lingotek_admin_profile_usage(LingotekSync::PROFILE_CONFIG)))),
'#title' => t('Change all current content in this profile to use the new workflow'),
'#default_value' => FALSE,
'#description' => t('All current translations will be removed and recreated using the new workflow, with translations pulled from the previous workflow'),
'#states' => array(
'invisible' => array(
':input[name="addtl_workflow_id"]' => array(
'value' => $stored_workflow_id,
),
),
),
);
$form['additional_translation']['overwrite_config_set_workflow'] = array(
'#type' => 'checkbox',
'#title' => t('Include config sets that have been explicitly changed to another workflow.'),
'#default_value' => FALSE,
'#description' => t('All config sets will be changed, regardless of individual changes made'),
'#states' => array(
'visible' => array(
':input[name="addtl_workflow_id"]' => array(
'!value' => $stored_workflow_id,
),
':input[name="addtl_prefill_phases_checkbox"]' => array(
'checked' => TRUE,
),
),
),
);
$form['additional_translation']['addtl_prefill_phase_select'] = array(
'#title' => t("Desired Prefill Phase"),
'#description' => t('Please select the highest phase which should be prefilled for the new workflow'),
'#type' => 'select',
'#states' => array(
'visible' => array(
':input[name="addtl_workflow_id"]' => array(
'!value' => $stored_workflow_id,
),
':input[name="addtl_prefill_phases_checkbox"]' => array(
'checked' => TRUE,
),
),
),
'#suffix' => '</div>',
);
$form['additional_translation']['addtl_prefill_phase_select']['#options'] = lingotek_get_phases_by_workflow_id($selected_workflow_id);
}
// Projects
$projects = class_exists('LingotekApi') ? $api
->listProjects() : FALSE;
$project_id = variable_get('lingotek_project', '');
// If it is not an array, it means that the API failed, so we will not auto provision a project for them.
if (is_array($projects) && count($projects) == 0 && $project_id == '') {
//No project id set, project deleted, or community changed to one without that project. Try to find the Drupal project
//Setup a default Drupal project if they have no other projects
$project_id = lingotek_add_project($site);
$projects = class_exists('LingotekApi') ? $api
->listProjects() : FALSE;
}
if ($projects && count($projects) > 0 && $setup_complete) {
$sorted = asort($projects);
$default_project_id = $config_profile
->getAttribute('project_id');
$form['additional_translation']['addtl_project_id'] = array(
'#type' => 'select',
'#title' => t('Default Project'),
'#options' => $projects,
'#description' => t('The default Lingotek Project with which translations will be associated.'),
'#default_value' => $default_project_id ? $default_project_id : $project_id,
);
}
// Vaults
$vaults = $api
->listVaults();
$current_vault_id = variable_get('lingotek_vault', '');
$personal_vault_count = isset($vaults['Personal Vaults']) ? count($vaults['Personal Vaults']) : 0;
$community_vault_count = isset($vaults['Community Vaults']) ? count($vaults['Community Vaults']) : 0;
// If no vault id is set, and we don't have any personal vaults, then create one and add it to our project.
if ($current_vault_id == '' && $personal_vault_count == 0 && $community_vault_count == 0) {
$current_project_id = variable_get('lingotek_project', '');
// But only if we have a ProjectID.
if ($current_project_id != '') {
$current_vault_id = lingotek_add_vault($site);
lingotek_add_vault_to_project();
}
}
if ($personal_vault_count + $community_vault_count > 0 && $setup_complete) {
$default_vault_id = $config_profile
->getAttribute('vault_id');
$form['additional_translation']['addtl_vault_id'] = array(
'#type' => 'select',
'#title' => t('Default Vault'),
'#options' => $vaults,
'#description' => t('The default Translation Memory Vault where translations are saved.'),
'#default_value' => $default_vault_id ? $default_vault_id : $current_vault_id,
);
}
$form['additional_translation']['lingotek_translate_config_options']['view_status'] = array(
'#type' => 'item',
'#description' => t('You can view the progress of the configuration translations on the <a href="@link">Translate Interface</a> page', array(
'@link' => url('admin/settings/lingotek/manage/config'),
)),
);
$setup_complete = !lingotek_is_config_missing();
if ($setup_complete) {
$form['#action'] = url('admin/settings/lingotek/settings', array(
'fragment' => 'ltk-config',
));
}
return $form;
}