Skip to content

PrettyPersianNumbers is an Android library to convert a number to a word for Persian/Farsi using Kotlin/JVM

License

Notifications You must be signed in to change notification settings

yamin8000/PrettyPersianNumbers

Repository files navigation

PrettyPersianNumbers

All Contributors

logo

Build

Convert numbers to Persian words


- -
📺 Preview
📱 Compatibility
💻 Usage
📩 Download
📋 Features
🧾 Changelog
🏆 Credits
👨‍💻 [Contribution](#Contributors ✨)
⚖️ License

Preview

ScreenShot

Check preview on imgur

Compatibility

Android Jellybean 4.1+/SDK 16+

Usage

Kotlin You just need to create an instance from Digits class and call spellToFarsi method. input can be any number in different data types like Byte, Short, Int, Long, Float, Double, BigInteger, BigDecimal or numbers as a String.

    val word1 : String = Digits().spellToFarsi(input)
    val word2 : String = Digits().spellToFarsi(12) // دوازده
    //دوازده میلیارد و یک صد و بیست و سه میلیون و سی صد و دوازده هزار و یک صد و بیست و سه
    val word3 : String = Digits().spellToFarsi(12_123_312_123)
    //پنج میلیون و یک صد و بیست و یک هزار و سی صد و بیست و یک
    val word4 : String = Digits().spellToFarsi("5121321")
    //چهارده هزار و پانصد ریال
    val money1 : String = Digits().spellToIranMoney("14500")
    //چهارده هزار و پانصد تومان
    val money2 : String = Digits().spellToIranMoney("14500", IranCurrency.TOMAN)

Java

String persianNumber = new Digits().spellToFarsi("1231");

Download

Find latest version from Maven Artifact

Gradle Groovy DSL

Step 1. Add the Maven repository to your build file
Add it in your root build.gradle at the end of repositories:

repositories {
    mavenCentral()
}

Step 2. Add the dependency

dependencies {
    implementation 'com.github.yamin8000:PrettyPersianNumbers:1.0.3'
}

Maven

Add the dependency

<dependency>
  <groupId>com.github.yamin8000</groupId>
  <artifactId>PrettyPersianNumbers</artifactId>
  <version>1.0.3</version>
  <type>aar</type>
</dependency>  

Gradle Kotlin DSL

dependencies {
    implementation("com.github.yamin8000:PrettyPersianNumbers:1.0.3")
}

Features

  • Any number that could be fitted in BigInteger can be converted to Persian words using this library From Zero to Vigintillion or more
  • Convert numbers from Byte, Short, Int, Long, Float, Double, BigInteger, BigDecimal
  • Convert numbers straight to currency like: چهارده هزار و پانصد تومان see Usage
  • Large numbers are named using short-scale standard
  • Negative numbers are supported

Changelog

  • 1.0.3 add support for decimal numbers
  • 1.0.2 bug fixes
  • 1.0.1 bug fixes, added support for big numbers
  • 1.0.0 initial version

Credits

https://github.com/yaghoob

License

Pretty Persian Numbers is licensed under the GNU General
Public License v3.0

Permissions of this strong copyleft license are conditioned on making
available complete source code of licensed works and modifications,
which include larger works using a licensed work, under the same
license. Copyright and license notices must be preserved. Contributors
provide an express grant of patent rights.

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Yaghoob Siahmargooei

🐛 💻

YaMiN

💻

This project follows the all-contributors specification. Contributions of any kind welcome!