File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php declare (strict_types=1 );
2+
3+ namespace Loki \Base \ViewModel ;
4+
5+ use Magento \Framework \View \Element \Block \ArgumentInterface ;
6+ use Magento \Framework \Locale \Resolver as LocaleResolver ;
7+
8+ class LocaleCode implements ArgumentInterface
9+ {
10+ public function __construct (
11+ private LocaleResolver $ localeResolver ,
12+ ){
13+ }
14+
15+ public function getCode (): string
16+ {
17+ return str_replace ('_ ' , '- ' , $ this ->localeResolver ->getLocale ());
18+ }
19+ }
Original file line number Diff line number Diff line change 1515 <block name =" loki.dynamic-script.variables" template =" Loki_Base::script/variables.phtml" >
1616 <arguments >
1717 <argument name =" form_key_value" xsi : type =" object" >Loki\Base\ViewModel\FormKeyValue</argument >
18+ <argument name =" locale_code" xsi : type =" object" >Loki\Base\ViewModel\LocaleCode</argument >
1819 </arguments >
1920 </block >
2021 </container >
Original file line number Diff line number Diff line change 22declare (strict_types=1 );
33
44use Loki \Base \ViewModel \FormKeyValue ;
5+ use Loki \Base \ViewModel \LocaleCode ;
56use Magento \Framework \Escaper ;
67use Magento \Framework \View \Element \Template ;
78
89/** @version 1.1.3 */
910/** @var Template $block */
1011/** @var FormKeyValue $formKeyValue */
12+ /** @var LocaleCode $localeCode */
1113/** @var Escaper $escaper */
1214
1315$ formKeyValue = $ block ->getFormKeyValue ();
16+ $ localeCode = $ block ->getLocaleCode ();
1417$ mobileWidth = $ block ->getMobileWidth ();
1518if (!is_numeric ($ mobileWidth ) || $ mobileWidth < 100 ) {
1619 $ mobileWidth = 767 ;
1720}
1821?>
1922<script>
2023 var LOKI_BASE_URL = '<?= $ escaper ->escapeUrl ($ block ->getBaseUrl ()) ?> ';
24+ var LOKI_LOCALE = '<?= $ escaper ->escapeUrl ($ localeCode ->getCode ()) ?> ';
2125 var LOKI_THEME_URL = '<?= $ escaper ->escapeUrl ($ block ->getViewFileUrl ('' )) ?> ';
2226 var LOKI_FORM_KEY = '<?= $ escaper ->escapeHtml ($ formKeyValue ->get ()) ?> ';
2327 var LOKI_CURRENT_URL = window.location.href.split('?')[0];
You can’t perform that action at this time.
0 commit comments