Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
locale_config_batch_update_components example
$last_checked
=
$this
->state->
get
(
'locale.translation_last_checked'
)
;
if
(
$last_checked
< REQUEST_TIME - LOCALE_TRANSLATION_STATUS_TTL
)
{
locale_translation_clear_status
(
)
;
$batch
=
locale_translation_batch_update_build
(
[
]
,
$langcodes
,
$options
)
;
batch_set
(
$batch
)
;
}
else
{
// Set a batch to download and import translations.
$batch
=
locale_translation_batch_fetch_build
(
$projects
,
$langcodes
,
$options
)
;
batch_set
(
$batch
)
;
// Set a batch to update configuration as well.
if
(
$batch
=
locale_config_batch_update_components
(
$options
,
$langcodes
)
)
{
batch_set
(
$batch
)
;
}
}
}
}
$options
=
array_merge
(
_locale_translation_default_update_options
(
)
,
[
'langcode' =>
$form_state
->
getValue
(
'langcode'
)
,
'overwrite_options' =>
$form_state
->
getValue
(
'overwrite_options'
)
,
'customized' =>
$form_state
->
getValue
(
'customized'
)
? LOCALE_CUSTOMIZED : LOCALE_NOT_CUSTOMIZED,
]
)
;
$this
->moduleHandler->
loadInclude
(
'locale', 'bulk.inc'
)
;
$file
=
locale_translate_file_attach_properties
(
$this
->file,
$options
)
;
$batch
=
locale_translate_batch_build
(
[
$file
->uri =>
$file
]
,
$options
)
;
batch_set
(
$batch
)
;
// Create or update all configuration translations for this language.
if
(
$batch
=
locale_config_batch_update_components
(
$options
,
[
$form_state
->
getValue
(
'langcode'
)
]
)
)
{
batch_set
(
$batch
)
;
}
$form_state
->
setRedirect
(
'locale.translate_page'
)
;
}
}