bein-sports/openl10n-sdk

openl10n 的 API 客户端

v0.1.0 2014-09-12 20:28 UTC

This package is not auto-updated.

Last update: 2024-10-02 08:44:07 UTC


README

Openl10n SDK 是一个用于 openl10n API 的 PHP 客户端。它使用 Guzzle 库(版本 4)来处理 HTTP 请求。

使用方法

<?php

require __DIR__.'/vendor/autoload.php';

use Openl10n\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);

许可证

OpenLocalization SDK 根据 MIT 许可证发布。有关详细信息,请参阅 捆绑的 LICENSE 文件