PHP code example of erykai / translate

1. Go to this page and download the library: Download erykai/translate library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

erykai / translate example snippets


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 = '';

use Erykai\Translate\Translate;

p";

$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();

use Erykai\Translate\Translate;

p";
$translate = new Translate();


$dir = 'resources/lang/en/';
$files = array_diff(scandir($dir), array('..', '.'));

foreach ($files as $file) {
    if (pathinfo($file, PATHINFO_EXTENSION) == 'php') {
        $validationMessages =