Git Product home page Git Product logo

muath-ye / laravel-speaks-arabic Goto Github PK

View Code? Open in Web Editor NEW

This project forked from adnane-ka/laravel-speaks-arabic

2.0 1.0 0.0 24 KB

"Laravel Speaks Arabic" is a light weight ,open-source laravel package . It facilitates dealing with arabic concepts in Laravel Framework using a set of Classess and methods to make laravel speaks arabic! concepts like , Hijri Dates & Arabic strings and so on

PHP 100.00%

laravel-speaks-arabic's Introduction

Laravel Speaks Arabic

"Laravel Speaks Arabic" is a light weight ,open-source laravel package . It facilitates dealing with arabic concepts in Laravel Framework using a set of classes and methods to make laravel speaks arabic! concepts like , Hijri Dates & Arabic strings and so on ..

code example

use Adnane\Arabic\Arabic;

echo Arabic::tafkit(12078437); // اثنا عشر مليون و ثمان و سبعون ألف و أربع مئة و سبع و ثلاثون
// or
echo arabic()->tafkit(12078437); // اثنا عشر مليون و ثمان و سبعون ألف و أربع مئة و سبع و ثلاثون

installation

1.install via composer

composer require adnane/laravel-speaks-arabic

2.in your config\app.php add the service provider in providers array

'providers' => [ 
    Adnane\Arabic\ArabicServiceProvider::class,
]

3.as you can define an alias in config\app.php in the aliases array

'Arabic' => Adnane\Arabic\Arabic::class,

use in blade files

make sure you define an alias first

change method to needed method like Arabic::tafkit(643646) or arabic()->tafkit(643646)

{{ Arabic::method($input) }}

or

{{ arabic()->method($input) }}

Methods & How to use

import the class as bellow

use Adnane\Arabic\Arabic;

or just use the alias you just defined

use Arabic;

1.Working with numbers & integers

/* 
| convert numeric numbers to spelled strings 
| @params : $integer (int) required | max : 999999999999999
|
| example of output :خمس عشر مليون و مئتان و أحدا عشر ألف و ثمان مئة و اثنان و تسعون
*/
Arabic::tafkit($integer)
// or by using helper method
arabic()->tafkit($integer)


/* 
| convert numeric numbers to ordered declares
| @params : $integer (int) required | max : 999999999999999
|
| example of output : الثالث و العشرون
*/
Arabic::tartib($integer)
// or by using helper method
arabic()->tartib($integer)

/* 
| rewrite numbers in a containing string to be like ۱٧۳۱۸
| @params : $str (string) required
| 
| example of output : ولد عليه الصلاة والسلام في ۱۲ ربيع الاول من عام ٦۲۲ ميلادية
*/
Arabic::arkam($longText) 
// or by using helper method
arabic()->arkam($longText) 

2.Working with dates & times

/* 
| convert a given date to hijri takwim date 
| format : f , s , n 
| @params : $format (string) , $date (Y/m/d) 
|
| example of output : الحادي عشر من شعبان من السنة الهجرية ألف و أربع مئة و اثنان و أربعون
*/
Arabic::hijri($format = 'f' ,$date = null)
// or by using helper method
arabic()->hijri($format = 'f' ,$date = null)

/* 
| Get the relative time between two given dates 
| @params : $date (Y/m/d) required , $date2 (Y/m/d) , $detailed (boolean) 
| 
| example of output : منذ ثلاث أشهر 
| example of output2 : مئة و أحدا عشر سنة 
*/
Arabic::fariq($date ,$date2 = null ,$detailed = false)
// or by using helper method
arabic()->fariq($date ,$date2 = null ,$detailed = false)

3.Working with Strings & longTexts

/* 
| get rid of The vowel diacritics in Arabic  
| @params : $str (string) required [ string to clean ]
| example :
| [input] : أَحَبُّ النَّاسِ إِلَى اللَّهِ أَنْفَعَهُمْ لِلنَّاسِ، وَأَحَبُّ الْأَعْمَالِ إِلَى اللَّهِ سُرُورٍ تُدْخِلُهُ عَلَى مُسْلِمٍ،
| output : أحب الناس إلى الله أنفعهم للناس، وأحب الأعمال إلى الله سرور تدخله على مسلم 
*/
Arabic::removeHarakat($longText)
// or by using helper method
arabic()->removeHarakat($longText)

/* 
| rewrite strings and texts to match the keyboard reveresed in english 
| this method can be really helpful when it comes to making search procces better 
| @params : $str (string) required [ string to reverse ]
| 
| example :
| [input] : sg,h hggi uglh khtuh ,,ju,`,h fhggi lk ugl gh dktu
| [output] : سلوا الله علما نافعا ووتعوذوا بالله من علم لا ينفع
*/
Arabic::toKeyboardInput($longText)
// or by using helper method
arabic()->toKeyboardInput($longText)

/* 
| rewrite strings and texts to be written and spelled in english letters 
| this mehotd can be really helpful when it comes to making seo friendly url's or arabic slugs 
| @params : $str (string) required [ string to write in spelled form ]
| 
| [input] : إِذَا مَاتَ الإنْسَانُ انْقَطَعَ عنْه عَمَلُهُ إِلَّا مِن ثَلَاثَةٍ: إِلَّا مِن صَدَقَةٍ جَارِيَةٍ، أَوْ عِلْمٍ يُنْتَفَعُ بِهِ، أَوْ وَلَدٍ صَالِحٍ يَدْعُو له
| [output] : izaa maat ālinsaan ānqta anh amlh ilaa mn thlaatht: ilaa mn sdqt jaariit، āoo alm yntfa bh، āoo wld saalh ydaoo lh
*/
Arabic::toSpelled($longText)
// or by using helper method
arabic()->toSpelled($longText)

This package is still under development ,as it was recently created, please feel free to contribute or help us making laravel speaks arabic better by opening a discuss , fixing a bug or helping in improving some methods!

it's highly recommended you follow the written code manner

  1. Create new PHP class in /Ar/
  2. You may need to add some data in /Ar/data/YourFolder/
  3. Import your class in Arabic.php & define your methods !That's it!

laravel-speaks-arabic's People

Contributors

adnane-ka avatar muath-ye avatar

Stargazers

راضي الزهيري(Radi-Zuhahiri) avatar As3ad Altabali avatar

Watchers

James Cloos 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.