doctrine-extensions / DoctrineExtensions

Doctrine2 behavioral extensions, Translatable, Sluggable, Tree-NestedSet, Timestampable, Loggable, Sortable
MIT License
4.01k stars 1.26k forks source link

Chinese transliteration #248

Closed khepin closed 12 years ago

khepin commented 12 years ago

Hi, there's some issues with transliteration from Chinese unicode characters:

Some of them don't seem to be present: 北京 = BeiJing slugs to "-1" When some characters are slugged in a correct way, it seems to be a Cantonese transliteration.

The problem with Chinese characters is that there's a lot of possible ways to do a romanization of these characters. So in Taiwan they will need a different romanization than they use in China. Some characters are even common with Japanese who I am sure have a different way of romanizing them as well.

If you let me know how you use and format your character dictionaries I could try to provide one for Chinese characters.

Also do you think it would be possible to have "pluggable" dictionaries so that people with different needs could chose different ones?

l3pp4rd commented 12 years ago

hi, well I do not have much expertise in transliteration. but sluggable can use custom transliterator callable. so you can use drupal or whatever transliterator you see fit your needs. you can also contribute for more world friendly transliteration usage.

By default sluggable uses this utility class to transliterate from character maps here. This third party library is old as php and was migrated from perl, cannot find the original source out there anymore

khepin commented 12 years ago

Ok, indeed drupal has a quite good transliteration support, however their code is under gpl2 and I'm no expert in open source license compatibly but yours being under MIT license I'd say it's not possible to directly use it with your extensions.

Updating all the character maps with the right Chinese characters / transliteration although possible seems quite a daunting task considering the many thousands of them that exist and that they span across many different file maps so I'm not going there yet!

Can the custom transliterator callable be set in the annotations? I didn't find any reference to that.

l3pp4rd commented 12 years ago

Regarding callable, its not possible to set it through annotations, only through slug handler. but I plan to change it into event listeners. Sluggable has much use cases where people require different behaviors on most bizzar cases.

What conserns drupal, gpl indeed cannot be included as a sublicensed portion, but you could use it in your own project as a library. And so far I do not plan to create a library for that. So unless theres something useful allready, which I could use without putting much effort.

l3pp4rd commented 12 years ago

by the way, your custom callable can have a map which object classes it overrides, otherwise use an Urlizer as default

khepin commented 12 years ago

Yeah, I mean I would've spent the time to make drupal's code usable here if it was compatible or another one if there was one that's easy enough to integrate and has a compatible license but seems out of luck so far! Thanks!

khepin commented 12 years ago

For people using this through the Symfony2 bundle there's a quite simple way to add their custom transliterator. I just wrote how to there: http://sf.khepin.com/2012/01/doctrine-sluggable-and-transliteration/ if anyone has this issue later.