alfa123 Posted August 12, 2012 Share Posted August 12, 2012 How can I display non-latin characters in friendly URLs? In my case thai letters. This should be quite easy using url encoding. For example, thai word for "shoe": รองเท้า with url encoding it's: %E0%B8%A3%E0%B8%AD%E0%B8%87%E0%B9%80%E0%B8%97%E0%B9%89%E0%B8%B2 But prestashop filters out the % character and the result is: E0B8A3E0B8ADE0B887E0B980E0B897E0B989E0B8B2 I've looked around on thai websites with thai letters in the URL. The HTML source contain url encoded characters such as the example above. Example of such page: http://www.bbfashion-shop.com/category/11/%E0%B8%9E%E0%B8%A3%E0%B8%B5%E0%B8%AD%E0%B8%AD%E0%B9%80%E0%B8%94%E0%B8%AD%E0%B8%A3%E0%B9%8C-%E0%B8%81%E0%B8%A3%E0%B8%B0%E0%B9%80%E0%B8%9B%E0%B9%8B%E0%B8%B2%E0%B9%81%E0%B8%9F%E0%B8%8A%E0%B8%B1%E0%B9%88%E0%B8%99/ Link to comment Share on other sites More sharing options...
alfa123 Posted August 12, 2012 Author Share Posted August 12, 2012 (edited) I've just tried to add url-encoded string into link_rewrite manually thru phpMyAdmin and it WORKS! =) However, it does NOT work if I enter thai letter. It works only if I enter url encoded. Here is the result: http://veenafashion.com/th/5-%E0%B9%80%E0%B8%AA%E0%B8%B7%E0%B9%89%E0%B8%AD%E0%B8%9C%E0%B9%89%E0%B8%B2 In the address bar it shows thai letters. Edited August 12, 2012 by alfa123 (see edit history) Link to comment Share on other sites More sharing options...
Suthichai Posted August 25, 2012 Share Posted August 25, 2012 To be able to input Thai letters in products, there are 3 steps: Step 1 FIle#1: classes/Validate.php Change from public static function isLinkRewrite($link) { return preg_match('/^[_a-zA-Z0-9\-\pL]+$/u', $link); } To public static function isLinkRewrite($link) { return preg_match('/^[_a-zA-Z0-9ก-๙\-\pL]+$/u', $link); } Step 2 File #2: shop_root/js/admin.js, at the very beginning of the file, look for function str2url(str,encoding,ucfirst) Change from str = str.replace(/[^a-z0-9\s\'\:\/\[\]-]\\u00A1-\\uFFFF/g,''); to str = str.replace(/[^a-z0-9ก-๙\s\'\:\/\[\]-]\\u00A1-\\uFFFF/g,''); Now we can enter Thai characters in Catalog > Products > SEO > Friendly URL. Step 3 Finally, I guess .htaccess need to be changed (try messing around [_a-zA-Z0-9-]), but unfortunately I could not get it working. Still looking for a better solution. Link to comment Share on other sites More sharing options...
Suthichai Posted August 25, 2012 Share Posted August 25, 2012 In case you want to search in Thai, try this Link to comment Share on other sites More sharing options...
Suthichai Posted August 26, 2012 Share Posted August 26, 2012 Got it working, there are only 2 files need to be changed: 1. classes/Validate.php Search for: return preg_match('/^[_a-zA-Z0-9\-\pL]+$/u', $link); Replace with return preg_match('/^[_a-zA-Z0-9\-\pL\pM]+$/u', $link); 2. classes/Dispatcher.php Search for /pL, and replace with /pL/pM Then we can input Thai and display the nice friendly URL. It turns out to be quite easy, credit must be given to the Prestashop team for delivering us such a wonderful system. This is for v1.5.0.15 1 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