43 private $digitTransformLang;
55 $this->digitTransformLang = $digitTransformLang instanceof
Language
57 : $languageFactory->
getLanguage( $digitTransformLang );
58 parent::__construct( $languageFactory );
62 $sortkey = parent::getSortKey( $string );
63 $sortkey = $this->convertDigits( $sortkey );
69 $sortkey = preg_replace_callback(
'/\d+/',
static function (
$matches ) {
72 $len = strlen( $number );
75 $prefix = chr( (
int)floor( $len / 256 ) ) . chr( $len % 256 );
76 return '0' . $prefix . $number;
90 private function convertDigits( $string ) {
91 $table = $this->digitTransformLang->digitTransformTable();
93 $table = array_filter( $table );
94 $flipped = array_flip( $table );
96 $flipped = array_filter( $flipped,
'is_numeric' );
97 $string = strtr( $string, $flipped );
103 $convertedString = $this->convertDigits( $string );
105 if ( preg_match(
'/^\d/', $convertedString ) ) {
106 return wfMessage(
'category-header-numerals' )
110 return parent::getFirstLetter( $string );
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Collation that orders text with numbers "naturally", so that 'Foo 1' < 'Foo 2' < 'Foo 12'.
getSortKey( $string)
Given a string, convert it to a (hopefully short) key that can be used for efficient sorting.
getFirstLetter( $string)
Given a string, return the logical "first letter" to be used for grouping on category pages and so on...
__construct(LanguageFactory $languageFactory, $digitTransformLang)