PHP code example of pervozdanniy / translation-storage

1. Go to this page and download the library: Download pervozdanniy/translation-storage 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/ */

    

pervozdanniy / translation-storage example snippets




class ApiAdapter implements \Translate\StorageManager\Contracts\Api
{
    // MUST return data compatible with storage's data structure
    public function fetch(array $params = [], int $page = 1) : array
    {
        // TODO: Implement fetch() method.
        return [];
    }
}

/** @var \Translate\StorageManager\Contracts\Api $api */
$api = new ApiAdapter();

$builder = \Elasticsearch\ClientBuilder::create();
// set all options for elastic client you need
$elastic = $builder->build();
$storage = new \Translate\StorageManager\Storage\ElasticStorage($elastic);
// you can pass any storage you want that implements \Translate\StorageManager\Contracts\TranslationStorage interface
$manager = new \Translate\StorageManager\Manager($api, $storage);
$manager->update(['en', 'es', 'ru']);

/** @var \Translate\StorageManager\Manager $manager*/
//update all translation groups for specified languages
$manager->update(['en', 'es', 'ru']);

//update specified group
$manager->updateGroup('app', ['en', 'es', 'ru']);

bash
# Install Composer
curl -sS https://getcomposer.org/installer | php