Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
turanjanin committed Mar 30, 2021
0 parents commit d3c28e7
Show file tree
Hide file tree
Showing 10 changed files with 1,104 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
charset = utf-8
indent_size = 4
indent_style = space
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/phpunit.xml.dist export-ignore
/tests export-ignore
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.idea/
vendor/
build/
composer.lock
phpunit.xml
.phpunit.result.cache
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) Jovan Turanjanin

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Serbian Transliterator - PHP library

This library converts text between Serbian Latin and Cyrillic scripts.

It comes with an extensive list of exceptions in order to properly handle digraphs when transliterating
from Latin to Cyrillic (*injekcija* becomes *инјекција* instead of *ињекција*).

Additionally, the most common foreign words will be detected and left in their original form (*Facebook* won't be transliterated to *Фацебоок*).


## Installation

You can install the package via composer:

```bash
composer require turanjanin/serbian-transliterator
```

## Usage

```php
use Turanjanin\SerbianTransliterator\Transliterator;


echo Transliterator::toLatin('Брза вижљаста лија хоће да ђипи преко лењог флегматичног џукца.');
// Brza vižljasta lija hoće da đipi preko lenjog flegmatičnog džukca.

echo Transliterator::toAsciiLatin('Fijuče vetar u šiblju, ledi pasaže i kuće iza njih i gunđa u odžacima.');
// Fijuce vetar u siblju, ledi pasaze i kuce iza njih i gundja u odzacima.

echo Transliterator::toCyrillic('Odjednom Tanjug reče da će nadživeti injekciju. Dodjavola, džangrizava njuška je bila u pravu.');
// Одједном Танјуг рече да ће надживети инјекцију. Дођавола, џангризава њушка је била у праву.
```


## Author

- [Jovan Turanjanin](https://github.com/turanjanin)

The list of exceptions for transliteration is taken from [turanjanin/cirilizator](https://github.com/turanjanin/cirilizator) project.

## License

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
33 changes: 33 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "turanjanin/serbian-transliterator",
"description": "Transliterate between Serbian Cyrillic and Latin scripts.",
"keywords": ["serbian", "transliteration", "cyrillic", "latin", "latinisation"],
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Jovan Turanjanin",
"email": "[email protected]",
"homepage": "https://www.turanjanin.net"
}
],
"require": {
"php": "^7.2|^8.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5"
},
"autoload": {
"psr-4": {
"Turanjanin\\SerbianTransliterator\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Turanjanin\\SerbianTransliterator\\Tests\\": "tests/"
}
},
"config": {
"sort-packages": true
}
}
28 changes: 28 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
verbose="true"
>
<testsuites>
<testsuite name="All Tests">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
</phpunit>
Loading

0 comments on commit d3c28e7

Please sign in to comment.