Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/evandhq/react-persian
A set of react components for Persian localization.
https://github.com/evandhq/react-persian
Last synced: 22 days ago
JSON representation
A set of react components for Persian localization.
- Host: GitHub
- URL: https://github.com/evandhq/react-persian
- Owner: evandhq
- License: mit
- Created: 2015-09-29T13:59:59.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-12-08T01:45:05.000Z (about 7 years ago)
- Last Synced: 2024-12-01T04:41:33.685Z (28 days ago)
- Language: JavaScript
- Homepage:
- Size: 36.1 KB
- Stars: 82
- Watchers: 4
- Forks: 11
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# react-persian
**react-persian** is a set of react components for Persian localization.# Installation
You can install this package via `npm`:
```bash
npm install react-persian --save
```# Components
## PersianNumber
You can use `PersianNumber` component to convert the digits to Persian form:```jsx
import React from 'react';
import { PersianNumber } from 'react-persian';class Test extends React.Component {
render() {
return ();
سال تولد: 1372
}
}
```### Properties
* **latin** (default: *true*): Enable converting Latin numbers to Persian numbers
* **arabic** (default: *false*): Enable converting Arabic numbers to Persian numbers
* **format** (default: *false*): Enable comma separate number every 3 digit
* **removeCommas** (default: *false*): Enable removing every comma from number/string## PersianNumberWords
You
```jsx
import React from 'react';
import { PersianNumberWords } from 'react-persian';class Test extends React.Component {
render() {
return ();
قیمت: 5600
}
}
```
# functions
### latinToPersian
You can use `latinToPersian` function to convert the digits to Persian:
```jsx
import { latinToPersian } from 'react-persian';class Test extends React.Component {
render() {
return ( console.log(latingToPersian('44'))}>show 44 in persian)
}
}
```
### arabicToPersian
You can use `arabicToPersian` function to convert the Arabic digits to Persian:
```jsx
import { arabicToPersian } from 'react-persian';class Test extends React.Component {
render() {
return ( console.log(arabicToPersian('٤٥'))}>show ٤٥ in persian)
}
}
```
### formatString
You can use `formatString` function to add commas every 3 characters fron right:
```jsx
import { formatString } from 'react-persian';class Test extends React.Component {
render() {
return ( console.log(formatString('۲۵۰۰۰۰۰۰۰'))}> is equal to ۲۵۰,۰۰۰,۰۰۰)
}
}
```
### removeCommasFromString
You can use `formatString` function to remove any commas from string:
```jsx
import { removeCommasFromString } from 'react-persian';class Test extends React.Component {
render() {
return ( console.log(removeCommasFromString('۲۵۰,۰۰۰,۰۰۰'))}> is equal to ۲۵۰۰۰۰۰۰۰ (without commas))
}
}
```