PHP code example of bein-sports / openl10n-sdk

1. Go to this page and download the library: Download bein-sports/openl10n-sdk 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/ */

    

bein-sports / openl10n-sdk example snippets




penl10n\Sdk\Api;
use Openl10n\Sdk\Config;
use Openl10n\Sdk\Model\Resource;

$rootApi = new Api((new Config('openl10n.dev'))->setAuth('user', 'user'));

// Get API entry points
$projectApi = $rootApi->getEntryPoint('project');
$resourceApi = $rootApi->getEntryPoint('resource');

// Get project by its slug
$demo = $projectApi->get('demo');

// Create new resource file
$resource = new Resource($demo->getSlug());
$resource->setPathname('path/to/messages.en.yml');
$resourceApi->create($resource);

// Import some translations
$resourceApi->import($resource, 'path/to/messages.en.yml', 'en');

// Export content
$content = $resourceApi->export($resource, 'fr');
file_put_contents('path/to/messages.fr.yml', $content);