Last modified: 2012-03-01 20:59:42 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T36358, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 34358 - Locale-specific sorting in Arrays extension
Locale-specific sorting in Arrays extension
Status: VERIFIED FIXED
Product: MediaWiki extensions
Classification: Unclassified
Other (Other open bugs)
unspecified
All All
: Unprioritized enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch, patch-need-review
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-02-12 21:05 UTC by Van de Bugger
Modified: 2012-03-01 20:59 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Trivial patch. (439 bytes, patch)
2012-02-12 21:05 UTC, Van de Bugger
Details

Description Van de Bugger 2012-02-12 21:05:35 UTC
Created attachment 9997 [details]
Trivial patch.

I want #arraysort parser function respects current locale setting. In particular, it allows case-insensitive sorting. To achieve this, the second parameter should be passed to sort function:

> sort( $array, SORT_LOCALE_STRING );

Trivial patch is attached. However, it could change default behaviour. Maintaining backward compatibility will require changes in interface. For example:

> {{ #arraysort: key | asc, locale }}

or 

> {{ #arraysort: key | asc | locale }}

or

> {{ #arraysort: key | order=asc | flags=locale }}

or something similar. Let extension maintainer decide.
Comment 1 Van de Bugger 2012-02-12 21:06:56 UTC
Oops, sorry, wrong component was selected. Proper component "Arrays" is not present is the list...
Comment 2 Daniel A. R. Werner 2012-02-13 23:51:04 UTC
If we want to make locale as default in Version 2.0 (with compatibility mode active not enabling it at all), I would use "nolocale" to deactivate the behavior.

> {{ #arraysort: key | asc nolocale }}

I have thought about implementing further flags like "case-insensitive" or "natural" for natsort()

I am just wondering about SORT_LOCALE_STRING, what exactly does it do besides case-insensitive sorting (in some languages?). Right now I don't feel too comfortable making this default with knowing so little (it's not that well documented).
Also, what about natsort() for example, why is there no parameter for this key, or is it even always enabled for natsort() ? There is a natcasesort() too so if the key does nothing than changing case-sensitivity, 'asc case-sensitive' might be more appropriate than 'nolocale' here.

So if nobody can answer these questions, I'd do some testing by myself first before properly implementing such a flag system.
Comment 3 Daniel A. R. Werner 2012-02-28 21:24:31 UTC
Alright, I added the functionality in r112642.
for 'asce' and 'desc' sort mode the setlocale() setting will be respected. It can be deactivated by using

> {{ #arraysort: key | asc nolocale }}
> {{ #arraysort: key | desc nolocale }}

Also, there is a new sort mode 'natural' which works with PHPs natsort(). This one doesn't respect the setlocale() though.

Also, it could get nasty when it comes to UTF8 sorting and different languages, I haven't looked into that yet and probably won't in the near future.
Comment 4 Van de Bugger 2012-03-01 20:59:42 UTC
Verified on r112642.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links