laravel Translatable
This package to make translate easly in laravel and to save your translate words in datatabse with many usefull functions., (*1)
Install
Via Composer, (*2)
``` bash
$ composer require Aktaa/laravel-translate, (*3)
## Usage
You shoud publish provider to use package without errors.
``` bash
$ php artisan vendor:publish --provider=Aktaa\translatable\TranslatableServiceProvider
After that use this command ti initialize package's files (Model,Provider,viewComposer,helper file,translate table migration), (*4)
``` bash
$ php artisan make:translate-init --langs=en,ar, (*5)
The name of Model will be Translate by default if you want to change it you just write this command istead of the above,
and you want to deploy it in another directory you just add option ``` bash --dir=folder ```.
``` bash
$ php artisan make:translate-init Example --langs=en,ar --dir=Models
The file generated is:, (*6)
App\Helper\Helpers.php,, (*7)
App\Models\Translate.php,, (*8)
App\Providers\ComposerServiceProvider.php,, (*9)
database\migrations\2018_05_09_124224_create_translates_table.php,, (*10)
resources\lang{lang}\words.php,, (*11)
The words file is if you want to use php helper function trans('words.example')
., (*12)
you should put in app.config
file., (*13)
App\Providers\ComposerServiceProvider::class
and, (*14)
Aktaa\translatable\TranslatableServiceProvide::class
Facade:, (*15)
'Translatable' => Aktaa\translatable\Facades\Translatable::class,
```
The helper function is
``` php
translate($word,$lang,$default);
ex:translate('hello_word',Translatable::getCurrentLocale(),'Hello World!);
$default
the word appear if the word you entered doesn't exist., (*16)
After all of this you will be able to use it
go to this url:
php
http://localhost/your-project-name/public/{lang}/translates
, (*17)
, (*18)
, (*19)
, (*20)