modules/acm/src/I18nHelper.php
public function formatPrice($price) {
    // Fetch the config.
    $config = $this->configFactory->get('acm.currency');

    // Get currency with the correct locale.
    $locale = \Drupal::languageManager()->getCurrentLanguage()->getId();
    $currency = \Drupal::service('repository.currency');
    $numberFormat = \Drupal::service('repository.number_format');
    $currencyFormatter = new CurrencyFormatter($numberFormat, $currency, ['locale' => $locale]);

    $currencyCode = $currency->get($config->get('currency_code'))->getCurrencyCode();

    return $currencyFormatter->format($price, $currencyCode);
  }
public function formatPrice($price) {
    // Fetch the config.
    $config = $this->configFactory->get('acm.currency');

    // Get currency with the correct locale.
    $locale = \Drupal::languageManager()->getCurrentLanguage()->getId();
    $currency = \Drupal::service('repository.currency');
    $numberFormat = \Drupal::service('repository.number_format');
    $currencyFormatter = new CurrencyFormatter($numberFormat, $currency, ['locale' => $locale]);

    $currencyCode = $currency->get($config->get('currency_code'))->getCurrencyCode();

    return $currencyFormatter->format($price, $currencyCode);
  }
public function formatPrice ( $ price ) { // Fetch the config. $ config = $ this -> configFactory -> get ( 'acm.currency' ) ; // Get currency with the correct locale. $ locale = \ Drupal :: languageManager ( ) -> getCurrentLanguage ( ) -> getId ( ) ; $ currency = \ Drupal :: service ( 'repository.currency' ) ; $ numberFormat = \ Drupal :: service ( 'repository.number_format' ) ; $ currencyFormatter = new CurrencyFormatter ( $ numberFormat , $ currency , [ 'locale' => $ locale ] ) ; $ currencyCode = $ currency -> get ( $ config -> get ( 'currency_code' ) ) -> getCurrencyCode ( ) ; return $ currencyFormatter -> format ( $ price , $ currencyCode ) ; }
Helper function to format price string.

@param string $price
Price vaue we want to format.

@return string
Formatted price string.
Helper function to format price string .