Coder Social home page Coder Social logo

angular-persian's Introduction

#Build Status Dependency Status License

AngularPersian is a simple Angular.js module which provides a set of useful Angular Filters for Persian localization.

AngluarPersian uses usablica/persian.js. It also has an additional pDigitWords method which represents numbers as words.

Installation

You can install this package using bower.

bower install angular-persian

Refer all dependencies in your page in right order.

<script src="bower_components/persianjs/persian.js"></script>
<script src="bower_components/angular-persian/dist/angularpersian.js"></script>

Also you can get the package using npm.

Usage

To use this package add ngPersian as a dependency to your app module, then you can easily use the tools provided in the package.

var app = angular.module('myApp', ['ngPersian', /* Other deps ... */]);

Convert Numbers to Persian Digits

You can use pNumber filter to convert the digits to persian form :

{{ product.price | pNumber }}
<!-- e.g. Raw value: 36590, Output: ۳۶۵۹۰ -->

You can mix this filter with currency and number filters :

{{ product.price | currency | pNumber }}
{{ product.quantity | number | pNumber }}

Convert Numbers to Persian Words

You can use pDigitWords filter to convert numbers to persian words.

{{ product.price | pDigitWords }} ریال
<!-- e.g. سیصد و پنجاه هزار ریال -->

Switch Keyboard layout

You can use pSwitchKey filter to switch keyboard layouts.

{{ "لخخلمث" | pSwitchKey }}
<!-- output: google -->

Fix Persian Characters in URLs

{{ 'https://fa.wikipedia.org/wiki/%D8%B5%D9%81%D8%AD%D9%87%D9%94_%D8%A7%D8%B5%D9%84%DB%8C' | pFixURL }}
<!-- https://fa.wikipedia.org/wiki/صفحهٔ_اصلی -->

Convert Arabic characters to Persian characters

You can use pArabicNumber to fix arabic number characters and pArabicChar to fix arabic characters to persian equivalents.

{{ "علي٤2465" | pArabicNumber | pArabicChar | pNumber }}
<!-- output: علی۴۲۴۶۵ -->

angular-persian's People

Contributors

ahmadina avatar mohebifar avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.