-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
54 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,37 @@ | ||
# NumberSerbianizer: Simple class to convert numbers to Serbian Words | ||
# oblak/number-serbianisation [![Readme EN](https://img.shields.io/badge/Readme-English-red)](https://github.com/oblakstudio/number-serbianisation/blob/master/README.md) [![Readme SR](https://img.shields.io/badge/Readme-Serbian-blue)](https://github.com/oblakstudio/number-serbianisation/blob/master/README.sr.md) | ||
|
||
[![Packagist Version](https://img.shields.io/packagist/v/oblak/number-serbianisation)](https://packagist.org/packages/oblak/number-serbianisation) | ||
![Packagist Dependency Version](https://img.shields.io/packagist/dependency-v/oblak/number-serbianisation/php) | ||
[![codecov](https://codecov.io/gh/oblakstudio/number-serbianisation/graph/badge.svg?token=RoeLb6hV76)](https://codecov.io/gh/oblakstudio/number-serbianisation) | ||
[![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release) | ||
|
||
## About | ||
|
||
NumberSerbianizer is an easy-to-use class for PHP. | ||
It was made to be a class that you could quickly include into a project and have working right away. | ||
|
||
|
||
## Installation | ||
|
||
You can install the package via composer: | ||
|
||
```bash | ||
composer require oblak/number-serbianisation | ||
``` | ||
|
||
## Basic Usage | ||
## Usage | ||
|
||
``` php | ||
```php | ||
<?php | ||
|
||
require 'vendor/autoload.php'; | ||
|
||
$number = '12721438261'; | ||
use Oblak\Intl\NumberSerbianizer; | ||
use Oblak\Intl\NumberScale; | ||
|
||
require 'vendor/autoload.php'; | ||
|
||
``` | ||
$srn = new NumberSerbianizer(); | ||
|
||
### Output | ||
echo $srn->toWordString(1000); // jedna hiljada | ||
echo $srn->useAccusative()->toWordString(1000); // hiljadu | ||
|
||
``` | ||
dvanaest milijardi sedamsto dvadeset jedan milion cetristo trideset osam hiljada dvesta sezdeset jedan | ||
dvadeset tri hiljade osamsto trideset jedan | ||
echo $srn->useScale(NumberScale::Short)->toWordString(1000000000); // jedan bilion | ||
echo $srn->useScale(NumberScale::Long)->toWordString(1000000000); // jedna milijarda | ||
echo $srn->useAccusative()->toWordString(1000000000); // milijardu | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# oblak/number-serbianisation [![Readme EN](https://img.shields.io/badge/Readme-English-red)](https://github.com/oblakstudio/number-serbianisation/blob/master/README.md) [![Readme SR](https://img.shields.io/badge/Readme-Serbian-blue)](https://github.com/oblakstudio/number-serbianisation/blob/master/README.sr.md) | ||
|
||
[![Packagist Version](https://img.shields.io/packagist/v/oblak/number-serbianisation)](https://packagist.org/packages/oblak/number-serbianisation) | ||
![Packagist Dependency Version](https://img.shields.io/packagist/dependency-v/oblak/number-serbianisation/php) | ||
[![codecov](https://codecov.io/gh/oblakstudio/number-serbianisation/graph/badge.svg?token=RoeLb6hV76)](https://codecov.io/gh/oblakstudio/number-serbianisation) | ||
[![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release) | ||
|
||
Omogućava konverziju brojeva u tekst na srpskom jeziku - odnosno "posrbljavanje" brojeve. | ||
|
||
## Instalacija | ||
|
||
Biblioteku možete instalirati koristeći composer: | ||
|
||
```bash | ||
composer require oblak/number-serbianisation | ||
``` | ||
|
||
## Upotreba | ||
|
||
Biblioteka podržava dva načina skaliranja brojeva "kratki" i "dugi" (eng. short, long) kao i upotrebu "[skamenjenog akuzativa](https://www.nin.rs/arhiva/vesti/29972/skamenjeni-brojevi)" prilikom konverzije. | ||
|
||
|
||
```php | ||
<?php | ||
|
||
use Oblak\Intl\NumberSerbianizer; | ||
use Oblak\Intl\NumberScale; | ||
|
||
require 'vendor/autoload.php'; | ||
|
||
$srn = new NumberSerbianizer(); | ||
|
||
echo $srn->toWordString(1000); // jedna hiljada | ||
echo $srn->useAccusative()->toWordString(1000); // hiljadu | ||
|
||
echo $srn->useScale(NumberScale::Short)->toWordString(1000000000); // jedan bilion | ||
echo $srn->useScale(NumberScale::Long)->toWordString(1000000000); // jedna milijarda | ||
echo $srn->useAccusative()->toWordString(1000000000); // milijardu | ||
``` | ||
|