Commit 214e6ff4 authored by Loparev's avatar Loparev
Browse files

Added exclude_translatable_attributes directive support

parent def8ffd8
......@@ -24,6 +24,7 @@ settings:
export_format: 'xml'
custom_regexp_placeholder: '(@|%|!)[\w-]+'
translatable_attributes: 'title, alt'
exclude_translatable_attributes: ''
identical_file_name: false
enable_smartling_logging: true
enable_notifications: true
......
......@@ -43,6 +43,9 @@ tmgmt.translator.settings.smartling:
translatable_attributes:
type: string
label: 'Comma-separated list of HTML attributes to be translatable'
exclude_translatable_attributes:
type: string
label: 'Comma-separated list of HTML attributes to exclude from translation'
export_format:
type: string
label: 'Export format for file type'
......
......@@ -392,7 +392,8 @@ class SmartlingTranslator extends TranslatorPluginBase implements
'smartling.source_key_paths' => 'html/body/div/{div.sl-variant}, html/body/div/{span.sl-variant}',
'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.include_translatable_attributes' => $job->getSetting('translatable_attributes'),
'smartling.exclude_translatable_attributes' => $job->getSetting('exclude_translatable_attributes')
];
$this->moduleHandler->alter('tmgmt_smartling_directives', $directives);
......@@ -426,7 +427,8 @@ class SmartlingTranslator extends TranslatorPluginBase implements
'smartling.instruction_paths',
'smartling.character_limit_paths',
'smartling.force_inline_for_tags',
'smartling.include_translatable_attributes'
'smartling.include_translatable_attributes',
'smartling.exclude_translatable_attributes'
];
$result = [];
......@@ -646,6 +648,7 @@ class SmartlingTranslator extends TranslatorPluginBase implements
'context_silent_user_switching' => FALSE,
'custom_regexp_placeholder' => '(@|%|!)[\w-]+',
'translatable_attributes' => 'title, alt',
'exclude_translatable_attributes' => '',
'context_skip_host_verifying' => FALSE,
'identical_file_name' => FALSE,
'enable_smartling_logging' => TRUE,
......
......@@ -169,6 +169,15 @@ class SmartlingTranslatorUi extends TranslatorPluginUiBase {
'#required' => FALSE,
];
$form['exclude_translatable_attributes'] = [
'#type' => 'textfield',
'#title' => t('Comma-separated list of HTML attributes to exclude from translation'),
'#description' => t('Instructs Smartling not to capture the text of a list of HTML attributes for translation.'),
'#size' => 63,
'#default_value' => $translator->getSetting('exclude_translatable_attributes'),
'#required' => FALSE,
];
// TODO: identical filename task.
// $form['identical_file_name'] = [
// '#type' => 'checkbox',
......
......@@ -48,7 +48,8 @@ class LoggingTest extends SmartlingTestBase {
'settings[callback_url_host]' => $this->smartlingPluginProviderSettings['settings[callback_url_host]'],
'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[translatable_attributes]' => $this->smartlingPluginProviderSettings['settings[translatable_attributes]'],
'settings[exclude_translatable_attributes]' => $this->smartlingPluginProviderSettings['settings[exclude_translatable_attributes]']
], t('Save'));
}
......
......@@ -171,6 +171,7 @@ abstract class SmartlingTestBase extends TMGMTTestBase {
'scheme' => $providerSettings['settings[scheme]'],
'custom_regexp_placeholder' => $providerSettings['settings[custom_regexp_placeholder]'],
'translatable_attributes' => $providerSettings['settings[translatable_attributes]'],
'exclude_translatable_attributes' => $providerSettings['settings[exclude_translatable_attributes]'],
'enable_smartling_logging' => $providerSettings['settings[enable_smartling_logging]'],
'enable_notifications' => $providerSettings['settings[enable_notifications]'],
'download_by_job_items' => $providerSettings['settings[download_by_job_items]']
......
......@@ -60,7 +60,8 @@ class SmartlingTranslatorTest extends SmartlingTestBase {
'smartling.instruction_paths' => 'test',
'smartling.character_limit_paths' => 'test',
'smartling.force_inline_for_tags' => 'test',
'smartling.include_translatable_attributes' => 'test'
'smartling.include_translatable_attributes' => 'test',
'smartling.exclude_translatable_attributes' => 'test'
]);
$expected = [
'smartling.entity_escaping' => 'test',
......@@ -75,7 +76,8 @@ class SmartlingTranslatorTest extends SmartlingTestBase {
'smartling.instruction_paths' => 'test',
'smartling.character_limit_paths' => 'test',
'smartling.force_inline_for_tags' => 'test',
'smartling.include_translatable_attributes' => 'test'
'smartling.include_translatable_attributes' => 'test',
'smartling.exclude_translatable_attributes' => 'test'
];
$this->assertEquals($expected, $actual);
......
......@@ -29,7 +29,8 @@ class UploadFlowTest extends SmartlingTestBase {
$params['smartling.source_key_paths'] == 'html/body/div/{div.sl-variant}, html/body/div/{span.sl-variant}' &&
$params['smartling.character_limit_paths'] == 'html/body/div/limit' &&
$params['smartling.placeholder_format_custom'] == '(@|%|!)[\w-]+' &&
$params['smartling.include_translatable_attributes'] == 'title, alt';
$params['smartling.include_translatable_attributes'] == 'title, alt' &&
$params['smartling.exclude_translatable_attributes'] == '';
}
/**
......
......@@ -194,7 +194,7 @@ function tmgmt_smartling_update_8403() {
}
/**
* Create download by job items action plugin./
* Create download by job items action plugin.
*/
function tmgmt_smartling_update_8804() {
try {
......@@ -224,3 +224,18 @@ function tmgmt_smartling_update_8804() {
throw new UpdateException('Unable to create "tmgmt_smartling_download_by_job_items_job_action" action.');
}
}
/**
* Set default exclude_translatable_attributes string.
*/
function tmgmt_smartling_update_8805() {
$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.exclude_translatable_attributes', '')->save(TRUE);
}
}
}
......@@ -19,6 +19,7 @@ $settings = [
'settings[scheme]' => 'public',
'settings[custom_regexp_placeholder]' => '(@|%|!)[\w-]+',
'settings[translatable_attributes]' => 'title, alt',
'settings[exclude_translatable_attributes]' => '',
'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