nicmart/getlocalization

A simple php client for GetLocalization

v0.1 2013-03-05 12:20 UTC

This package is auto-updated.

Last update: 2024-03-23 15:19:08 UTC


README

GetLocalization is a simple php client for the GetLocalization File Management api.

Build Status

Install

The best way to install GetLocalization is through composer.

Just create a composer.json file for your project:

{
    "require": {
        "nicmart/getlocalization": "dev-master"
    }
}

Then you can run these two commands to install it:

$ 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.

Then you can include the autoloader, and you will have access to the library classes:

<?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:

<?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.

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.

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

Get a zipped archive of all translations

/**
 * Download all translations in zip format
 */
$client->getZippedTranslations();

CREDITS

Tests

$ phpunit

License

MIT, see LICENSE.