I need to update the allowed locale list with my custom language in magento 2.3.3. For that, I have overridden the Magento\Framework\Locale\Config class in my custom module.
di.xml:
<preference for="Magento\Framework\Locale\Config" type="Vendor\Module\Locale\Config" />
Config.php:
<?php
namespace Vendor\Module\Locale;
class Config extends \Magento\Framework\Locale\Config
{
protected $_test = [
'es_US'
];
public function __construct(array $data = [])
{
$data['allowedLocales'] = $this->_test;
parent::__construct($data);
}
}
The problem is both the core and overridden files executing. When I print the variable $this->_allowedLocales
, I get the results twice, the first result don't has my custom locale and the second result has my custom locale.
What I want here is I need a single result which includes my custom locale.
Please see the following result I get
Array
(
[0] => af_ZA
[1] => ar_DZ
[2] => ar_EG
[3] => ar_KW
[4] => ar_MA
[5] => ar_SA
[6] => az_Latn_AZ
[7] => be_BY
[8] => bg_BG
[9] => bn_BD
[10] => bs_Latn_BA
[11] => ca_ES
[12] => cs_CZ
[13] => cy_GB
[14] => da_DK
[15] => de_AT
[16] => de_CH
[17] => de_DE
[18] => de_LU
[19] => el_GR
[20] => en_AU
[21] => en_CA
[22] => en_GB
[23] => en_NZ
[24] => en_US
[25] => es_AR
[26] => es_CO
[27] => es_PA
[28] => gl_ES
[29] => es_CR
[30] => es_ES
[31] => es_MX
[32] => eu_ES
[33] => es_PE
[34] => et_EE
[35] => fa_IR
[36] => fi_FI
[37] => fil_PH
[38] => fr_BE
[39] => fr_CA
[40] => fr_CH
[41] => fr_FR
[42] => fr_LU
[43] => gu_IN
[44] => he_IL
[45] => hi_IN
[46] => hr_HR
[47] => hu_HU
[48] => id_ID
[49] => is_IS
[50] => it_CH
[51] => it_IT
[52] => ja_JP
[53] => ka_GE
[54] => km_KH
[55] => ko_KR
[56] => lo_LA
[57] => lt_LT
[58] => lv_LV
[59] => mk_MK
[60] => mn_Cyrl_MN
[61] => ms_MY
[62] => ms_Latn_MY
[63] => nl_BE
[64] => nl_NL
[65] => nb_NO
[66] => nn_NO
[67] => pl_PL
[68] => pt_BR
[69] => pt_PT
[70] => ro_RO
[71] => ru_RU
[72] => sk_SK
[73] => sl_SI
[74] => sq_AL
[75] => sr_Cyrl_RS
[76] => sv_SE
[77] => sv_FI
[78] => sw_KE
[79] => th_TH
[80] => tr_TR
[81] => uk_UA
[82] => vi_VN
[83] => zh_Hans_CN
[84] => zh_Hant_HK
[85] => zh_Hant_TW
[86] => es_CL
[87] => lo_LA
[88] => es_VE
[89] => en_IE
[90] => es_BO
)
Array
(
[0] => af_ZA
[1] => ar_DZ
[2] => ar_EG
[3] => ar_KW
[4] => ar_MA
[5] => ar_SA
[6] => az_Latn_AZ
[7] => be_BY
[8] => bg_BG
[9] => bn_BD
[10] => bs_Latn_BA
[11] => ca_ES
[12] => cs_CZ
[13] => cy_GB
[14] => da_DK
[15] => de_AT
[16] => de_CH
[17] => de_DE
[18] => de_LU
[19] => el_GR
[20] => en_AU
[21] => en_CA
[22] => en_GB
[23] => en_NZ
[24] => en_US
[25] => es_AR
[26] => es_CO
[27] => es_PA
[28] => gl_ES
[29] => es_CR
[30] => es_ES
[31] => es_MX
[32] => eu_ES
[33] => es_PE
[34] => et_EE
[35] => fa_IR
[36] => fi_FI
[37] => fil_PH
[38] => fr_BE
[39] => fr_CA
[40] => fr_CH
[41] => fr_FR
[42] => fr_LU
[43] => gu_IN
[44] => he_IL
[45] => hi_IN
[46] => hr_HR
[47] => hu_HU
[48] => id_ID
[49] => is_IS
[50] => it_CH
[51] => it_IT
[52] => ja_JP
[53] => ka_GE
[54] => km_KH
[55] => ko_KR
[56] => lo_LA
[57] => lt_LT
[58] => lv_LV
[59] => mk_MK
[60] => mn_Cyrl_MN
[61] => ms_MY
[62] => ms_Latn_MY
[63] => nl_BE
[64] => nl_NL
[65] => nb_NO
[66] => nn_NO
[67] => pl_PL
[68] => pt_BR
[69] => pt_PT
[70] => ro_RO
[71] => ru_RU
[72] => sk_SK
[73] => sl_SI
[74] => sq_AL
[75] => sr_Cyrl_RS
[76] => sv_SE
[77] => sv_FI
[78] => sw_KE
[79] => th_TH
[80] => tr_TR
[81] => uk_UA
[82] => vi_VN
[83] => zh_Hans_CN
[84] => zh_Hant_HK
[85] => zh_Hant_TW
[86] => es_CL
[87] => lo_LA
[88] => es_VE
[89] => en_IE
[90] => es_BO
***[91] => es_US***
)
en_SG
just fine using the preference method above or a plugin around (after)getAllowedLocales
, works fine for developer mode and allows me to set the store locale to English (Singapore), however the language is not reflected in command lineinfo:language:list
or when I try to deploy staitc content for the language in production mode. Some debugging seems it creates the List object (and Config object in constructor) twice, once without and once with the preference, only the first one survivesMagento\Framework\Setup\Lists
class to no joy....