mysociety / yournextrepresentative

A website for crowd-sourcing structured election candidate data
https://candidates.democracyclub.org.uk/
GNU Affero General Public License v3.0
56 stars 21 forks source link

Support non-English slugs #880

Open wfdd opened 8 years ago

wfdd commented 8 years ago

There's two separate issues here:

  1. The slugify filter used in templates is the built-in Django one, which, prior to 1.9, has no support for non-ASCII characters; the slug of a Greek name is an empty string:

    In [1]: from django.template.defaultfilters import slugify
    
    In [2]: slugify('Γιάννης')
    Out[2]: ''
  2. A different slugify transform is used in code, python-slugify, which does support Unicode (via unidecode). This one's also problematic 'cause it has no conception of language. What this means is that the authors have made a choice for which language they were gonna transliterate from for any particular script. For the Greek alphabet, it's the Ancient Greek language. For Cyrillic, it might be Russian.

@dracos suggested on IRC that we backport the 1.9 slugify filter, which simply leaves Unicode characters intact (and presumably remove python-slugify in its favour). This sounds like the most elegant solution to me, but I'd suggest that we also make it easy for users to plug in their own slugify, if at all possible.