42 private $digitTransformLang;
54 $this->digitTransformLang = $digitTransformLang instanceof
Language
56 : $languageFactory->
getLanguage( $digitTransformLang );
57 parent::__construct( $languageFactory );
61 $sortkey = parent::getSortKey( $string );
62 $sortkey = $this->convertDigits( $sortkey );
68 $sortkey = preg_replace_callback(
'/\d+/',
static function (
$matches ) {
71 $len = strlen( $number );
74 $prefix = chr( (
int)floor( $len / 256 ) ) . chr( $len % 256 );
75 return '0' . $prefix . $number;
89 private function convertDigits( $string ) {
90 $table = $this->digitTransformLang->digitTransformTable();
92 $table = array_filter( $table );
93 $flipped = array_flip( $table );
95 $flipped = array_filter( $flipped,
'is_numeric' );
96 $string = strtr( $string, $flipped );
102 $convertedString = $this->convertDigits( $string );
104 if ( preg_match(
'/^\d/', $convertedString ) ) {
105 return wfMessage(
'category-header-numerals' )
109 return parent::getFirstLetter( $string );
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Base class for language-specific code.
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)