{"id":17350535,"url":"https://github.com/iranian-github/python-num2fa","last_synced_at":"2025-04-14T21:14:06.828Z","repository":{"id":214761705,"uuid":"737299040","full_name":"iranian-github/python-num2fa","owner":"iranian-github","description":"A Python library to convert numbers into Persian numbers or words.","archived":false,"fork":false,"pushed_at":"2025-03-02T05:44:05.000Z","size":30,"stargazers_count":10,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-14T21:13:57.731Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iranian-github.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"docs/Contributing.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-30T14:28:57.000Z","updated_at":"2025-03-02T05:44:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"95906a21-d308-444e-bb96-e0f7e162f647","html_url":"https://github.com/iranian-github/python-num2fa","commit_stats":null,"previous_names":["codewithemad/num2fa"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iranian-github%2Fpython-num2fa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iranian-github%2Fpython-num2fa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iranian-github%2Fpython-num2fa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iranian-github%2Fpython-num2fa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iranian-github","download_url":"https://codeload.github.com/iranian-github/python-num2fa/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248961237,"owners_count":21189993,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T17:07:19.633Z","updated_at":"2025-04-14T21:14:06.803Z","avatar_url":"https://github.com/iranian-github.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Num2Fa\n\n[![PyPI releases](https://img.shields.io/pypi/v/num2fa?logo=python\u0026logoColor=white)](https://pypi.python.org/pypi/num2fa)\n[![PyPI Downloads](https://static.pepy.tech/badge/num2fa)](https://pepy.tech/projects/num2fa)\n[![MIT License](https://img.shields.io/github/license/codewithemad/num2fa.svg?style=flat-square)](https://opensource.org/license/agpl-v3/)\n\n`num2fa` is a versatile solution that enables the conversion of numbers (integers, floats, decimals, fractions, or strings) into their corresponding number or word form in Persian.\n\nThis repo is built upon the foundation of [num2faword](https://github.com/5j9/num2fawords), and I would like to express my gratitude to the [original developer](https://github.com/5j9) for their contributions.\n\n## Installation\n\n```bash\npip install num2fa\n```\n\nThat's it!\n\n## Usage\n\nYou can use `numbers`, `words`, and `ordinal_words` to convert numbers to their respective Persian forms, whether that be in numeric, word, or ordinal form.\n\n```python\n\u003e\u003e\u003e from num2fa import numbers, words, ordinal_words\n\u003e\u003e\u003e numbers(1984)\n'۱۹۸۴'\n\u003e\u003e\u003e numbers('1984')\n'۱۹۸۴'\n\u003e\u003e\u003e numbers('1.1e-4')\n\u003e\u003e\u003e words(1984)\n'یک هزار و نهصد و هشتاد و چهار'\n\u003e\u003e\u003e ordinal_words(1232)\n'یک هزار و دویست و سی و دوم'\n\u003e\u003e\u003e ordinal_words(123)\n'یکصد و بیست و سوم'\n\u003e\u003e\u003e words(1.1e-9)\n'یک و یک دهم در ده به توان منفی نه'\n```\n\n`numbers` and `words` also accepts other common standard types:\n\n```python\n\n\u003e\u003e\u003e from decimal import Decimal\n\u003e\u003e\u003e from fractions import Fraction\n\n\u003e\u003e\u003e numbers(Decimal('1.1'))\n'۱٫۱'\n\u003e\u003e\u003e numbers(Fraction(-2, 5))\n'-۲/۵'\n\u003e\u003e\u003e words(Decimal('1.1'))\n'یک و یک دهم'\n\u003e\u003e\u003e words(Fraction(-2, 5))\n'منفی دو پنجم'\n\u003e\u003e\u003e ordinal_words(123)\n'یکصد و بیست و سوم'\n```\n\n## Customization\n\nThe default decimal separator for `numbers` is `٫` and for `words` is `و`. it can be changed to any other strings with `decimal_separator`:\n\n```python\n\u003e\u003e\u003e numbers(19.75, decimal_separator='/')\n'۱۹/۷۵'\n\u003e\u003e\u003e words(19.75, decimal_separator=' ممیز ')\n'نوزده ممیز هفتاد و پنج صدم'\n```\n\nIf you wanted to use different number characters for example `٦` instead of `۶`, you can just:\n\n```python\nfrom num2fa.constants import PERSIAN_DIGITS\n\nPERSIAN_DIGITS.update({'6': '٦'})\nnumbers(19.66, decimal_separator='/')\n'۱۹/٦٦'\n```\n\nSome people prefer, for example, \"صد و هفتاد\" over its other form \"یکصد و هفتاد\". This package uses the second form by default which is also used on official Iranian banknotes. But it can be changed:\n\n```python\n\u003e\u003e\u003e from num2fa.constants import HUNDREDS\n\u003e\u003e\u003e words(170)\n'یکصد و هفتاد'\n\u003e\u003e\u003e HUNDREDS[1] = 'صد'\n\u003e\u003e\u003e words(170)\n'صد و هفتاد'\n```\n\nother customizations in `words`:\n\n```python\n\u003e\u003e\u003e words(7, positive='مثبت ')\n'مثبت هفت'\n\u003e\u003e\u003e words(-2, negative='منهای ')\n'منهای دو'\n\u003e\u003e\u003e words('۱/۲')\n'یک دوم'\n\u003e\u003e\u003e words('1/2', fraction_separator=' تقسیم بر ', ordinal_denominator=False)\n'یک تقسیم بر دو'\n\u003e\u003e\u003e words(1.1e-9)\n'یک و یک دهم در ده به توان منفی نه'\n\u003e\u003e\u003e words(1.1e-9, scientific_separator=' ضربدر ده به قوهٔ ')\n'یک و یک دهم ضربدر ده به قوهٔ منفی نه'\n```\n\n`positive`, `negative`, `decimal_separator`, `fraction_separator` can be used in `numbers` too.\n\nAll above arguments can be used together. If you prefer to change the default argument values once and for all, use the `change_defaults_numbers` or `change_defaults_words` function:\n\n```python\n\u003e\u003e\u003e from num2fa import change_numbers_defaults, change_words_defaults\n\n\u003e\u003e\u003e change_numbers_defaults(fraction_separator=' بر ', decimal_separator='.')\n\u003e\u003e\u003e numbers('1.89/23')\n\u003e\u003e\u003e '۱.۸۹ بر ۲۳'\n\n\u003e\u003e\u003e change_words_defaults(fraction_separator=' بخش بر ', ordinal_denominator=False)\n\u003e\u003e\u003e words('۱/۴')\n'یک بخش بر چهار'\n```\n\n## Contributing\n\nWe welcome contributions! To learn how you can contribute, please check the [Contributing](https://github.com/codewithemad/num2fa/blob/master/docs/Contributing.md) document.\n\n## License\n\nThis work is licensed under the terms of the [GNU Affero General Public License (AGPL)](https://github.com/codewithemad/num2fa/blob/master/LICENSE.txt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Firanian-github%2Fpython-num2fa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Firanian-github%2Fpython-num2fa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Firanian-github%2Fpython-num2fa/lists"}