Merge "Don't fallback from uk to ru"
[lhc/web/wiklou.git] / languages / classes / LanguageRu.php
index 60384a8..62de390 100644 (file)
@@ -31,7 +31,6 @@
  * @ingroup Language
  */
 class LanguageRu extends Language {
-
        /**
         * Convert from the nominative form of a noun to some other case
         * Invoked with {{grammar:case|word}}
@@ -46,19 +45,22 @@ class LanguageRu extends Language {
                        return $wgGrammarForms['ru'][$case][$word];
                }
 
-               $grammarDataFile = __DIR__ . '/data/grammar.ru.json';
-               $grammarData = FormatJson::decode( file_get_contents( $grammarDataFile ), true );
+               $grammarTransformations = $this->getGrammarTransformations();
+
+               if ( isset( $grammarTransformations[$case] ) ) {
+                       foreach ( array_values( $grammarTransformations[$case] ) as $rule ) {
+                               $form = $rule[0];
 
-               if ( array_key_exists( $case, $grammarData ) ) {
-                       foreach ( array_keys( $grammarData[$case] ) as $form ) {
                                if ( $form === '@metadata' ) {
                                        continue;
                                }
 
+                               $replacement = $rule[1];
+
                                $regex = "/$form/";
 
                                if ( preg_match( $regex, $word ) ) {
-                                       $word = preg_replace( $regex, $grammarData[$case][$form], $word );
+                                       $word = preg_replace( $regex, $replacement, $word );
 
                                        break;
                                }
@@ -70,7 +72,7 @@ class LanguageRu extends Language {
 
        /**
         * Four-digit number should be without group commas (spaces)
-        * See manual of style at http://ru.wikipedia.org/wiki/Википедия:Оформление_статей
+        * See manual of style at https://ru.wikipedia.org/wiki/Википедия:Оформление_статей
         * So "1 234 567", "12 345" but "1234"
         *
         * @param string $_