Skip to content

Commit

Permalink
Merge pull request #47 from geminorum/master
Browse files Browse the repository at this point in the history
additional Arabic & Persian chars
  • Loading branch information
jbroadway authored Sep 14, 2016
2 parents 984c991 + 12f138d commit d3e240c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A PHP port of [URLify.js](https://github.com/django/django/blob/master/django/contrib/admin/static/admin/js/urlify.js)
from the Django project. Handles symbols from Latin languages as well as Arabic, Azerbaijani, Czech, German, Greek,
Latvian, Lithuanian, Polish, Romanian, Bulgarian, Russian, Serbian, Turkish, Ukrainian and Vietnamese. Symbols it cannot
Latvian, Lithuanian, Persian, Polish, Romanian, Bulgarian, Russian, Serbian, Turkish, Ukrainian and Vietnamese. Symbols it cannot
transliterate it will simply omit.

## Usage:
Expand Down
8 changes: 7 additions & 1 deletion URLify.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,13 @@ class URLify {
'أ' => 'a', 'ب' => 'b', 'ت' => 't', 'ث' => 'th', 'ج' => 'g', 'ح' => 'h', 'خ' => 'kh', 'د' => 'd',
'ذ' => 'th', 'ر' => 'r', 'ز' => 'z', 'س' => 's', 'ش' => 'sh', 'ص' => 's', 'ض' => 'd', 'ط' => 't',
'ظ' => 'th', 'ع' => 'aa', 'غ' => 'gh', 'ف' => 'f', 'ق' => 'k', 'ك' => 'k', 'ل' => 'l', 'م' => 'm',
'ن' => 'n', 'ه' => 'h', 'و' => 'o', 'ي' => 'y'
'ن' => 'n', 'ه' => 'h', 'و' => 'o', 'ي' => 'y',
'ا' => 'a', 'إ' => 'a', 'آ' => 'a', 'ؤ' => 'o', 'ئ' => 'y', 'ء' => 'aa',
'٠' => '0', '١' => '1', '٢' => '2', '٣' => '3', '٤' => '4', '٥' => '5', '٦' => '6', '٧' => '7', '٨' => '8', '٩' => '9',
),
'fa' => array ( /* Persian */
'گ' => 'g', 'ژ' => 'j', 'پ' => 'p', 'چ' => 'ch', 'ی' => 'y', 'ک' => 'k',
'۰' => '0', '۱' => '1', '۲' => '2', '۳' => '3', '۴' => '4', '۵' => '5', '۶' => '6', '۷' => '7', '۸' => '8', '۹' => '9',
),
'sr' => array ( /* Serbian */
'ђ' => 'dj', 'ј' => 'j', 'љ' => 'lj', 'њ' => 'nj', 'ћ' => 'c', 'џ' => 'dz', 'đ' => 'dj',
Expand Down
3 changes: 2 additions & 1 deletion tests/URLifyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ function test_filter () {
$this->assertEquals ('f3pws', URLify::filter ('ΦΞΠΏΣ'));
$this->assertEquals ('', URLify::filter('大般若經'));
$this->assertEquals ('test-.txt', URLify::filter('test-大般若經.txt', 60, "", $file_name = true));
$this->assertEquals ('ykrhy-ltoytr', URLify::filter('ياكرهي لتويتر'));
$this->assertEquals ('yakrhy-ltoytr', URLify::filter('ياكرهي لتويتر'));
$this->assertEquals ('saaat-25', URLify::filter('ساعت ۲۵'));
$this->assertEquals ('foto.jpg', URLify::filter ('фото.jpg', 60, "", $file_name = true));
// priorization of language-specific maps
$this->assertEquals ('aouaou', URLify::filter ('ÄÖÜäöü',60,"tr"));
Expand Down

0 comments on commit d3e240c

Please sign in to comment.