I built a multi-language site that has a Glossary page. On the English page the entries are alphabetised:
There was an issue with Alphabetising Chinese so I used a simple check to turn of Alphabetisation when non-latin characters are detected in the page title:
However, this is picking up the diacritics of Polish an non-latin. The client is now asking if they can have alphabetisation in Polish but characters like ‘Ł’ are not being sorting (they want it near L, whatever I try it’s being sorted at the end).
I’ve read about setting the locale via the config, but I’d have to do this manually and the client needs to option to have new languages themselves via the panel. I’m a bit stumped on how to tackle this one, what would be the best approach? I tried setting the locale like this:
Setting the locale separately shouldn’t be necessary, the locale is set in the language config files.
However, I found that even the sorting flag on sortBy() doesn’t work properly for the Polish language ( $projects = $page->children()->listed()->sortBy('title', 'asc', SORT_LOCALE_STRING);), not does even a simple array sort with the sorting flag
Unfortunately, I have no idea whatsoever, why the sorting doesn’t work properly with the sort flag set (not even in basic PHP).
So why I posted my findings was to find a workaround, i.e. using the collator result for custom sorting via mapping of the collection, similar to what I did in this cookbook recipe:
This seems to work for the Chinese version of the page too, and I have no idea how Chinese sorting works! Thanks for pointing me in the right direction @texnixe , you’re the best!