Browse Source

Add Azerbaijani transliterations (#102)

Farhad Safarov 8 years ago
parent
commit
922e56aedc

+ 16 - 0
Resources/rules/azerbaijani.json

@@ -0,0 +1,16 @@
+{
+    "Ə": "E",
+    "Ç": "C",
+    "Ğ": "G",
+    "İ": "I",
+    "Ş": "S",
+    "Ö": "O",
+    "Ü": "U",
+    "ə": "e",
+    "ç": "c",
+    "ğ": "g",
+    "ı": "i",
+    "ş": "s",
+    "ö": "o",
+    "ü": "u"
+}

+ 17 - 0
src/RuleProvider/DefaultRuleProvider.php

@@ -69,6 +69,23 @@ class DefaultRuleProvider implements RuleProviderInterface
     'ö' => 'oe',
     'ü' => 'ue',
   ),
+  'azerbaijani' => 
+  array (
+    'Ə' => 'E',
+    'Ç' => 'C',
+    'Ğ' => 'G',
+    'İ' => 'I',
+    'Ş' => 'S',
+    'Ö' => 'O',
+    'Ü' => 'U',
+    'ə' => 'e',
+    'ç' => 'c',
+    'ğ' => 'g',
+    'ı' => 'i',
+    'ş' => 's',
+    'ö' => 'o',
+    'ü' => 'u',
+  ),
   'bulgarian' => NULL,
   'burmese' => 
   array (

+ 1 - 0
src/Slugify.php

@@ -49,6 +49,7 @@ class Slugify implements SlugifyInterface
             // Languages are preferred if they appear later, list is ordered by number of
             // websites in that language
             // https://en.wikipedia.org/wiki/Languages_used_on_the_Internet#Content_languages_for_websites
+            'azerbaijani',
             'burmese',
             'hindi',
             'georgian',

+ 20 - 0
tests/SlugifyTest.php

@@ -137,6 +137,26 @@ class SlugifyTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals($expected, $this->slugify->slugify($actual));
     }
 
+    /**
+     * @test
+     * @dataProvider customRulesProvider
+     */
+    public function customRules($rule, $string, $result)
+    {
+        $slugify = new Slugify();
+        $slugify->activateRuleSet($rule);
+
+        $this->assertSame($result, $slugify->slugify($string));
+    }
+
+    public function customRulesProvider()
+    {
+        return [
+            ['azerbaijani', 'əöüğşçı', 'eougsci'],
+            ['azerbaijani', 'Fərhad Səfərov', 'ferhad-seferov']
+        ];
+    }
+
     public function defaultRuleProvider()
     {
         return [