atpro / translator
Atpro translator allows you to translate lang files into several languages and thus save time in managing the internationalization of your laravel projects
Requires
- stichoza/google-translate-php: ^4.1.0
Requires (Dev)
- phpunit/phpunit: ^9.5
README
Introduction
Atpro-translator is a package that allows you to easily manage the internationalization in your applications.
Installation
To get started with Atpro-translator, use Composer to add the package to your project's dependencies:
composer require atpro/translator
Configuration
After installing the Atpro-translator
library, register the \Atpro\Translator\AtproServiceProvider::class
in your config/app.php
configuration file:
'providers' => [ \Atpro\Translator\AtproServiceProvider::class, ],
Also, register the middleware in web middleware groups by simply adding the middleware class :
AtproTranslateMiddleware::class,
into the $middlewareGroups
of your app/Http/Kernel.php
file.
And then run :
php artisan vendor:publish
publish AtproServiceProvider
.
Usage
To translate your lang files into other languages:
Run the command in terminal
php artisan atpro:translate
Example:
- php artisan atpro:translate and click enter
- --> Your started language ?
en
- --> Your translated list language seperated with commas (,) example: fr,es ... ?
fr,it,es
- Click enter and wait for translated files
It will generate translated files in respective folder fr,it,es
OPTIONAL OPTIONS:
B. To generate views for translation:
Run the command in terminal
php artisan atpro:generate-view-translate
Example:
- php artisan atpro:generate-view-translate and click enter
- --> Yours languages seperated with commas (,) example: fr,es ... ?
fr,it,es
- Click enter and wait for generate views translate
It will generate a middleware, in controller, a routes file and a component containing the different options according to the chosen languages
You will also have a new component <x-atpro::language> </x-atpro::language>
. You can use it in views.
Note: Make sure that the started language folder exists in your language folder and contains files you want to translate.