Maciej Bliziński wrote:
> On Sat, 2006-08-26 at 10:05 +0200, Michal wrote:
>> Full description: In my language (czech) there are a lot of characters 
>> with accents. When I type titles in admin forms, the slug field 
>> autogenerated values are incorect (for example:title="sršeň", 
> 
> Is it a hornet?

Yes it is, my Slavic brother :)

> 
>> autogenerated slug="sre"; correct is "srsen").
> 
> That's right. I've been experiencing the same thing.
> 
>> I will be glad, If some others of you add your own national characters.
> 
> I'm attaching a modified patch with Polish characters added.
> 

Thank you. I also added a few of Slovak characters (Czech and Slovak was 
brothers too, and they have similar alphabet).

> 
> 



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---
Index: django/contrib/admin/media/js/urlify.js
===================================================================
--- django/contrib/admin/media/js/urlify.js     (revision 3657)
+++ django/contrib/admin/media/js/urlify.js     (working copy)
@@ -1,4 +1,20 @@
+function replAccents(s)
+{
+    // from and to strings must have same number of characters
+    var from = 
'áčďéěíňóřšťúůýžąćęłńóśżźäľĺôŕÁČĎÉĚÍŇÓŘŠŤÚŮÝŽĄĆĘŁŃÓŚŻŹÄĽĹÔŔ';
+    var to   = 'acdeeinorstuuyzacelnoszzallorACDEEINORSTUUYZACELNOSZZALLOR';
+    for (var i = 0; i != s.length; i++) {
+        var x = from.indexOf(s[i]);
+        if (x != -1) {
+            r = new RegExp(from[x], 'g');
+            s = s.replace(r, to[x]);
+        }
+    }
+    return s;
+}
+
 function URLify(s, num_chars) {
+    s = replAccents(s);
     // changes, e.g., "Petty theft" to "petty_theft"
     // remove all these words from the string before urlifying
     removelist = ["a", "an", "as", "at", "before", "but", "by", "for", "from",

Reply via email to