Jump to content

Edit History

vlgalik

vlgalik

Had the same problem.

Then I included:

// fixes undefined currency_specifications & number_specifications
Media::addJsDef(
  [
    'currency_specifications' => $this->preparePriceSpecifications($this->context),
    'number_specifications' => $this->prepareNumberSpecifications($this->context),
  ]
);
                  
// fixes undefined cldr
// cldr.bundle.js is copied from /admin-XXXXXX/themes/new-theme/public/cldr.bundle.js - so I don't disclose the admin url
$this->context->controller->registerJavascript('modules-mymodule1', 'js/cldr.bundle.js', ['position' => 'bottom', 'priority' => 1]); 

// contains formatCurrencyCldr function
$this->context->controller->registerJavascript('modules-mymodule0', 'js/tools.js', ['position' => 'bottom', 'priority' => 1]);

And these two methods:

// copied from classes/controller/AdminController.php
private function preparePriceSpecifications(Context $context)
{
    /* @var Currency */
    $currency = $context->currency;
    /* @var PriceSpecification */
    $priceSpecification = $context->getCurrentLocale()->getPriceSpecification($currency->iso_code);
    if (empty($priceSpecification)) {
        return [];
    }

    return array_merge(
        ['symbol' => $priceSpecification->getSymbolsByNumberingSystem(Locale::NUMBERING_SYSTEM_LATIN)->toArray()],
        $priceSpecification->toArray()
    );
}

// copied from classes/controller/AdminController.php
private function prepareNumberSpecifications(Context $context)
{
    /* @var NumberSpecification */
    $numberSpecification = $context->getCurrentLocale()->getNumberSpecification();
    if (empty($numberSpecification)) {
        return [];
    }

    return array_merge(
        ['symbol' => $numberSpecification->getSymbolsByNumberingSystem(Locale::NUMBERING_SYSTEM_LATIN)->toArray()],
        $numberSpecification->toArray()
    );
}

After that formatCurrencyCldr finally worked in FO. In BO you only need to include the tools.js.

vlgalik

vlgalik

Had the same problem.

Then I included:

// fixes undefined currency_specifications & number_specifications
Media::addJsDef(
  [
    'currency_specifications' => $this->preparePriceSpecifications($this->context),
    'number_specifications' => $this->prepareNumberSpecifications($this->context),
  ]
);
                  
// fixes undefined cldr
// cldr.bundle.js is copied from /admin-XXXXXX/themes/new-theme/public/cldr.bundle.js - so I don't disclose the admin url
$this->context->controller->registerJavascript('modules-mymodule1', 'js/cldr.bundle.js', ['position' => 'bottom', 'priority' => 1]); 

// contains formatCurrencyCldr function
$this->context->controller->registerJavascript('modules-mymodule0', 'js/tools.js', ['position' => 'bottom', 'priority' => 1]);

And these two methods:

// copied from classes/controller/AdminController.php
private function preparePriceSpecifications(Context $context)
{
    /* @var Currency */
    $currency = $context->currency;
    /* @var PriceSpecification */
    $priceSpecification = $context->getCurrentLocale()->getPriceSpecification($currency->iso_code);
    if (empty($priceSpecification)) {
        return [];
    }

    return array_merge(
        ['symbol' => $priceSpecification->getSymbolsByNumberingSystem(Locale::NUMBERING_SYSTEM_LATIN)->toArray()],
        $priceSpecification->toArray()
    );
}

// copied from classes/controller/AdminController.php
private function prepareNumberSpecifications(Context $context)
{
    /* @var NumberSpecification */
    $numberSpecification = $context->getCurrentLocale()->getNumberSpecification();
    if (empty($numberSpecification)) {
        return [];
    }

    return array_merge(
        ['symbol' => $numberSpecification->getSymbolsByNumberingSystem(Locale::NUMBERING_SYSTEM_LATIN)->toArray()],
        $numberSpecification->toArray()
    );
}

After that formatCurrencyCldr finally worked on FO. In BO you only need to include the tools.js.

×
×
  • Create New...