r97522 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97521‎ | r97522 | r97523 >
Date:18:07, 19 September 2011
Author:reedy
Status:ok
Tags:
Comment:
REL1_18 MFT r97515
Modified paths:
  • /branches/REL1_18/phase3/RELEASE-NOTES-1.18 (modified) (history)
  • /branches/REL1_18/phase3/languages/classes/LanguageOs.php (added) (history)

Diff [purge]

Index: branches/REL1_18/phase3/RELEASE-NOTES-1.18
@@ -627,6 +627,7 @@
628628 (Devanagari) (ks-deva). Defaults to ks-arab.
629629 * (bug 30817) Restored linktrail for kk (Kazakh)
630630 * (bug 27398) Add $wgExtraGenderNamespaces for configured gendered namespaces
 631+* (bug 30846) New LanguageOs class
631632
632633 === Other changes in 1.18 ===
633634 * Removed legacy wgAjaxWatch javascript global object, no longer in use.
Property changes on: branches/REL1_18/phase3/RELEASE-NOTES-1.18
___________________________________________________________________
Modified: svn:mergeinfo
634635 Merged /trunk/phase3/RELEASE-NOTES-1.18:r97515
Index: branches/REL1_18/phase3/languages/classes/LanguageOs.php
@@ -0,0 +1,87 @@
 2+<?php
 3+
 4+/** Ossetian (Ирон)
 5+ *
 6+ * @author Soslan Khubulov
 7+ *
 8+ * @ingroup Language
 9+ */
 10+class LanguageOs extends Language {
 11+
 12+ /**
 13+ * Convert from the nominative form of a noun to other cases
 14+ * Invoked with {{grammar:case|word}}
 15+ *
 16+ * Depending on word there are four different ways of converting to other cases.
 17+ * 1) Word consist of not cyrillic letters or is an abbreviation.
 18+ * Then result word is: word + hyphen + case ending.
 19+ *
 20+ * 2) Word consist of cyrillic letters.
 21+ * 2.1) Word is in plural.
 22+ * Then result word is: word - last letter + case ending. Ending of allative case here is 'æм'.
 23+ *
 24+ * 2.2) Word is in singular.
 25+ * 2.2.1) Word ends on consonant.
 26+ * Then result word is: word + case ending.
 27+ *
 28+ * 2.2.2) Word ends on vowel.
 29+ * Then result word is: word + 'й' + case ending for cases != allative or comitative
 30+ * and word + case ending for allative or comitative. Ending of allative case here is 'æ'.
 31+ *
 32+ * @param $word string
 33+ * @param $case string
 34+ * @return string
 35+ */
 36+ function convertGrammar( $word, $case ) {
 37+ global $wgGrammarForms;
 38+ if ( isset( $wgGrammarForms['os'][$case][$word] ) ) {
 39+ return $wgGrammarForms['os'][$case][$word];
 40+ }
 41+ # Ending for allative case
 42+ $end_allative = 'мæ';
 43+ # Variable for 'j' beetwen vowels
 44+ $jot = '';
 45+ # Variable for "-" for not Ossetic words
 46+ $hyphen = '';
 47+ # Variable for ending
 48+ $ending = '';
 49+
 50+
 51+ # CHecking if the $word is in plural form
 52+ if ( preg_match( '/тæ$/u', $word ) ) {
 53+ $word = mb_substr( $word, 0, -1 );
 54+ $end_allative = 'æм';
 55+ }
 56+ # Works if $word is in singular form.
 57+ # Checking if $word ends on one of the vowels: е, ё, и, о, ы, э, ю, я.
 58+ elseif ( preg_match( "/[аæеёиоыэюя]$/u", $word ) ) {
 59+ $jot = 'й';
 60+ }
 61+ # Checking if $word ends on 'у'. 'У' can be either consonant 'W' or vowel 'U' in cyrillic Ossetic.
 62+ # Examples: {{grammar:genitive|аунеу}} = аунеуы, {{grammar:genitive|лæппу}} = лæппуйы.
 63+ elseif ( preg_match( "/у$/u", $word ) ) {
 64+ if ( !preg_match( "/[аæеёиоыэюя]$/u", mb_substr( $word, -2, 1 ) ) )
 65+ $jot = 'й';
 66+ } elseif ( !preg_match( "/[бвгджзйклмнопрстфхцчшщьъ]$/u", $word ) ) {
 67+ $hyphen = '-';
 68+ }
 69+
 70+ switch ( $case ) {
 71+ case 'genitive': $ending = $hyphen . $jot . 'ы'; break;
 72+ case 'dative': $ending = $hyphen . $jot . 'æн'; break;
 73+ case 'allative': $ending = $hyphen . $end_allative; break;
 74+ case 'ablative':
 75+ if ( $jot == 'й' ) {
 76+ $ending = $hyphen . $jot . 'æ'; break;
 77+ }
 78+ else {
 79+ $ending = $hyphen . $jot . 'æй'; break;
 80+ }
 81+ case 'inessive': break;
 82+ case 'superessive': $ending = $hyphen . $jot . 'ыл'; break;
 83+ case 'equative': $ending = $hyphen . $jot . 'ау'; break;
 84+ case 'comitative': $ending = $hyphen . 'имæ'; break;
 85+ }
 86+ return $word . $ending;
 87+ }
 88+}
Property changes on: branches/REL1_18/phase3/languages/classes/LanguageOs.php
___________________________________________________________________
Added: svn:eol-style
189 + native

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r97515* (bug 30846) New LanguageOs classnikerabbit17:00, 19 September 2011

Status & tagging log