I created an extension to String with one method called 'no_accents':
class String
def no_accents
Then I do a whack of these:
str = self
#Spanish letters
str = str.gsub("á", "a")
str = str.gsub("é","e")
For upper and lower case.
Obviously there is a big list. Right now I am just doing Spanish, French and German as they are the ones I am most interested in.
I had to make a change to Permalink_fu to call my method first:
def escape(str)
str = str.no_accents
s = ((translation_to && translation_from) ? Iconv.iconv(translation_to, translation_from, str) : str).to_s
But that's all.
Here is the file. What I did is put it in my initializers directory.
If you add to it maybe you could post your additions. I am sure some clever-clogs out there will come up with a more slick solution. But... mine works!
No comments:
Post a Comment