GetLocalization
GetLocalization is a simple php client for the GetLocalization File Management api., (*1)
, (*2)
Install
The best way to install GetLocalization is through composer., (*3)
Just create a composer.json file for your project:, (*4)
{
"require": {
"nicmart/getlocalization": "dev-master"
}
}
Then you can run these two commands to install it:, (*5)
$ curl -s http://getcomposer.org/installer | php
$ php composer.phar install
or simply run composer install
if you have have already installed the composer globally., (*6)
Then you can include the autoloader, and you will have access to the library classes:, (*7)
<?php
require 'vendor/autoload.php';
use GetLocalization\Client;
Initialization
All you have to do is to instantiate a new Client object, passing to its constructor your GetLocalization username and
password and the name of your project:, (*8)
<?php
$client = new GetLocalization\Client('username', 'password', 'projectname');
Api calls
This library offers an one-to-one mapping with the
GetLocalization File Management API.
And that's all. Managing merging of your local files with GetLocalization ones is up to you., (*9)
Managing master files
Create a new master file
/**
* @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);
Update a master file
/**
* @param string $filePath The path of the local file to upload as master file
*/
$client->updateMaster($filePath);
Be careful here to pass a file path of a file that has the same name of the master file you want to update., (*10)
List all master files
/**
* List master files
*
* @return array A php array that is the json-decoded response of the get call
*/
$client->listMaster();
Managing Translations
Get a translation
/**
* @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);
Update a translation
/**
* @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);
Get a list of all translations
Not implemented yet, (*11)
Get a zipped archive of all translations
/**
* Download all translations in zip format
*/
$client->getZippedTranslations();
CREDITS
Tests
$ phpunit
License
MIT, see LICENSE., (*12)