Fix Uzbek converter
authorrobin <robinp.1273@gmail.com>
Wed, 5 Mar 2014 00:34:16 +0000 (01:34 +0100)
committerrobin <robinp.1273@gmail.com>
Wed, 5 Mar 2014 12:46:45 +0000 (13:46 +0100)
Improve the Latin to Cyrillic conversion of "e" per https://meta.wikimedia.org/w/index.php?title=User_talk:SPQRobin&oldid=7720901#Request

The code of this change is inspired on LanguageKk.php

As far as I tested, it works as intended

Change-Id: I20f293c8d1f753af7b5344543ec2ce459edcba0c

languages/classes/LanguageUz.php

index aa3e4f2..2079c5e 100644 (file)
@@ -69,9 +69,7 @@ class UzConverter extends LanguageConverter {
                'a' => 'а', 'A' => 'А',
                'b' => 'б', 'B' => 'Б',
                'd' => 'д', 'D' => 'Д',
-               'e' => 'е', 'E' => 'Е',
-               ' e' => ' э', ' E' => ' Э', // "э" is used at the beginning of a word instead of "e"
-               'ye' => 'е', 'Ye' => 'Е',
+               'e' => 'э', 'E' => 'Э', // at the beginning of a word and after a vowel, "э" is used instead of "e" (see regex below)
                'f' => 'ф', 'F' => 'Ф',
                'g' => 'г', 'G' => 'Г',
                'g‘' => 'ғ', 'G‘' => 'Ғ', 'gʻ' => 'ғ', 'Gʻ' => 'Ғ',
@@ -112,6 +110,17 @@ class UzConverter extends LanguageConverter {
                );
        }
 
+       function translate( $text, $toVariant ) {
+               if( $toVariant == 'uz-cyrl' ) {
+                       $text = str_replace( 'ye', 'е', $text );
+                       $text = str_replace( 'Ye', 'Е', $text );
+                       $text = str_replace( 'YE', 'Е', $text );
+                       $text = preg_replace( '/([BVGDJZYKLMNPRSTFXCWQʻ‘H])E/u', '$1Е', $text );
+                       $text = preg_replace( '/([bvgdjzyklmnprstfxcwqʻ‘h])e/ui', '$1е', $text );
+               }
+               return parent::translate( $text, $toVariant );
+       }
+
 }
 
 /**