Jump to content
  • 0
arbuzas

How to change EUR to €

Question

13 answers to this question

Recommended Posts

  • 0

Ok so it looks like PrestaShop 1.7 is using new fancy pancy Cldr framework (ICanBoogie). Basically it drags all localisation stuff from the Cldr database (repo). It's all good but unfortunately this framework does not give many option for customisation (not that I found any) so you have to be happy what Cldr provides. In my case Cldr dictates that currency sign is "EUR" on the left, when we actually more used to "€" on the left.

 

Anyway, it is possible to override this by creating file in: override/classes/Tools.php

<?php

/**
 * Forcing to use Euro (Currency) sign
 */
class Tools extends ToolsCore
{

  public static function displayPrice($price, $currency = null, $no_utf8 = false, Context $context = null)
  {
      if (!is_numeric($price)) {
          return $price;
      }
      if (!$context) {
          $context = Context::getContext();
      }
      if ($currency === null) {
          $currency = $context->currency;
      } elseif (is_int($currency)) {
          $currency = Currency::getCurrencyInstance((int)$currency);
      }

      $numberFormatter = new ICanBoogie\CLDR\NumberFormatter;
      return $numberFormatter->format($price, "#0.#0").' '.$currency->getSign();
  }
}

?>

This workaround is bit crusty but meh.. it works.

Share this post


Link to post
Share on other sites
  • 0

Wait until you realize that it also does not support zero decimal currencies anymore.

I don't care, irrelevant for European business.. If its true I'm sure they will come up with something.

Share this post


Link to post
Share on other sites
  • 0

There are a few countries in and near Europe that do not use decimals, so while you may not care, there are plenty that do. 

 

If its true I'm sure they will come up with something.

 

The problem is that Prestashop appears to think like you.  Let's remove features that we think are not important, and now we have to re-add them back because we didn't have enough foresight to see what issues it might create. 

 

In a nutshell, that is the problem with PS v1.7

Share this post


Link to post
Share on other sites
  • 0

Offtopic...

 

The problem is that Prestashop appears to think like you.  

 

Nah.. I'm still just playing with 1.7, and I'm not sure if I like it or if I'll use it. It looks like it was patched with bits and bobs from the 1.6v and everything is all over the place. In my opinion they just had to start from scratch if they wanted to change everything... pretty much everything broke anyway.

 

1.6 is also rusty.. so yeah not sure, I might look somewhere else if I can't make 1.7 to work.

Share this post


Link to post
Share on other sites
  • 0

Ok so it looks like PrestaShop 1.7 is using new fancy pancy Cldr framework (ICanBoogie). Basically it drags all localisation stuff from the Cldr database (repo). It's all good but unfortunately this framework does not give many option for customisation (not that I found any) so you have to be happy what Cldr provides. In my case Cldr dictates that currency sign is "EUR" on the left, when we actually more used to "€" on the left.

 

Anyway, it is possible to override this by creating file in: override/classes/Tools.php

<?php

/**
 * Forcing to use Euro (Currency) sign
 */
class Tools extends ToolsCore
{

  public static function displayPrice($price, $currency = null, $no_utf8 = false, Context $context = null)
  {
      if (!is_numeric($price)) {
          return $price;
      }
      if (!$context) {
          $context = Context::getContext();
      }
      if ($currency === null) {
          $currency = $context->currency;
      } elseif (is_int($currency)) {
          $currency = Currency::getCurrencyInstance((int)$currency);
      }

      $numberFormatter = new ICanBoogie\CLDR\NumberFormatter;
      return $numberFormatter->format($price, "#0.#0").' '.$currency->getSign();
  }
}

?>

This workaround is bit crusty but meh.. it works.

But it works only in product page, not ir modules or "hopepage" :)

Share this post


Link to post
Share on other sites
  • 0

Right.. I see what you mean. Well it looks like you can't override symfony based pages. I guess you can edit Tools.php directly and live till next update that way...

 

I saw somewhere mentioned that instead of overriding the code you can extend it or something like that.. but can't find any documentation about it so not sure whats the story with that.

Share this post


Link to post
Share on other sites
  • 0

Try to edit these files:

 

EUR to €:

in this file web/translations/cldr/main--xx-XX--currencies , change "symbol":"EUR" to "symbol":"€" 
 
Removing decimals:
in this file web/translations/cldr/main--xx-XX--numbers , change "standard":"#,##0.00\u00a0\u00a4" to "standard":"#,##0\u00a0\u00a4"
 
xx-XX is language which you use

Share this post


Link to post
Share on other sites
  • 0

 

Try to edit these files:

 

EUR to €:

in this file web/translations/cldr/main--xx-XX--currencies , change "symbol":"EUR" to "symbol":"€" 
 
Removing decimals:
in this file web/translations/cldr/main--xx-XX--numbers , change "standard":"#,##0.00\u00a0\u00a4" to "standard":"#,##0\u00a0\u00a4"
 
xx-XX is language which you use

 

 

 

in this case removing decimal also remove args after decimal. How to fix that? 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×