Skip to content

AlirezaIvaz/NumbersToLetters

Repository files navigation

Persian Numbers to Letter Converter

Apache2 API 14 Kotlin 1.8.0 Issues

This simple library converts numbers to Persian letters.

Demo

You can download the demo application from releases page or markets:

Get it on Bazaar Get it on Myket

Adding to your project

1. Adding the library repository

If you're using the old project structure, add JitPack in your root build.gradle or build.gradle.kts file like this:

build.gradle
allprojects {
    repositories {
        ...
        maven {
            url 'https://jitpack.io'
        }
    }
}
build.gradle.kts
allprojects {
    repositories {
        ...
        maven("https://jitpack.io")
    }
}

Otherwise if you're using new project structure, add JitPack in your settings.gradle or settings.gradle.kts like this:

settings.gradle
dependencyResolutionManagement {
    ...
    repositories {
        ...
        maven {
            url 'https://jitpack.io'
        }
    }
}
settings.gradle.kts
dependencyResolutionManagement {
    ...
    repositories {
        ...
        maven("https://jitpack.io")
    }
}

2. Adding the library dependency

Gradle Version Catalog

First add dependency in your project version catalog like this:

libs.versions.toml
[version]
numberstoletters = "2.0.1" # You can find the latest version from releases page

[libraries]
numberstoletters = { group = "ir.alirezaivaz", name = "numberstoletters", version.ref = "numberstoletters" }

Then add the library dependency in your application module build.gradle or build.gradle.kts file like this:

build.gradle
dependencies {
    ...
    implementation libs.numberstoletters
}
build.gradle.kts
dependencies {
    ...
    implementation(libs.numberstoletters)
}

Legacy

Just add the library dependency in your application module build.gradle or build.gradle.kts file like this:

build.gradle
dependencies {
    ...
    def numbersToLetters = "2.0.1" // You can find the latest version from releases page
    implementation "ir.alirezaivaz:numberstoletters:$numbersToLetters"
}
build.gradle.kts
dependencies {
    ...
    val numbersToLetters = "2.0.1" // You can find the latest version from releases page
    implementation("ir.alirezaivaz:numberstoletters:$numbersToLetters")
}

Usage

Simply create an object from PersianNumbersToLettersConverter class and call getParsedString() function and pass your number as string to that function.

Java
PersianNumbersToLettersConverter converter = new PersianNumbersToLettersConverter();
Int number = 123456789;
String inputNumber = Integer.toString(number);
String result = converter.getParsedString(inputNumber);
Kotlin
val converter = PersianNumbersToLettersConverter()
val number = 123456789
val result = converter.getParsedString("$number")

Notes

This library supports 63 numbers. If you try to enter more than, the library returns error!

Author

Library by Alireza Ivaz

Thanks

Changelog

You can see full changelog from here.

License

Copyright 2016-2020 Saeid Raei
Copyright 2017-2023 Alireza Ivaz

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.