Qullanıcı:Don Alessandro/Translit/LanguageCrh crh.php
Körüniş
<?php
/** Crimean Tatarish (Qırımtatarca)
*
*
* @addtogroup Language
*/
class LanguageCrh_crh extends Language {
# Convert from the nominative form of a noun to some other case
# Invoked with {{GRAMMAR:case|word}}
/**
* Cases: genitive, dative, accusative, locative, ablative + possessive forms
*/
function convertGrammarCrh_cyrl( $word, $case ) {
global $wgGrammarForms;
if ( isset( $wgGrammarForms['crh-cyrl'][$case][$word] ) ) {
return $wgGrammarForms['crh-cyrl'][$case][$word];
}
// Set up some constants...
// Vowels in last syllable
$frontVowels = array( "е", "э", "и", "ь" );
$backVowels = array( "а", "о", "у", "ы", "я", "ъ" );
$allVowels = array( "е", "э", "и", "ь", "а", "о", "у", "ы", "я", "ъ" );
// Preceding letters
$Voiceds = array( "б", "д", "г", "ъ", "ж", "л", "м", "н", "р", "в", "й", "з" );
$Voicelesses = array( "ч", "ф", "х", "к", "п", "ъ", "с", "ш", "щ", "т" );
$GroupOne = array( "а", "я", "б", "д", "е", "э", "г", "ъ", "и", "ы", "ж", "л", "м", "н", "о", "р", "у", "в", "й", "з" );
$GroupTwo = array( "а", "я", "б", "ч", "д", "е", "э", "ф", "г", "х", "и", "ы", "ж", "к", "л", "м", "н", "о", "п", "р", "с", "ш", "т", "у", "в", "й", "з" );
// Possessives
$firstPerson = array( "м", "нъ" ); // 1st singular, 2nd unformal
$secondPerson = array( "з" ); // 1st plural, 2nd formal
$thirdPerson = array( "ы", "и" ); // 3rd
$lastLetter = self::lastLetter( $word, $allVowels );
$wordEnding =& $lastLetter[0];
$wordLastVowel =& $lastLetter[1];
// Now convert the word
switch ( $case ) {
case "dc1":
case "genitive":
case "dc11":
case "possessive genitive":
if ( in_array( $wordEnding, $GroupTwo ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "нынъ";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "нынъ";
}
}
break;
case "dc2":
case "dative":
if ( in_array( $wordEnding, $Voicelesses ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "ке";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "къа";
}
} elseif ( in_array( $wordEnding, $GroupOne ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "ге";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "гъа";
}
}
break;
case "dc21":
case "possessive dative":
if ( in_array( $wordEnding, $firstPerson ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "е";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "а";
}
} elseif ( in_array( $wordEnding, $secondPerson ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "ге";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "гъа";
}
} elseif ( in_array( $wordEnding, $thirdPerson ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "не";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "на";
}
}
break;
case "dc3":
case "accusative":
if ( in_array( $wordEnding, $GroupTwo ) ) {
if ( in_array($wordLastVowel, $frontVowels ) ) {
$word = $word . "ни";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "ны";
}
}
break;
case "dc31":
case "possessive accusative":
if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) || in_array( $wordEnding, $thirdPerson ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "ни";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "ны";
}
}
break;
case "dc4":
case "locative":
if ( in_array( $wordEnding, $Voicelesses ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "те";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "та";
}
} elseif ( in_array( $wordEnding, $GroupOne ) ) {
if ( in_array( $wordLastVowel, $frontVowels) ) {
$word = $word . "де";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "да";
}
}
break;
case "dc41":
case "possessive locative":
if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "де";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "да";
}
} elseif ( in_array( $wordEnding, $thirdPerson ) ) {
if ( in_array( $wordLastVowel, $frontVowels) ) {
$word = $word . "нде";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "нда";
}
}
break;
case "dc5":
case "ablative":
if ( in_array( $wordEnding, $Voicelesses ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "тен";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "тан";
}
} elseif ( in_array($wordEnding, $GroupOne ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "ден";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "дан";
}
}
break;
case "dc51":
case "possessive ablative":
if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "ден";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "дан";
}
} elseif ( in_array($wordEnding, $thirdPerson ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "нден";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "ндан";
}
}
break;
case "dc6":
case "comitative":
if ( in_array( $wordEnding, $GroupTwo ) ) {
$word = $word . "нен";
}
break;
case "dc61":
case "possessive comitative":
if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) || in_array( $wordEnding, $thirdPerson ) ) {
$word = $word . "нен";
}
break;
default: #dc0 #nominative
}
return $word;
}
function convertGrammarCrh_latn( $word, $case ) {
global $wgGrammarForms;
if ( isset( $wgGrammarForms['crh-latn'][$case][$word] ) ) {
return $wgGrammarForms['crh-latn'][$case][$word];
}
// Set up some constants...
// Vowels in last syllable
$frontVowels = array( "e", "ö", "ü", "i" );
$backVowels = array( "a", "o", "u", "ı", "â", "q" );
$allVowels = array( "e", "ö", "ü", "i", "a", "o", "u", "ı", "â", "q" );
// Preceding letters
$Voiceds = array( "b", "c", "d", "g", "ğ", "j", "l", "m", "n", "ñ", "r", "v", "y", "z" );
$Voicelesses = array( "ç", "f", "h", "k", "p", "q", "s", "ş", "t" );
$GroupOne = array( "a", "â", "b", "c", "d", "e", "g", "ğ", "i", "ı", "j", "l", "m", "n", "ñ", "o", "ö", "r", "u", "ü", "v", "y", "z" );
$GroupTwo = array( "a", "â", "b", "c", "ç", "d", "e", "f", "g", "ğ", "h", "i", "ı", "j", "k", "l", "m", "n", "ñ", "o", "ö", "p", "q", "r", "s", "ş", "t", "u", "ü", "v", "y", "z" );
// Possessives
$firstPerson = array( "m", "ñ" ); // 1st singular, 2nd unformal
$secondPerson = array( "z" ); // 1st plural, 2nd formal
$thirdPerson = array( "ı", "i" ); // 3rd
$lastLetter = self::lastLetter( $word, $allVowels );
$wordEnding =& $lastLetter[0];
$wordLastVowel =& $lastLetter[1];
// Now convert the word
switch ( $case ) {
case "dc1":
case "genitive":
case "dc11":
case "possessive genitive":
if ( in_array( $wordEnding, $GroupTwo ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "niñ";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "nıñ";
}
}
break;
case "dc2":
case "dative":
if ( in_array( $wordEnding, $Voicelesses ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "ke";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "qa";
}
} elseif ( in_array( $wordEnding, $GroupOne ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "ge";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "ğa";
}
}
break;
case "dc21":
case "possessive dative":
if ( in_array( $wordEnding, $firstPerson ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "e";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "a";
}
} elseif ( in_array( $wordEnding, $secondPerson ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "ge";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "ğa";
}
} elseif ( in_array( $wordEnding, $thirdPerson ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "ne";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "na";
}
}
break;
case "dc3":
case "accusative":
if ( in_array( $wordEnding, $GroupTwo ) ) {
if ( in_array($wordLastVowel, $frontVowels ) ) {
$word = $word . "ni";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "nı";
}
}
break;
case "dc31":
case "possessive accusative":
if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) || in_array( $wordEnding, $thirdPerson ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "ni";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "nı";
}
}
break;
case "dc4":
case "locative":
if ( in_array( $wordEnding, $Voicelesses ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "te";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "ta";
}
} elseif ( in_array( $wordEnding, $GroupOne ) ) {
if ( in_array( $wordLastVowel, $frontVowels) ) {
$word = $word . "de";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "da";
}
}
break;
case "dc41":
case "possessive locative":
if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "de";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "da";
}
} elseif ( in_array( $wordEnding, $thirdPerson ) ) {
if ( in_array( $wordLastVowel, $frontVowels) ) {
$word = $word . "nde";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "nda";
}
}
break;
case "dc5":
case "ablative":
if ( in_array( $wordEnding, $Voicelesses ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "ten";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "tan";
}
} elseif ( in_array($wordEnding, $GroupOne ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "den";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "dan";
}
}
break;
case "dc51":
case "possessive ablative":
if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "den";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "dan";
}
} elseif ( in_array($wordEnding, $thirdPerson ) ) {
if ( in_array( $wordLastVowel, $frontVowels ) ) {
$word = $word . "nden";
} elseif ( in_array( $wordLastVowel, $backVowels ) ) {
$word = $word . "ndan";
}
}
break;
case "dc6":
case "comitative":
if ( in_array( $wordEnding, $GroupTwo ) ) {
$word = $word . "nen";
}
break;
case "dc61":
case "possessive comitative":
if ( in_array( $wordEnding, $firstPerson ) || in_array( $wordEnding, $secondPerson ) || in_array( $wordEnding, $thirdPerson ) ) {
$word = $word . "nen";
}
break;
default: #dc0 #nominative
}
return $word;
}
function lastLetter( $word, $allVowels ) {
$lastLetter = array();
$ar = array();
// Put the word in a form we can play with since we're using UTF-8
$ar = preg_split('//u', parent::lc($word), -1, PREG_SPLIT_NO_EMPTY);
// Here's an array with the order of the letters in the word reversed
// so we can find a match quicker *shrug*
$wordReversed = array_reverse( $ar );
// Here's the last letter in the word
$lastLetter[0] = $ar[count( $ar ) - 1];
// Find the last vowel in the word
$lastLetter[1] = NULL;
foreach ( $wordReversed as $xvalue ) {
foreach ( $allVowels as $yvalue ) {
if ( $xvalue == $yvalue ) {
$lastLetter[1] = $xvalue;
break;
} else {
continue;
}
}
if ( $lastLetter[1] !== NULL ) {
break;
} else {
continue;
}
}
return $lastLetter;
}
/**
* Avoid grouping whole numbers between 0 to 9999
*/
function commafy( $_ ) {
if ( !preg_match( '/^\d{1,4}$/', $_ ) ) {
return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev($_) ) );
} else {
return $_;
}
}
}