This extension is used to make the url more clean, change the blank to dash, change the un-ascii code to ascii, such as Œ to OE, À to A and so on. Remove the unsafe symbols such as &%$#@
Yii 1.0 or above
Download the code, and locate it in protected/components
test in your controller,
echo UrlTransliterate::cleanString("我爱 中文！");
nice class :) I have written such a component too but not that complete. Here some ideas:
$ignoreWords: Perhaps the user of the component wants to modify this, especially because of other languages. And perhaps it would be better that there is no default value.
Modify your punctuationChars() method like this:
So you have to adjust your loop in cleanString().
Nice one. Why Russian (Cyrillic) letters are translated to uppercased English letters? Should be lowercased.
Thank you for your suggestion. I have upgraded the code except the point 1: $ignoreWords. Because i think that that if the user ignore some words include the un-ASCII characters, then this class will lost its function, right?
Just feel free to have a discussion. :)
Thank you for your testing, but i didn't find the error, here is the test code. (Please forgive me the words i just copy from the yii forum, and i don't know what does that mean :p )
Here is the result:
My clients have multilingual websites so this comes in very handy.
This extension is very good for multilingual sites
I used this code before: (/protected/components/UrlGenerator.php)
The code only handle some languages from free text to URL safe text
Obviously this extension much more better. Thanks
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.