arabic-to-persian
v1.1.0
Published
A library to convert arabic text to persian
Downloads
7
Readme
arabic-to-persian
arabic-to-persian
is a library to convert arabic text to persian.
Install
npm install arabic-to-persian
or
yarn add arabic-to-persian
Usage
In most cases you just need to import convert
function as bellow:
import { convert } from "arabic-to-persian";
const arabic = "ﻭاﮊﻩ";
const persian = "واژه";
console.log(arabic === persian); // false
console.log(convert(arabic) === persian); // true
convert
accepts another argument as options
.
In this example you can see how it's possible to set your own charMap
:
import { convert } from "arabic-to-persian";
const arabic = "﷼";
const persian = "ریال";
console.log(arabic === persian); // false
console.log(convert(arabic) === persian); // false
function customConvert(text) {
const options = { charMap: {} };
options.charMap[arabic] = persian;
return convert(text, options);
}
console.log(customConvert(arabic) === persian); // true
A better way to create yout own converter is to use createConverter
closure:
import { createConverter } from "arabic-to-persian";
const arabic = "﷼";
const persian = "ریال";
console.log(arabic === persian); // false
const options = { charMap: {} };
options.charMap[arabic] = persian;
const ar2fa = createConverter(options)
console.log(ar2fa(arabic) === persian); // true
Api
See documentation