From 0f614669b674bd19ac44a1100535f208317331f7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Sun, 17 Nov 2013 16:02:29 +0100 Subject: [PATCH] IcuCollation: Add CollationCkb subclass for Sorani Kurdish ICU does not currently support Sorani Kurdish / Central Kurdish language ('ckb'). CollationCkb uses the same collation rules as Persian / Farsi ('fa'), but different characters for digits. For use at ckb.wikipedia, which currently has 'uca-fa' collation deployed as a workaround. Added the MW language used for transforming digits to cache key for first-letters data, in addition to the ICU locale. Bug: 55630 Change-Id: I7d7f007592ede952859c5c9556b9ea5084b90e89 --- includes/AutoLoader.php | 1 + includes/Collation.php | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index ca40d1e461..58c8461368 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -50,6 +50,7 @@ $wgAutoloadLocalClasses = array( 'ChangeTags' => 'includes/ChangeTags.php', 'ChannelFeed' => 'includes/Feed.php', 'Collation' => 'includes/Collation.php', + 'CollationCkb' => 'includes/Collation.php', 'ConcatenatedGzipHistoryBlob' => 'includes/HistoryBlob.php', 'Cookie' => 'includes/Cookie.php', 'CookieJar' => 'includes/Cookie.php', diff --git a/includes/Collation.php b/includes/Collation.php index b0688f54e1..7204f3129d 100644 --- a/includes/Collation.php +++ b/includes/Collation.php @@ -47,6 +47,8 @@ abstract class Collation { return new IdentityCollation; case 'uca-default': return new IcuCollation( 'root' ); + case 'xx-uca-ckb': + return new CollationCkb; default: $match = array(); if ( preg_match( '/^uca-([a-z@=-]+)$/', $collationName, $match ) ) { @@ -350,7 +352,7 @@ class IcuCollation extends Collation { } $cache = wfGetCache( CACHE_ANYTHING ); - $cacheKey = wfMemcKey( 'first-letters', $this->locale ); + $cacheKey = wfMemcKey( 'first-letters', $this->locale, $this->digitTransformLanguage->getCode() ); $cacheEntry = $cache->get( $cacheKey ); if ( $cacheEntry && isset( $cacheEntry['version'] ) @@ -615,3 +617,17 @@ class IcuCollation extends Collation { } } } + +/** + * Workaround for the lack of support of Sorani Kurdish / Central Kurdish language ('ckb') in ICU. + * + * Uses the same collation rules as Persian / Farsi ('fa'), but different characters for digits. + */ +class CollationCkb extends IcuCollation { + function __construct() { + // This will set $locale and collators, which affect the actual sorting order + parent::__construct( 'fa' ); + // Override the 'fa' language set by parent constructor, which affects #getFirstLetterData() + $this->digitTransformLanguage = Language::factory( 'ckb' ); + } +} -- 2.20.1