Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
createLocale example
foreach
(
$catalogue
->
all
(
)
as
$domain
=>
$messages
)
{
$createdIds
=
$this
->
createAssets
(
array_keys
(
$messages
)
,
$domain
)
;
if
(
$createdIds
)
{
$this
->
tagsAssets
(
$createdIds
,
$domain
)
;
}
}
foreach
(
$translatorBag
->
getCatalogues
(
)
as
$catalogue
)
{
$locale
=
$catalogue
->
getLocale
(
)
;
if
(
!\
in_array
(
$locale
,
$this
->
getLocales
(
)
)
)
{
$this
->
createLocale
(
$locale
)
;
}
foreach
(
$catalogue
->
all
(
)
as
$domain
=>
$messages
)
{
$keysIdsMap
=
[
]
;
foreach
(
$this
->
getAssetsIds
(
$domain
)
as
$id
)
{
$keysIdsMap
[
$this
->
retrieveKeyFromId
(
$id
,
$domain
)
]
=
$id
;
}
$assets
=
[
]
;
foreach
(
$keysIdsMap
as
$key
=>
$id
)
{
return
1536233560;
}
public
function
update
(
Connection
$connection
)
: void
{
$hasData
=
$connection
->
executeQuery
(
'SELECT 1 FROM `language` LIMIT 1'
)
->
fetchAssociative
(
)
;
if
(
$hasData
)
{
return
;
}
$this
->
createLanguage
(
$connection
)
;
$this
->
createLocale
(
$connection
)
;
$this
->
createDocumentTypes
(
$connection
)
;
$this
->
createSalutation
(
$connection
)
;
$this
->
createCountry
(
$connection
)
;
$this
->
createCurrency
(
$connection
)
;
$this
->
createCustomerGroup
(
$connection
)
;
$this
->
createPaymentMethod
(
$connection
)
;
$this
->
createShippingMethod
(
$connection
)
;
$this
->
createTax
(
$connection
)
;
$this
->
createRootCategory
(
$connection
)
;
$this
->
createSalesChannelTypes
(
$connection
)
;
private
function
getLocale
(
string
$locale
)
: string
{
if
(
!
$this
->phraseLocales
)
{
$this
->
initLocales
(
)
;
}
$phraseCode
=
str_replace
(
'_', '-',
$locale
)
;
if
(
!\
array_key_exists
(
$phraseCode
,
$this
->phraseLocales
)
)
{
$this
->
createLocale
(
$phraseCode
)
;
}
return
$this
->phraseLocales
[
$phraseCode
]
[
'id'
]
;
}
private
function
getFallbackLocale
(
string
$locale
)
: ?string
{
$phraseLocale
=
str_replace
(
'_', '-',
$locale
)
;
return
$this
->phraseLocales
[
$phraseLocale
]
[
'fallback_locale'
]
[
'name'
]
?? null;
}