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("我爱 中文!");
Total 5 comments
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
My clients have multilingual websites so this comes in very handy.
@g3ck0 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. :)
@samdark 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: ya-vot-kapchu-opredelil-v-kontrollere-vyvel-gde-nuzhno-no-vse-primery-osnovany-na-validatore-form-a-ya-ego-ne-ispolzuyu-podskazhite-gde-vzyat-znachenie-kapchi-chtoby-samomu-v-kontrollere-sdelat-proverku
Nice one. Why Russian (Cyrillic) letters are translated to uppercased English letters? Should be lowercased.
Hey,
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().
Leave a comment
Please login to leave your comment.