sickshot Posted March 28, 2014 Share Posted March 28, 2014 (edited) hello, so my problem is that my currency doesn't have symbol and I'm using just its name so when the language is switched form native to English currency stays untranslated. so is there any way to translate currency symbol? or any other way maybe... Edited April 3, 2014 by sickshot (see edit history) Link to comment Share on other sites More sharing options...
sickshot Posted March 31, 2014 Author Share Posted March 31, 2014 any ideas please.... Link to comment Share on other sites More sharing options...
alienx2 Posted March 31, 2014 Share Posted March 31, 2014 try search "dollar symbol" in google.. then copy symbol then go to BO>Localization>Currencies>Click your country then paste in symbol then click SAVE/APPLY Link to comment Share on other sites More sharing options...
PascalVG Posted March 31, 2014 Share Posted March 31, 2014 Hi sickshot, No solution yet, but maybe an idea that gets you started. I have a javascript that checks the body for instances of the currency (I believe you use GEL and ლარი, right? If you add the following code to themes/<your theme folder>/header.tpl (just above the line {$HOOK_HEADER} INside the <head>...</head> tag )) {assign var="hdr_language" value=Context::getContext()->language->id}<script> $(document).ready(function() { if ({$hdr_language} == XXXX) { var replaced=document.body.innerHTML.replace(/GEL/g,'ლარი'); document.body.innerHTML=replaced; } });</script> (and Replace XXXX witht the language ID of your Georgian language in PrestaShop) In Localization->Currencies, use GEL as Unit of Currency. What it does is, when the Language changes to Georgian, it will replace the GEL with ლარი. This sounds great, but I bumped into a few problems: - After replacing the body text with the new 'replaced' (in the line: document.body.innerHTML=replaced;), not all javascripts seem to work anymore, like the shoppingcart won't fold open, the top menu- drop down menu's won't open etc. - When adding some product to the cart, I expect that the added product still has the GEL as currency unit, as it won't be 'translated' on the fly, only one time, when loading the page the first time. So, this won't fully work, but it may give you some idea how wo do the translation. Maybe someone else has a great idea where to put this code to make it work everywhere and correctly with the diverse scripts... My 2 cents, pascal. 1 Link to comment Share on other sites More sharing options...
El Patron Posted March 31, 2014 Share Posted March 31, 2014 your currency symbol is not here? http://www.xe.com/symbols.php Link to comment Share on other sites More sharing options...
sickshot Posted March 31, 2014 Author Share Posted March 31, 2014 hello and thank you for your replays! Pascal you're right thats exactly my case I'll check and see whats happens then I'll get back with the results.. El Patron No. sound silly but we dont have a symbol we use only GEL when needed in English as USD is used... 1 Link to comment Share on other sites More sharing options...
PascalVG Posted March 31, 2014 Share Posted March 31, 2014 Hi Sickshot, I think I found an easy way! Edit file: classes/tools.php find the function: public static function displayPrice($price, $currency = null, $no_utf8 = false, Context $context = null) 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; // if you modified this function, don't forget to modify the Javascript function formatCurrency (in tools.js) elseif (is_int($currency)) $currency = Currency::getCurrencyInstance((int)$currency); if (is_array($currency)) { $c_char = $currency['sign']; $c_format = $currency['format']; $c_decimals = (int)$currency['decimals'] * _PS_PRICE_DISPLAY_PRECISION_; $c_blank = $currency['blank']; } elseif (is_object($currency)) { $c_char = $currency->sign; $c_format = $currency->format; $c_decimals = (int)$currency->decimals * _PS_PRICE_DISPLAY_PRECISION_; $c_blank = $currency->blank; } else return false; $blank = ($c_blank ? ' ' : ''); $ret = 0; if (($is_negative = ($price < 0))) $price *= -1; $price = Tools::ps_round($price, $c_decimals); switch ($c_format) { /* X 0,000.00 */ case 1: $ret = $c_char.$blank.number_format($price, $c_decimals, '.', ','); break; /* 0 000,00 X*/ case 2: $ret = number_format($price, $c_decimals, ',', ' ').$blank.$c_char; break; /* X 0.000,00 */ case 3: $ret = $c_char.$blank.number_format($price, $c_decimals, ',', '.'); break; /* 0,000.00 X */ case 4: $ret = number_format($price, $c_decimals, '.', ',').$blank.$c_char; break; /* 0 000.00 X Added for the switzerland currency */ case 5: $ret = number_format($price, $c_decimals, '.', ' ').$blank.$c_char; break; } if ($is_negative) $ret = '-'.$ret; if ($no_utf8) return str_replace('€', chr(128), $ret); return $ret; } and add the follwing lines: if ((int)Context::getContext()->language->id == XXXX) // XXXX is langage ID of Greorgian $c_char ='ლარი'; // (see your Localization->Languages) like this: 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; // if you modified this function, don't forget to modify the Javascript function formatCurrency (in tools.js) elseif (is_int($currency)) $currency = Currency::getCurrencyInstance((int)$currency); if (is_array($currency)) { $c_char = $currency['sign']; $c_format = $currency['format']; $c_decimals = (int)$currency['decimals'] * _PS_PRICE_DISPLAY_PRECISION_; $c_blank = $currency['blank']; } elseif (is_object($currency)) { $c_char = $currency->sign; $c_format = $currency->format; $c_decimals = (int)$currency->decimals * _PS_PRICE_DISPLAY_PRECISION_; $c_blank = $currency->blank; } else return false; if ((int)Context::getContext()->language->id == XXXX) // <-- add here $c_char ='ლარი'; $blank = ($c_blank ? ' ' : ''); $ret = 0; if (($is_negative = ($price < 0))) $price *= -1; $price = Tools::ps_round($price, $c_decimals); switch ($c_format) { /* X 0,000.00 */ case 1: $ret = $c_char.$blank.number_format($price, $c_decimals, '.', ','); break; /* 0 000,00 X*/ case 2: $ret = number_format($price, $c_decimals, ',', ' ').$blank.$c_char; break; /* X 0.000,00 */ case 3: $ret = $c_char.$blank.number_format($price, $c_decimals, ',', '.'); break; /* 0,000.00 X */ case 4: $ret = number_format($price, $c_decimals, '.', ',').$blank.$c_char; break; /* 0 000.00 X Added for the switzerland currency */ case 5: $ret = number_format($price, $c_decimals, '.', ' ').$blank.$c_char; break; } if ($is_negative) $ret = '-'.$ret; if ($no_utf8) return str_replace('€', chr(128), $ret); return $ret; } resullt: before changing to Greorgian language: after: If you have more languages that you support, you can change the line to something like: if (((int)Context::getContext()->language->id == XXXX) AND ((int)Context::getContext()->currency->id == YYYY)) //$c_char ='ლარი'; Where YYYY is currency ID of Greorgian currency Hope that helps, pascal. Link to comment Share on other sites More sharing options...
sickshot Posted March 31, 2014 Author Share Posted March 31, 2014 (edited) thank you Pascal, I did it, but site messed up . my code looks little different as I can see, maybe theres something to do with the PS version? i'm running 1.4.7 I'm unable to post my code in post so I attach it.. Tools.php Edited March 31, 2014 by sickshot (see edit history) Link to comment Share on other sites More sharing options...
PascalVG Posted March 31, 2014 Share Posted March 31, 2014 Hi sickshot, Don't add the name of the language, but it's ID number: So for example, if your language ka has an ID of 2: Don't add: if ((int)Context::getContext()->language->id == ka) $c_char ='ლარი'; but if ((int)Context::getContext()->language->id == 2) $c_char ='ლარი'; That should do the trick. pascal Link to comment Share on other sites More sharing options...
sickshot Posted March 31, 2014 Author Share Posted March 31, 2014 sorry but result is the same... Link to comment Share on other sites More sharing options...
PascalVG Posted March 31, 2014 Share Posted March 31, 2014 emm, 1.4.7 right.... try this: (If your language ka has an ID of 2): if ((int)$cookie->id_lang == 2) $c_char ='ლარი'; Hope this is it... pascal Link to comment Share on other sites More sharing options...
sickshot Posted April 2, 2014 Author Share Posted April 2, 2014 hello PascalVG tried this last code and nothing happened Link to comment Share on other sites More sharing options...
PascalVG Posted April 3, 2014 Share Posted April 3, 2014 Sorry.... Didn't work with 1.4 for a while... add: global $cookie; global $cookie; if ((int)$cookie->id_lang == 2) $c_char ='ლარი'; total function: public static function displayPrice($price, $currency = NULL, $no_utf8 = false) { if ($currency === NULL) $currency = Currency::getCurrent(); /* if you modified this function, don't forget to modify the Javascript function formatCurrency (in tools.js) */ if (is_int($currency)) $currency = Currency::getCurrencyInstance((int)$currency); if (is_array($currency)) { $c_char = $currency['sign']; $c_format = $currency['format']; $c_decimals = (int)$currency['decimals'] * _PS_PRICE_DISPLAY_PRECISION_; $c_blank = $currency['blank']; } elseif (is_object($currency)) { $c_char = $currency->sign; $c_format = $currency->format; $c_decimals = (int)$currency->decimals * _PS_PRICE_DISPLAY_PRECISION_; $c_blank = $currency->blank; } else return false; global $cookie; if ((int)$cookie->id_lang == 1) // replace 1 with language ID where GEL should be replaced with ლარი $c_char ='ლარი'; $blank = ($c_blank ? ' ' : ''); $ret = 0; if (($isNegative = ($price < 0))) $price *= -1; $price = self::ps_round($price, $c_decimals); switch ($c_format) { /* X 0,000.00 */ case 1: $ret = $c_char.$blank.number_format($price, $c_decimals, '.', ','); break; /* 0 000,00 X*/ case 2: $ret = number_format($price, $c_decimals, ',', ' ').$blank.$c_char; break; /* X 0.000,00 */ case 3: $ret = $c_char.$blank.number_format($price, $c_decimals, ',', '.'); break; /* 0,000.00 X */ case 4: $ret = number_format($price, $c_decimals, '.', ',').$blank.$c_char; break; } if ($isNegative) $ret = '-'.$ret; if ($no_utf8) return str_replace('€', chr(128), $ret); return $ret; } Hope this really does the trick. Can you give me the URL to see the result? pascal Link to comment Share on other sites More sharing options...
sickshot Posted April 3, 2014 Author Share Posted April 3, 2014 PascalVG thank you it worked everywhere except product page... Link to comment Share on other sites More sharing options...
PascalVG Posted April 3, 2014 Share Posted April 3, 2014 Please edit themes/<your theme folder>/js/tools.js (make backup, just in case) edit Function formatCurrency: //return a formatted pricefunction formatCurrency(price, currencyFormat, currencySign, currencyBlank){ // if you modified this function, don't forget to modify the PHP function displayPrice (in the Tools.php class) blank = ''; price = Number(price); price = parseFloat(price.toFixed(6)); price = ps_round(price, priceDisplayPrecision); global $cookie; if ((int)$cookie->id_lang == 1) $currencySign ='ლარი'; if (currencyBlank > 0) blank = ' ';... I think we're finally there.... pascal 1 Link to comment Share on other sites More sharing options...
sickshot Posted April 3, 2014 Author Share Posted April 3, 2014 (edited) PascalVG Great Work! Thank you so much for helping me solve this! you are awesome! P.S. can this code make other Java script to freeze? I'm using color attributes and when I choose color Image doesnt change anymore... Edited April 3, 2014 by sickshot (see edit history) Link to comment Share on other sites More sharing options...
alldz Posted September 23, 2016 Share Posted September 23, 2016 Hello any solution for 1.6.* ? Link to comment Share on other sites More sharing options...
rl_lucian Posted March 8, 2017 Share Posted March 8, 2017 (edited) Please edit themes/<your theme folder>/js/tools.js (make backup, just in case) edit Function formatCurrency: //return a formatted price function formatCurrency(price, currencyFormat, currencySign, currencyBlank) { // if you modified this function, don't forget to modify the PHP function displayPrice (in the Tools.php class) blank = ''; price = Number(price); price = parseFloat(price.toFixed(6)); price = ps_round(price, priceDisplayPrecision); global $cookie; if ((int)$cookie->id_lang == 1) $currencySign ='ლარი'; if (currencyBlank > 0) blank = ' '; ... I think we're finally there.... pascal Hello Pascal, Can you please tell us how can i translate Currency Sign from "RON" to "LEI" in Prestashop 1.7? Front: https://i.imgsafe.org/fce0c69115.png Back: https://i.imgsafe.org/fce0b8e5bf.png Thank you! Edited March 8, 2017 by rl_lucian (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now