Skip to content

Commit

Permalink
Installation section, formatting fixes, travis-ci build status
Browse files Browse the repository at this point in the history
  • Loading branch information
jbroadway authored Dec 8, 2018
1 parent 708f14e commit 3887f73
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
# URLify for PHP
# URLify for PHP [![Build Status](https://travis-ci.org/jbroadway/urlify.png)](https://travis-ci.org/jbroadway/urlify)

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, Kazakh,
Latvian, Lithuanian, Persian, Polish, Romanian, Bulgarian, Russian, Serbian, Turkish, Ukrainian, Vietnamese and Slovak. Symbols it cannot
transliterate it will simply omit.

## Usage:
## Installation

Install the latest version with:

```bash
$ composer require jbroadway/urlify
```

## Usage

To generate slugs for URLs:

Expand All @@ -17,8 +25,6 @@ echo URLify::filter (' J\'étudie le français ');

echo URLify::filter ('Lo siento, no hablo español.');
// "lo-siento-no-hablo-espanol"

?>
```

To generate slugs for file names:
Expand All @@ -28,11 +34,8 @@ To generate slugs for file names:

echo URLify::filter ('фото.jpg', 60, "", true);
// "foto.jpg"

?>
```


To simply transliterate characters:

```php
Expand All @@ -48,8 +51,6 @@ echo URLify::downcode ('Lo siento, no hablo español.');

echo URLify::transliterate ('Lo siento, no hablo español.');
// "Lo siento, no hablo espanol."

?>
```

To extend the character list:
Expand All @@ -64,8 +65,6 @@ URLify::add_chars (array (

echo URLify::downcode ('¿ ® ¼ ¼ ¾ ¶');
// "? (r) 1/2 1/2 3/4 P"

?>
```

To extend the list of words to remove:
Expand All @@ -74,21 +73,18 @@ To extend the list of words to remove:
<?php

URLify::remove_words (array ('remove', 'these', 'too'));

?>
```

To prioritize a certain language map:

```php
<?php

echo URLify::filter (' Ägypten und Österreich besitzen wie üblich ein Übermaß an ähnlich öligen Attachés ',60,"de");
echo URLify::filter ('Ägypten und Österreich besitzen wie üblich ein Übermaß an ähnlich öligen Attachés', 60, 'de');
// "aegypten-und-oesterreich-besitzen-wie-ueblich-ein-uebermass-aehnlich-oeligen-attaches"

echo URLify::filter ('Cağaloğlu, çalıştığı, müjde, lazım, mahkûm',60,"tr");
echo URLify::filter ('Cağaloğlu, çalıştığı, müjde, lazım, mahkûm', 60, 'tr');
// "cagaloglu-calistigi-mujde-lazim-mahkum"

?>
```

Please note that the "ü" is transliterated to "ue" in the first case, whereas it results in a simple "u" in the latter.

0 comments on commit 3887f73

Please sign in to comment.