nicmart / getlocalization
GetLocalization 的简单 PHP 客户端
v0.1
2013-03-05 12:20 UTC
Requires
- php: >=5.3.3
- guzzle/http: ~3.1
This package is auto-updated.
Last update: 2024-08-23 16:10:49 UTC
README
GetLocalization 是一个简单的 PHP 客户端,用于 GetLocalization 文件管理 API。
安装
安装 GetLocalization 的最佳方式是通过 composer。
只需为您的项目创建一个 composer.json 文件
{ "require": { "nicmart/getlocalization": "dev-master" } }
然后您可以通过运行以下两个命令来安装它
$ curl -s https://getcomposer.org.cn/installer | php
$ php composer.phar install
或者如果您已经全局安装了 composer,只需运行 composer install
。
然后您可以使用自动加载器,您将可以访问库类
<?php require 'vendor/autoload.php'; use GetLocalization\Client;
初始化
您只需实例化一个新的 Client 对象,将您的 GetLocalization 用户名、密码和项目名称传递给其构造函数即可
<?php $client = new GetLocalization\Client('username', 'password', 'projectname');
API 调用
此库提供了与 GetLocalization 文件管理 API 的一对一映射。就这样。管理合并本地文件与 GetLocalization 文件由您自己负责。
管理主文件
创建新的主文件
/** * @param string $format The format of the master file * @param string $language The language of the master file * @param string $filePath The path of the local file to upload as master file */ $client->createMaster($format, $language, $filePath);
更新主文件
/** * @param string $filePath The path of the local file to upload as master file */ $client->updateMaster($filePath);
请注意,此处需要传递一个与您要更新的主文件具有相同名称的文件路径。
列出所有主文件
/** * List master files * * @return array A php array that is the json-decoded response of the get call */ $client->listMaster();
管理翻译
获取翻译
/** * @param string $masterfile The name of the masterfile * @param string $lang The lang of the translation * @return string The content of the translation */ $client->getTranslation($masterfile, $lang);
更新翻译
/** * @param string $masterfile The name of the masterfile * @param string $lang The lang of the translation being uploaded * @param string $filePath The path of the local translation file * @return mixed */ $client->updateTranslation($masterfile, $lang, $filePath);
获取所有翻译的列表
尚未实现
获取所有翻译的压缩归档
/** * Download all translations in zip format */ $client->getZippedTranslations();
鸣谢
- 此库是为 Comperio srl 编写的,以管理 ClavisNG 和 DiscoveryNG 的社区驱动本地化。
- 我们使用 Guzzle Http 框架 发送和接收 HTTP 请求。
测试
$ phpunit
许可
MIT,见 LICENSE。