metaphrase/php-sdk
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo

Namespaces

  • metaphrase
    • phpsdk
      • cache
      • controllers

Classes

  • Metaphrase

Interfaces

  • ICache
  • MetaphraseException

Class Metaphrase

Metaphrase class

Create a new instance of this class by providing your authentication credentials And execute the available API methods

Currently uses old translate API

Namespace: metaphrase\phpsdk
Package: metaphrase\phpsdk
Copyright: (c) 2014-2015, Spafaridis Xenophon
License: LGPL License 2.1
Author: Spafaridis Xenophon nohponex@gmail.com
Version: 0.1.2
Uses: curl_init curl
Todo: Migrate to metaphrase api
Todo: Make sure it can be work as a script in order to assist other SDKs to download and cache the translated data
Located at metaphrase/phpsdk/Metaphrase.php

Methods summary

public Returns
# __construct( string $api_key, array $settings = [], metaphrase\phpsdk\ICache $cache_engine = NULL )

Create a new instance of the class using user's email and password as authentication credentials

Create a new instance of the class using user's email and password as authentication credentials

Parameters

$api_key
Your API KEY
$settings
$cache_engine

Returns

Returns
an instance of Translate
public array
# request( string $resource, $method = metaphrase\phpsdk\Metaphrase::METHOD_GET, $data = NULL, $flags = metaphrase\phpsdk\Metaphrase::REQUEST_EMPTY_FLAG, $accept = 'application/json', $encoding = NULL )

Perform an cURL request to API server, this is an internal function

Perform an cURL request to API server, this is an internal function

Parameters

$resource
Resource fraction of the url for example fetch/?name=xx
$method
$data
$flags
$accept
$encoding

Returns

array

Returns an array with the response code and the response, if the accept parameter is set to json the the response will be decoded as json

public array
# fetch( integer $project_id, string $language_code, boolean $use_cached = TRUE )

Get all translation keys

Get all translation keys

Deprecated

since version 0.1.0 Use $this->translated

Parameters

$project_id
Project's id
$language_code
Lanuage Code
$use_cached
[Optional] If true, the SDK will attempt to use the selected cache machine. Default TRUE

Returns

array
Returns translation array for selected language

Throws

metaphrase\phpsdk\MetaphraseException
on failure
public boolean
# add_key( integer $project_id, string $keyword )

Add keyword to a project

Add keyword to a project

Deprecated

since version 0.1.0 use $this->keyword->post

Parameters

$project_id
Project's id
$keyword
Keyword

Returns

boolean
Returns TRUE on success

Throws

metaphrase\phpsdk\MetaphraseException
on failure
public static
# cache_update( type $project_id, type $language_code )

Cache helper task

Cache helper task

Parameters

$project_id
$language_code

Todo

implement
public static
# cache_clear( type $project_id, type $language_code )

Cache helper task

Cache helper task

Parameters

$project_id
$language_code

Todo

implement
public object|null
# get_cache_engine( )

Get current caching engine

Get current caching engine

Returns

object|null

Magic methods summary

Constants summary

string VERSION
# '0.1.2'
string METHOD_GET
# 'GET'
string METHOD_HEAD
# 'HEAD'
string METHOD_POST
# 'POST'
string METHOD_DELETE
# 'DELETE'
string METHOD_PUT
# 'PUT'
integer REQUEST_EMPTY_FLAG
# 0
integer REQUEST_BINARY
# 1
integer REQUEST_NOT_URL_ENCODED
# 2
integer SETTING_CURLOPT_CONNECTTIMEOUT

Setting CURLOPT_CONNECTTIMEOUT - timeout for the connect phase Pass a long. It should contain the maximum time in seconds that you allow the connection phase to the server to take. This only limits the connection phase, it has no impact once it has connected. Set to zero to switch to the default built-in connection timeout - 300 seconds. Default timeout is 300.

Setting CURLOPT_CONNECTTIMEOUT - timeout for the connect phase Pass a long. It should contain the maximum time in seconds that you allow the connection phase to the server to take. This only limits the connection phase, it has no impact once it has connected. Set to zero to switch to the default built-in connection timeout - 300 seconds. Default timeout is 300.

See

CURLOPT_CONNECTTIMEOUT
# CURLOPT_CONNECTTIMEOUT
integer SETTING_CURLOPT_TIMEOUT

Setting CURLOPT_TIMEOUT - set maximum time the request is allowed to take

Setting CURLOPT_TIMEOUT - set maximum time the request is allowed to take

Pass a long as parameter containing timeout - the maximum time in seconds that you allow the libcurl transfer operation to take. Normally, name lookups can take a considerable time and limiting operations to less than a few minutes risk aborting perfectly normal operations. This option may cause libcurl to use the SIGALRM signal to timeout system calls. Default timeout is 0 (zero) which means it never times out during transfer.

See

CURLOPT_TIMEOUT
# CURLOPT_TIMEOUT

Properties summary

public $keyword
#
public $project
#
public $translated
#
metaphrase/php-sdk API documentation generated by ApiGen