Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
moveMessagesToIntlDomainsIfPossible example
new
MergeOperation
(
$currentCatalogue
,
$extractedCatalogue
)
;
// Exit if no messages found.
if
(
!\
count
(
$operation
->
getDomains
(
)
)
)
{
$errorIo
->
warning
(
'No translation messages were found.'
)
;
return
0;
}
$resultMessage
= 'Translation files were successfully updated';
$operation
->
moveMessagesToIntlDomainsIfPossible
(
'new'
)
;
// show compiled list of messages
if
(
true ===
$input
->
getOption
(
'dump-messages'
)
)
{
$extractedMessagesCount
= 0;
$io
->
newLine
(
)
;
foreach
(
$operation
->
getDomains
(
)
as
$domain
)
{
$newKeys
=
array_keys
(
$operation
->
getNewMessages
(
$domain
)
)
;
$allKeys
=
array_keys
(
$operation
->
getMessages
(
$domain
)
)
;
$list
=
array_merge
(
array_diff
(
$allKeys
,
$newKeys
)
,
$diff
=
new
self
(
)
;
foreach
(
$this
->catalogues
as
$locale
=>
$catalogue
)
{
if
(
null ===
$diffCatalogue
=
$diffBag
->
getCatalogue
(
$locale
)
)
{
$diff
->
addCatalogue
(
$catalogue
)
;
continue
;
}
$operation
=
new
TargetOperation
(
$diffCatalogue
,
$catalogue
)
;
$operation
->
moveMessagesToIntlDomainsIfPossible
(
AbstractOperation::NEW_BATCH
)
;
$newCatalogue
=
new
MessageCatalogue
(
$locale
)
;
foreach
(
$catalogue
->
getDomains
(
)
as
$domain
)
{
$newCatalogue
->
add
(
$operation
->
getNewMessages
(
$domain
)
,
$domain
)
;
}
$diff
->
addCatalogue
(
$newCatalogue
)
;
}
return
$diff
;
}
if
(
!
$domains
)
{
$domains
=
$provider
->
getDomains
(
)
;
}
$providerTranslations
=
$provider
->
read
(
$domains
,
$locales
)
;
if
(
$force
)
{
foreach
(
$providerTranslations
->
getCatalogues
(
)
as
$catalogue
)
{
$operation
=
new
TargetOperation
(
new
MessageCatalogue
(
$catalogue
->
getLocale
(
)
)
,
$catalogue
)
;
if
(
$intlIcu
)
{
$operation
->
moveMessagesToIntlDomainsIfPossible
(
)
;
}
$this
->writer->
write
(
$operation
->
getResult
(
)
,
$format
,
$writeOptions
)
;
}
$io
->
success
(
sprintf
(
'Local translations has been updated from "%s" (for "%s" locale(s), and "%s" domain(s)).',
parse_url
(
$provider
, \PHP_URL_SCHEME
)
,
implode
(
', ',
$locales
)
,
implode
(
', ',
$domains
)
)
)
;
return
0;
}
$localTranslations
=
$this
->
readLocalTranslations
(
$locales
,
$domains
,
$this
->transPaths
)
;