erykai / translate
Component for all language translation, system messages and routes, and translation for laravel resources/lang/en
Fund package maintenance!
Erykai
Requires
- php: >=8.0
- ext-curl: *
README
Component for all language translation, system messages and routes, and resources lang laravel
Installation
Composer:
"erykai/translate": "3.0.*"
Terminal
composer require erykai/translate
Create config.php para erykia
const TRANSLATE_PATH = 'translate'; //Laravel 'php'; const TRANSLATE_DEFAULT = 'en'; //example: pt_BR, es ... const TRANSLATE_API_URL = 'https://translate.erykia.com/api/v1'; const TRANSLATE_EXT = 'translate'; // Laravel 'translate/resources/lang'; const TRANSLATE_API_KEY = '';
Translate define language ->target("es") ou ->target() default "en"
use Erykai\Translate\Translate; require_once "config.php"; require_once "vendor/autoload.php"; $translate = new Translate(); $data = new stdClass(); $data->file = "route"; $data->text = "/send/{id}/{slug}"; // $data->text = "Hello"; if remove line 12 $data->dynamic = "/{id}/{slug}"; // off dynamic remove line string|array ['{id}','{slug}'] $translate->data($data)->target("es")->response();
Example translate resources lang laravel Copy the resources/lang/en/*.php folder with all files to the root, then just run php index.php
use Erykai\Translate\Translate; require_once "config.php"; require_once "vendor/autoload.php"; $translate = new Translate(); $dir = 'resources/lang/en/'; $files = array_diff(scandir($dir), array('..', '.')); foreach ($files as $file) { if (pathinfo($file, PATHINFO_EXTENSION) == 'php') { $validationMessages = include $dir . $file; $filenameWithoutExtension = pathinfo($file, PATHINFO_FILENAME); $translate->processMessages($validationMessages, $translate, $filenameWithoutExtension,target:"pt_BR"); } }
Contribution
All contributions will be analyzed, if you make more than one change, make the commit one by one.
Support
If you find faults send an email reporting to webav.com.br@gmail.com.
Credits
- Alex de O. Vidal (Developer)
- All contributions (Contributors)
License
The MIT License (MIT). Please see License for more information.