Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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))
}
}
```