Page MenuHomeWickedGov Phorge

GrammarCu.php
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

GrammarCu.php

<?php
/**
* @license GPL-2.0-or-later
* @file
*/
namespace Wikimedia\Leximorph\Handler\Overrides\Grammar;
use Wikimedia\Leximorph\Handler\Overrides\IGrammarTransformer;
/**
* GrammarCu
*
* Implements grammar transformations for Church Slavonic (cu).
*
* These rules don't cover the whole grammar of the language.
* This logic was originally taken from MediaWiki Core.
* Thanks to all contributors.
*
* @since 1.45
* @author Doğu Abaris (abaris@null.net)
* @license https://www.gnu.org/copyleft/gpl.html GPL-2.0-or-later
*/
class GrammarCu implements IGrammarTransformer {
/**
* Applies Church Slavonic-specific grammatical transformations.
*
* @param string $word The word to process.
* @param string $case The grammatical case.
*
* @since 1.45
* @return string The processed word.
*/
public function process( string $word, string $case ): string {
# These rules are not perfect, but they are currently only used for
# site names, so it doesn't matter if they are wrong sometimes.
# Just add a special case for your site name if necessary.
# join and array_slice instead mb_substr
$ar = [];
preg_match_all( '/./us', $word, $ar );
if ( !preg_match( "/[a-zA-Z_]/u", $word ) ) {
switch ( $case ) {
# родительный падеж
case 'genitive':
// if ( ( implode( '', array_slice( $ar[0], -4 ) ) == 'вики' )
// || ( implode( '', array_slice( $ar[0], -4 ) ) == 'Вики' )
// ) {
// }
if ( implode( '', array_slice( $ar[0], -2 ) ) == 'ї' ) {
return implode( '', array_slice( $ar[0], 0, -2 ) ) . 'їѩ';
}
break;
# винительный падеж
case 'accusative':
# stub
break;
default:
break;
}
}
return $word;
}
}

File Metadata

Mime Type
text/x-php
Expires
Mon, Nov 23, 05:34 (3 d, 10 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
c7/cb/43db345898e3dd5c23170c7506c9
Default Alt Text
GrammarCu.php (1 KB)

Event Timeline