Bartosz Dziewoński has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/89488


Change subject: IcuCollation: Sort digits under localised digits' headings
......................................................................

IcuCollation: Sort digits under localised digits' headings

Previously both '1' and '۱' ("DIGIT ONE" and "EXTENDED ARABIC-INDIC
DIGIT ONE") were sorted under '1' heading, regardless of collation
locale.

Now they will be both sorted under localised heading name (transformed
using Language#formatNum), for example '1' for 'uca-en' collation or
'۱' for 'uca-fa' collation.

Bug: 55630
Change-Id: I0b745d955a6e72f53873c95648087aa5f90a8852
---
M includes/Collation.php
1 file changed, 12 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/88/89488/1

diff --git a/includes/Collation.php b/includes/Collation.php
index b0252c7..7061f80 100644
--- a/includes/Collation.php
+++ b/includes/Collation.php
@@ -149,7 +149,7 @@
 }
 
 class IcuCollation extends Collation {
-       const FIRST_LETTER_VERSION = 1;
+       const FIRST_LETTER_VERSION = 2;
 
        var $primaryCollator, $mainCollator, $locale;
        var $firstLetterData;
@@ -284,7 +284,12 @@
                        throw new MWException( 'An ICU collation was requested, 
' .
                                'but the intl extension is not available.' );
                }
+
                $this->locale = $locale;
+               // Drop everything after the '@' in locale's name
+               $baseLocale = explode( '@', $locale )[0];
+               $this->language = Language::factory( $baseLocale === 'root' ? 
'en' : $baseLocale );
+
                $this->mainCollator = Collator::create( $locale );
                if ( !$this->mainCollator ) {
                        throw new MWException( "Invalid ICU locale specified 
for collation: $locale" );
@@ -367,6 +372,12 @@
                        if ( isset( self::$tailoringFirstLetters['-' . 
$this->locale] ) ) {
                                $letters = array_diff( $letters, 
self::$tailoringFirstLetters['-' . $this->locale] );
                        }
+                       // Apply digit transforms
+                       $digits = array( '0', '1', '2', '3', '4', '5', '6', 
'7', '8', '9' );
+                       $letters = array_diff( $letters, $digits );
+                       foreach ( $digits as $digit ) {
+                               $letters[] = $this->language->formatNum( 
$digit, true );
+                       }
                } else {
                        $letters = wfGetPrecompiledData( 
"first-letters-{$this->locale}.ser" );
                        if ( $letters === false ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/89488
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0b745d955a6e72f53873c95648087aa5f90a8852
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to