From 13dc8ff88f48e0bb18750f5e98d50cdb8057c0d3 Mon Sep 17 00:00:00 2001 From: Brian Wolff Date: Tue, 15 Jan 2013 17:09:46 -0400 Subject: [PATCH] =?utf8?q?(bug=2029788)=20Swedish=20Collation=20(uppercase?= =?utf8?q?-sv).=20Swaps=20=C3=84=20and=20=C3=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit See I4542f57a. Meant as a temporary meassure until such a time generic tailoring code is implemented for uca. This patch is mostly Lejonel's code, with the class renamed. Change-Id: Id39406c37a5277d9e7a9216544de2140411c2b01 --- RELEASE-NOTES-1.21 | 2 ++ includes/AutoLoader.php | 1 + includes/Collation.php | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/RELEASE-NOTES-1.21 b/RELEASE-NOTES-1.21 index c735271391..99ac1ec74c 100644 --- a/RELEASE-NOTES-1.21 +++ b/RELEASE-NOTES-1.21 @@ -89,6 +89,8 @@ production. * (bug 5346) Categories that are redirects will be displayed italic in the category links section at the bottom of a page. * (bug 43915) New maintenance script deleteEqualMessages.php. +* New collation uppercase-sv, which is like uppercase, but adapted + to Swedish sort order. === Bug fixes in 1.21 === * (bug 40353) SpecialDoubleRedirect should support interwiki redirects. diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index be642e89fb..cb39b733b7 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -256,6 +256,7 @@ $wgAutoloadLocalClasses = array( 'UnlistedSpecialPage' => 'includes/SpecialPage.php', 'UploadSourceAdapter' => 'includes/Import.php', 'UppercaseCollation' => 'includes/Collation.php', + 'UppercaseSvCollation' => 'includes/Collation.php', 'User' => 'includes/User.php', 'UserArray' => 'includes/UserArray.php', 'UserArrayFromResult' => 'includes/UserArray.php', diff --git a/includes/Collation.php b/includes/Collation.php index f53ce02c66..7c2c05ed0a 100644 --- a/includes/Collation.php +++ b/includes/Collation.php @@ -43,6 +43,8 @@ abstract class Collation { switch( $collationName ) { case 'uppercase': return new UppercaseCollation; + case 'uppercase-sv': + return new UppercaseSvCollation; case 'identity': return new IdentityCollation; case 'uca-default': @@ -121,6 +123,22 @@ class UppercaseCollation extends Collation { } } +/** + * Like UppercaseCollation but swaps Ä and Æ. + * + * This provides an ordering suitable for Swedish. + * @author Lejonel + */ +class UppercaseSvCollation extends UppercaseCollation { + + /* Unicode code point order is ÄÅÆÖ, Swedish order is ÅÄÖ and Æ is often sorted as Ä. + * Replacing Ä for Æ should give a better collation. */ + function getSortKey( $string ) { + $uppercase = $this->lang->uc( $string ); + return strtr( $uppercase, array( 'Ä' => 'Æ', 'Æ' => 'Ä' ) ); + } +} + /** * Collation class that's essentially a no-op. * -- 2.20.1