Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/H-MAli/persian-localizations
A Python package to facilitate Persian language localizations
https://github.com/H-MAli/persian-localizations
Last synced: 3 months ago
JSON representation
A Python package to facilitate Persian language localizations
- Host: GitHub
- URL: https://github.com/H-MAli/persian-localizations
- Owner: H-MAli
- License: apache-2.0
- Created: 2023-01-02T17:47:26.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-30T08:01:21.000Z (about 1 year ago)
- Last Synced: 2024-07-26T15:55:08.953Z (4 months ago)
- Language: Python
- Size: 17.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# persian-localizations
A Python package to facilitate Persian language localizations.## Install
```
pip install persian-localizations
```## Usage
Here are a list of functions available to you through `persian-localizations`:- `latin_to_persian(latin, decimal_point=False, question_mark=False)`: Lets you convert some latin characters to their Persian counterparts:
```python
# required imports
from persian_localizations import latin_to_persian# Turn any occurrence of a lating digit character to its Persian equivalent
latin_to_persian('من 69 سال دارم!') # Returns 'من ۶۹ سال دارم!'# The same function can handle decimal marks as well, if directed to do so
latin_to_persian('69.420، همینجوری!', decimal_point=True) # Returns '۶۸٫۴۲۰، همینجوری!'# You can also change latin (LTR) question marks to Persian (RTL)
latin_to_persian('چی شد?', question_mark=True) # Returns 'چی شد؟'
```
- `persian_numerals(num)`: Lets you convert an `int` value to its Persian counterpart:
```python
# required imports
from persian_localizations import persian_numerals# Turn 123 to Persian-script string
persian_numerals(123) # Returns '۱۲۳'
```
- `cleanup_arabic_characters(problematic)`: Lets you clean-up a Persian `str` value containing some unintended Arabic characters:
```python
# required imports
from persian_localizations import cleanup_arabic_characters# Changes Arabic letter ي (non-existent in Persian) to ی
cleanup_arabic_characters('ميروم') # Returns 'میروم'
```
- `persian_numeral_string(num)`: Converts an `int` value to its written-out form in Persian:
```python
# required imports
from persian_localizations import persian_numeral_stringpersian_numeral_string(1234) # Returns 'هزار و دویست و سی و چهار'
```
- `persian_ordinal_string(num)`: Converts an `int` value to its written-out form in Persian in ordinal form (اول, دوم, etc.):
```python
# required imports
from persian_localizations import persian_ordinal_stringpersian_ordinal_string(25) # Returns 'بیست و پنجم'
```
- `persian_counting_ordinal_string(num)`: Converts an `int` value to its written-out form in Persian in counting ordinal form (اولین, دومین, etc.):
```python
# required imports
from persian_localizations import persian_counting_ordinal_stringpersian_counting_ordinal_string(1121) # Returns 'یک هزار و صد و بیست و یکمین'
```## Contributing
Your Pull Request submissions are welcome!
## License
Apache License © Mohammad Ali Haghshenas
See [LICENSE](./LICENSE) for more.