views:

146

answers:

1

In Ruby on Rails you can easily convert "any" text into a format which would work for subdomains/pathnames.

1) "I am nobody." -> "i-am-nobody"
2) "Grünkohl is a german word." -> "grunkohl-is-a-german-word"

I'd like to do this on the client-side for high responsiveness (alternative would be via Ajax).

The last example is called transliteration (converting Umlauts and other non-latin alphabets letters into latin ones). Transliteration would be a nice2have feature (in such cases I could fallback to Ajax to let Iconv do it).

Anybody knows how to do this with JavaScript? My current code works fine but has issues with multiple blank spaces, and Tête-à-tête becomes Tte--tte which is just ugly.

+2  A: 

When I needed this I used the Django javascript implementation for this wich covers most of this and even more :)

It can be found here: http://code.djangoproject.com/browser/django/trunk/django/contrib/admin/media/js/urlify.js

D4V360