Skip to content

Conversation

@ebsaral
Copy link
Contributor

@ebsaral ebsaral commented Jan 12, 2015

Mentioned in my first merge request, smart_boolean enables to replace common latin letters with their ascii representations.

Example:

from slugify import slugify
>>> slugify(u'Bakıcı geldi')
u'bak\u0131c\u0131-geldi'
>>> slugify(u'Bakıcı geldi', smart_replace=True)
u'bakici-geldi'

So that people who does not have 'ı' letter in their keyboards will be able to match the string by using either 'ı' or 'i' from their keyboards.

For current version, 'bakici' cannot match 'bakıcı'. But with smart_replace, 'bakıcı' and 'bakici' can both match 'bakıcı' because 'bakici' may represent 'bakıcı' within an English keyboard.

List of common latin letters to replace

  • ı, ì, í, î, ï -> i
    -İ, Ì, Í, Î, Ï -> I
  • ö, ó, ò, ô, õ, ø -> o
  • Ö, Ò, Ó, Ô, Õ, Ø -> O
  • ü, ù, ú, û -> u
  • Ü, Ù, Ú, Û -> U
  • à, á, â, ã, ä, å -> a
  • À, Á, Â, Ã, Ä, Å -> A
  • æ -> ae
  • Æ -> AE
  • è, é, ê, ë -> e
  • È, É, Ê, Ë -> E
  • ñ -> n
  • Ñ -> N
  • ý, ÿ -> y
  • Ý, Ÿ -> Y
  • ş -> s
  • Ş -> S
  • ç -> c
  • Ç -> C
  • ğ -> g
  • Ğ -> G

@ebsaral ebsaral changed the title smart_replace boolean replace_latin boolean Jan 12, 2015
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you wouldn't mind adding a docstring here that would be great too, at least explain what replace_latin does when enabled and when disabled.

@davedash
Copy link
Contributor

This looks good, if you can make those minor changes that'd be great, and I'll merge this.

@davedash
Copy link
Contributor

Also... may want to consider this library too:

https://github.com/dimka665/awesome-slugify

It might do everything this one does and then some already.

@ebsaral
Copy link
Contributor Author

ebsaral commented Jan 12, 2015

I checked that library but I liked this one since it's simple.

Made the changes.

@ebsaral
Copy link
Contributor Author

ebsaral commented Jan 12, 2015

If it's possible to build a new version with that merge, I would like to use this package in my requirements.

@ebsaral ebsaral closed this Jan 12, 2015
@ebsaral ebsaral reopened this Jan 12, 2015
@ebsaral ebsaral closed this Jan 13, 2015
@ebsaral ebsaral deleted the feature/smart_replace branch January 13, 2015 04:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants