tebdilikiyafet Posted April 25, 2013 Share Posted April 25, 2013 There was no problem in 1.5.1 version in Turkish characters like ''çşığüö'' and they were convert to ''csiguo'' . But now in 1.5.3.1 version it doesn't convert ''ş'' and ''ğ'' to ''s'' and ''g''. Is this convertion done by classes/tool.php ? There is a replacement code like this in the file: public static function replaceAccentedChars($str) { $patterns = array( /* Lowercase */ '/[\x{0105}\x{00E0}\x{00E1}\x{00E2}\x{00E3}\x{00E4}\x{00E5}]/u', '/[\x{00E7}\x{010D}\x{0107}]/u', '/[\x{010F}]/u', '/[\x{00E8}\x{00E9}\x{00EA}\x{00EB}\x{011B}\x{0119}]/u', '/[\x{00EC}\x{00ED}\x{00EE}\x{00EF}]/u', '/[\x{0142}\x{013E}\x{013A}]/u', '/[\x{00F1}\x{0148}]/u', '/[\x{00F2}\x{00F3}\x{00F4}\x{00F5}\x{00F6}\x{00F8}]/u', '/[\x{0159}\x{0155}]/u', '/[\x{015B}\x{0161}]/u', '/[\x{00DF}]/u', '/[\x{0165}]/u', '/[\x{00F9}\x{00FA}\x{00FB}\x{00FC}\x{016F}]/u', '/[\x{00FD}\x{00FF}]/u', '/[\x{017C}\x{017A}\x{017E}]/u', '/[\x{00E6}]/u', '/[\x{0153}]/u', /* Uppercase */ '/[\x{0104}\x{00C0}\x{00C1}\x{00C2}\x{00C3}\x{00C4}\x{00C5}]/u', '/[\x{00C7}\x{010C}\x{0106}]/u', '/[\x{010E}]/u', '/[\x{00C8}\x{00C9}\x{00CA}\x{00CB}\x{011A}\x{0118}]/u', '/[\x{0141}\x{013D}\x{0139}]/u', '/[\x{00D1}\x{0147}]/u', '/[\x{00D3}]/u', '/[\x{0158}\x{0154}]/u', '/[\x{015A}\x{0160}]/u', '/[\x{0164}]/u', '/[\x{00D9}\x{00DA}\x{00DB}\x{00DC}\x{016E}]/u', '/[\x{017B}\x{0179}\x{017D}]/u', '/[\x{00C6}]/u', '/[\x{0152}]/u'); $replacements = array( 'a', 'c', 'd', 'e', 'i', 'l', 'n', 'o', 'r', 's', 'ss', 't', 'u', 'y', 'z', 'ae', 'oe', 'A', 'C', 'D', 'E', 'L', 'N', 'O', 'R', 'S', 'T', 'U', 'Z', 'AE', 'OE' ); return preg_replace($patterns, $replacements, $str); } What should I change to make the correct url replacement? Link to comment Share on other sites More sharing options...
tebdilikiyafet Posted April 25, 2013 Author Share Posted April 25, 2013 Is there any suggestion for that? Because it was ok in 1.5.1. Now 'ş' and 'ğ' are not converting to 's' and 'g' ? Do I need to add character codes for ş and ğ? How can I solve this? Link to comment Share on other sites More sharing options...
benjamin utterback Posted April 26, 2013 Share Posted April 26, 2013 Hi, thank you for the message. 1.5.4 fixes this issue. However, you should use the newest version 1.5.4.1 as it has critical updates. Happy Selling! Link to comment Share on other sites More sharing options...
tebdilikiyafet Posted April 26, 2013 Author Share Posted April 26, 2013 (edited) Which files do this convertions? classes/tools.php? I have tired 1.5.4.1 but it does not convert them to latin characters. It makes the url with the same chars. For example product name Şerğınçörü and url must be like -> sitename/sergincoru only converted to latin chars. But 1.5.4.1 makes non-latin chars on the url like: sitename/şerğınçörü I don't want non-latin chars in the url. ıt was ok 1.4.x version and also 1.5.1 but it is a bug now. moreover only 2character is the problem, "ş" and "ğ" problem. others are true. Which file should I edit for the true convertion? I think I need to add these two characters' utf codes to tools.php? Or some file else? Edited April 26, 2013 by tebdilikiyafet (see edit history) Link to comment Share on other sites More sharing options...
benjamin utterback Posted April 26, 2013 Share Posted April 26, 2013 Hi tebdilikiyatfet, what is the problem with those two characters, they do not work? Link to comment Share on other sites More sharing options...
tebdilikiyafet Posted April 26, 2013 Author Share Posted April 26, 2013 There are 6 non-latin character in Turkish these are : ş ğ ç ö ı ü In the friendly urls these characters are converting to latin chars by prestashop -> s g c o i u The problem is that prestashop don't convert "ş" and "ğ" to latin chars in the url. It deletes these two characters. If product name Şerğınçörü it makes the friendly url : sitename/erincoru . As you see it deletes them. This is the problem. Link to comment Share on other sites More sharing options...
tebdilikiyafet Posted April 26, 2013 Author Share Posted April 26, 2013 I think the problem is here: // Remove all non-whitelist chars. if (Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL')) $str = preg_replace('/[^a-zA-Z0-9\s\'\:\/\[\]-\pL]/u', '', $str); else $str = preg_replace('/[^a-zA-Z0-9\s\'\:\/\[\]-]/','', $str); $str = preg_replace('/[\s\'\:\/\[\]-]+/', ' ', $str); $str = str_replace(array(' ', '/'), '-', $str); // If it was not possible to lowercase the string with mb_strtolower, we do it after the transformations. // This way we lose fewer special chars. if (!function_exists('mb_strtolower')) $str = strtolower($str); return $str; } /** * Replace all accented chars by their equivalent non accented chars. * * @param string $str * @return string */ public static function replaceAccentedChars($str) { $patterns = array( /* Lowercase */ '/[\x{0105}\x{00E0}\x{00E1}\x{00E2}\x{00E3}\x{00E4}\x{00E5}]/u', As you see it deletes ''Remove all non-whitelist chars'' It is needed to add these 2 chars to whitelist, but how? Link to comment Share on other sites More sharing options...
prestashopninja Posted April 27, 2013 Share Posted April 27, 2013 (edited) If you don't want to upgrade and just save the day: 1. download the attached file and upload it on your PS installation, under overrides/classes directory. 2. delete cache/class_index.php file (don't be afraid, it will be regenerated) This is the same method as the original, with additions for turkish special characters. I hope this helps. Tools.php.zip Edited April 27, 2013 by prestashopninja (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts