Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
tmgmt_smartling
Commits
d286a599
Commit
d286a599
authored
Jul 13, 2020
by
Loparev
Browse files
Introduced "Download by job item" option
parent
204aaa0e
Changes
7
Hide whitespace changes
Inline
Side-by-side
config/install/tmgmt.translator.smartling.yml
View file @
d286a599
...
...
@@ -29,6 +29,7 @@ settings:
enable_notifications
:
true
async_mode
:
false
enable_basic_auth
:
false
download_by_job_items
:
false
basic_auth
:
login
:
'
'
password
:
'
'
config/schema/tmgmt_smartling.schema.yml
View file @
d286a599
...
...
@@ -61,6 +61,9 @@ tmgmt.translator.settings.smartling:
enable_basic_auth
:
type
:
boolean
label
:
'
Enable
basic
auth
for
context'
download_by_job_items
:
type
:
boolean
label
:
'
Download
and
apply
translations
per
job
item'
basic_auth
:
type
:
mapping
label
:
'
Basic
auth'
...
...
src/Plugin/tmgmt/Translator/SmartlingTranslator.php
View file @
d286a599
...
...
@@ -652,6 +652,7 @@ class SmartlingTranslator extends TranslatorPluginBase implements
'enable_notifications'
=>
TRUE
,
'async_mode'
=>
FALSE
,
'enable_basic_auth'
=>
FALSE
,
'download_by_job_items'
=>
FALSE
,
'basic_auth'
=>
[
'login'
=>
''
,
'password'
=>
''
,
...
...
src/SmartlingTranslatorUi.php
View file @
d286a599
...
...
@@ -249,6 +249,13 @@ class SmartlingTranslatorUi extends TranslatorPluginUiBase {
],
];
$form
[
'download_by_job_items'
]
=
[
'#type'
=>
'checkbox'
,
'#title'
=>
t
(
'Download and apply translations per job item'
),
'#description'
=>
t
(
'Only enable <b>if you experience download execution timeout issues</b>.'
),
'#default_value'
=>
$translator
->
getSetting
(
'download_by_job_items'
),
];
// Cron & queues table.
$form
[
'cron_and_queues'
]
=
[
'#type'
=>
'details'
,
...
...
tests/src/Functional/SmartlingTestBase.php
View file @
d286a599
...
...
@@ -173,6 +173,7 @@ abstract class SmartlingTestBase extends TMGMTTestBase {
'translatable_attributes'
=>
$providerSettings
[
'settings[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]'
]
],
]);
...
...
tmgmt_smartling.module
View file @
d286a599
...
...
@@ -48,7 +48,8 @@ function tmgmt_smartling_cron() {
foreach
(
$smartling_provider_configs
as
$smartling_provider_config
)
{
$api_wrapper
=
\
Drupal
::
getContainer
()
->
get
(
"tmgmt_smartling.smartling_api_wrapper"
);
$api_wrapper
->
setSettings
(
$smartling_provider_config
->
get
(
"settings"
));
$settings
=
$smartling_provider_config
->
get
(
"settings"
);
$api_wrapper
->
setSettings
(
$settings
);
$search_params
=
new
SearchTranslationRequestParams
();
$search_params
->
setState
(
TranslationSubmissionStates
::
STATE_TRANSLATED
);
...
...
@@ -94,12 +95,22 @@ function tmgmt_smartling_cron() {
continue
;
}
foreach
(
$job
->
getItems
()
as
$item
)
{
if
(
$settings
[
'download_by_job_items'
])
{
foreach
(
$job
->
getItems
()
as
$item
)
{
Drupal
::
service
(
'tmgmt_extension_suit.utils.queue_unique_item'
)
->
addItem
(
'tmgmt_extension_suit_download'
,
[
'tjid'
=>
$tmgmt_job_id
,
'tjiid'
=>
$item
->
id
(),
]
);
}
}
else
{
Drupal
::
service
(
'tmgmt_extension_suit.utils.queue_unique_item'
)
->
addItem
(
'tmgmt_extension_suit_download'
,
[
'tjid'
=>
$tmgmt_job_id
,
'tjiid'
=>
$item
->
id
(),
'id'
=>
$tmgmt_job_id
,
]
);
}
...
...
@@ -230,6 +241,12 @@ function tmgmt_smartling_download_file(JobInterface $job, JobItemInterface $pass
// No translation found.
$force_import
[
$job_item
->
id
()]
=
$job_item
;
}
// Force import in case connector works in "download by job item"
// mode.
if
(
!
empty
(
$passed_job_item
))
{
$force_import
[
$passed_job_item
->
id
()]
=
$passed_job_item
;
}
}
// Compare old and new hashes in order to decide should we apply
...
...
tmgmt_smartling.simpletest.settings.php
View file @
d286a599
...
...
@@ -23,6 +23,7 @@ $settings = [
'settings[enable_notifications]'
=>
TRUE
,
'settings[async_mode]'
=>
FALSE
,
'settings[enable_basic_auth]'
=>
FALSE
,
'settings[download_by_job_items]'
=>
FALSE
,
'settings[basic_auth][login]'
=>
''
,
'settings[basic_auth][password]'
=>
''
,
];
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment