Commit 08c97a41 authored by Loparev's avatar Loparev
Browse files

Added support for force_block_for_tags directive: string segmentation

parent 214e6ff4
......@@ -25,6 +25,7 @@ settings:
custom_regexp_placeholder: '(@|%|!)[\w-]+'
translatable_attributes: 'title, alt'
exclude_translatable_attributes: ''
force_block_for_tags: ''
identical_file_name: false
enable_smartling_logging: true
enable_notifications: true
......
......@@ -46,6 +46,9 @@ tmgmt.translator.settings.smartling:
exclude_translatable_attributes:
type: string
label: 'Comma-separated list of HTML attributes to exclude from translation'
force_block_for_tags:
type: string
label: 'Comma-separated list of HTML tags to segment strings by'
export_format:
type: string
label: 'Export format for file type'
......
......@@ -393,7 +393,8 @@ class SmartlingTranslator extends TranslatorPluginBase implements
'smartling.character_limit_paths' => 'html/body/div/limit',
'smartling.placeholder_format_custom' => $job->getSetting('custom_regexp_placeholder'),
'smartling.include_translatable_attributes' => $job->getSetting('translatable_attributes'),
'smartling.exclude_translatable_attributes' => $job->getSetting('exclude_translatable_attributes')
'smartling.exclude_translatable_attributes' => $job->getSetting('exclude_translatable_attributes'),
'smartling.force_block_for_tags' => $job->getSetting('force_block_for_tags')
];
$this->moduleHandler->alter('tmgmt_smartling_directives', $directives);
......@@ -428,7 +429,8 @@ class SmartlingTranslator extends TranslatorPluginBase implements
'smartling.character_limit_paths',
'smartling.force_inline_for_tags',
'smartling.include_translatable_attributes',
'smartling.exclude_translatable_attributes'
'smartling.exclude_translatable_attributes',
'smartling.force_block_for_tags'
];
$result = [];
......@@ -649,6 +651,7 @@ class SmartlingTranslator extends TranslatorPluginBase implements
'custom_regexp_placeholder' => '(@|%|!)[\w-]+',
'translatable_attributes' => 'title, alt',
'exclude_translatable_attributes' => '',
'force_block_for_tags' => '',
'context_skip_host_verifying' => FALSE,
'identical_file_name' => FALSE,
'enable_smartling_logging' => TRUE,
......
......@@ -178,6 +178,15 @@ class SmartlingTranslatorUi extends TranslatorPluginUiBase {
'#required' => FALSE,
];
$form['force_block_for_tags'] = [
'#type' => 'textfield',
'#title' => t('Comma-separated list of HTML tags to segment strings by'),
'#description' => t('Forces the html parser to treat the listed tags as string separators.'),
'#size' => 63,
'#default_value' => $translator->getSetting('force_block_for_tags'),
'#required' => FALSE,
];
// TODO: identical filename task.
// $form['identical_file_name'] = [
// '#type' => 'checkbox',
......
......@@ -49,7 +49,8 @@ class LoggingTest extends SmartlingTestBase {
'settings[scheme]' => $this->smartlingPluginProviderSettings['settings[scheme]'],
'settings[custom_regexp_placeholder]' => $this->smartlingPluginProviderSettings['settings[custom_regexp_placeholder]'],
'settings[translatable_attributes]' => $this->smartlingPluginProviderSettings['settings[translatable_attributes]'],
'settings[exclude_translatable_attributes]' => $this->smartlingPluginProviderSettings['settings[exclude_translatable_attributes]']
'settings[exclude_translatable_attributes]' => $this->smartlingPluginProviderSettings['settings[exclude_translatable_attributes]'],
'settings[force_block_for_tags]' => $this->smartlingPluginProviderSettings['settings[force_block_for_tags]']
], t('Save'));
}
......
......@@ -172,6 +172,7 @@ abstract class SmartlingTestBase extends TMGMTTestBase {
'custom_regexp_placeholder' => $providerSettings['settings[custom_regexp_placeholder]'],
'translatable_attributes' => $providerSettings['settings[translatable_attributes]'],
'exclude_translatable_attributes' => $providerSettings['settings[exclude_translatable_attributes]'],
'force_block_for_tags' => $providerSettings['settings[force_block_for_tags]'],
'enable_smartling_logging' => $providerSettings['settings[enable_smartling_logging]'],
'enable_notifications' => $providerSettings['settings[enable_notifications]'],
'download_by_job_items' => $providerSettings['settings[download_by_job_items]']
......
......@@ -61,7 +61,8 @@ class SmartlingTranslatorTest extends SmartlingTestBase {
'smartling.character_limit_paths' => 'test',
'smartling.force_inline_for_tags' => 'test',
'smartling.include_translatable_attributes' => 'test',
'smartling.exclude_translatable_attributes' => 'test'
'smartling.exclude_translatable_attributes' => 'test',
'smartling.force_block_for_tags' => 'test'
]);
$expected = [
'smartling.entity_escaping' => 'test',
......@@ -77,7 +78,8 @@ class SmartlingTranslatorTest extends SmartlingTestBase {
'smartling.character_limit_paths' => 'test',
'smartling.force_inline_for_tags' => 'test',
'smartling.include_translatable_attributes' => 'test',
'smartling.exclude_translatable_attributes' => 'test'
'smartling.exclude_translatable_attributes' => 'test',
'smartling.force_block_for_tags' => 'test'
];
$this->assertEquals($expected, $actual);
......
......@@ -30,7 +30,8 @@ class UploadFlowTest extends SmartlingTestBase {
$params['smartling.character_limit_paths'] == 'html/body/div/limit' &&
$params['smartling.placeholder_format_custom'] == '(@|%|!)[\w-]+' &&
$params['smartling.include_translatable_attributes'] == 'title, alt' &&
$params['smartling.exclude_translatable_attributes'] == '';
$params['smartling.exclude_translatable_attributes'] == '' &&
$params['smartling.force_block_for_tags'] == '';
}
/**
......
......@@ -239,3 +239,18 @@ function tmgmt_smartling_update_8805() {
}
}
}
/**
* Set default force_block_for_tags string.
*/
function tmgmt_smartling_update_8806() {
$translator_ids = \Drupal::configFactory()->listAll('tmgmt.translator');
foreach ($translator_ids as $id) {
$config = \Drupal::configFactory()->getEditable($id);
if ($config && $config->get('plugin') === 'smartling') {
$config->set('settings.force_block_for_tags', '')->save(TRUE);
}
}
}
......@@ -20,6 +20,7 @@ $settings = [
'settings[custom_regexp_placeholder]' => '(@|%|!)[\w-]+',
'settings[translatable_attributes]' => 'title, alt',
'settings[exclude_translatable_attributes]' => '',
'settings[force_block_for_tags]' => '',
'settings[enable_smartling_logging]' => FALSE,
'settings[enable_notifications]' => TRUE,
'settings[async_mode]' => FALSE,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment