erykai/translate

Component for all language translation, system messages and routes, and translation for laravel resources/lang/en

Fund package maintenance!
Erykai

v3.0.1 2023-10-12 09:25 UTC

This package is auto-updated.

Last update: 2024-12-12 12:29:03 UTC


README

Maintainer Source Code PHP from Packagist Latest Version Software License Quality Score Total Downloads

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

License

The MIT License (MIT). Please see License for more information.