| 1 | <?php |
| 2 | /** |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License as published by |
| 5 | * the Free Software Foundation; either version 2 of the License, or |
| 6 | * (at your option) any later version. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License along |
| 14 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 15 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 16 | * http://www.gnu.org/copyleft/gpl.html |
| 17 | * |
| 18 | * @file |
| 19 | */ |
| 20 | |
| 21 | use MediaWiki\Language\Language; |
| 22 | use MediaWiki\MainConfigNames; |
| 23 | use MediaWiki\MediaWikiServices; |
| 24 | |
| 25 | /** |
| 26 | * Old Church Slavonic (Ѩзыкъ словѣньскъ) |
| 27 | * |
| 28 | * @ingroup Languages |
| 29 | */ |
| 30 | class LanguageCu extends Language { |
| 31 | public function convertGrammar( $word, $case ) { |
| 32 | $grammarForms = |
| 33 | MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::GrammarForms ); |
| 34 | |
| 35 | if ( isset( $grammarForms['сu'][$case][$word] ) ) { |
| 36 | return $grammarForms['сu'][$case][$word]; |
| 37 | } |
| 38 | |
| 39 | # These rules are not perfect, but they are currently only used for |
| 40 | # site names, so it doesn't matter if they are wrong sometimes. |
| 41 | # Just add a special case for your site name if necessary. |
| 42 | |
| 43 | # join and array_slice instead mb_substr |
| 44 | $ar = []; |
| 45 | preg_match_all( '/./us', $word, $ar ); |
| 46 | if ( !preg_match( "/[a-zA-Z_]/u", $word ) ) { |
| 47 | switch ( $case ) { |
| 48 | case 'genitive': # родительный падеж |
| 49 | // if ( ( implode( '', array_slice( $ar[0], -4 ) ) == 'вики' ) |
| 50 | // || ( implode( '', array_slice( $ar[0], -4 ) ) == 'Вики' ) |
| 51 | // ) { |
| 52 | // } |
| 53 | |
| 54 | if ( implode( '', array_slice( $ar[0], -2 ) ) == 'ї' ) { |
| 55 | return implode( '', array_slice( $ar[0], 0, -2 ) ) . 'їѩ'; |
| 56 | } |
| 57 | break; |
| 58 | case 'accusative': # винительный падеж |
| 59 | # stub |
| 60 | break; |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | return $word; |
| 65 | } |
| 66 | } |