TranslateMedia Releases PHP Library for STREAM

TranslateMedia Releases PHP Library for STREAM

TranslateMedia has released a PHP library to allow developers and businesses to begin to use the STREAM platform to deliver high-quality human translations into their PHP-based content management systems or web applications.

PHP is the most widely used open source general-purpose scripting language on the web and is the language that powers some of the best known content management systems and eCommerce platforms such as WordPress and Magento. It is also used to create some of the most popular web development frameworks including Zend Framework, Laravel and CodeIgniter.

Due to its popularity and ease of implementation, we’ve developed a PHP library to allow your business to easily connect its systems to our translation management API, allowing you to automate your translation management by providing direct access to the TranslateMedia STREAM Translation Workflow Technology via standard web services technology.

By automating your translation processes, you’ll be able to send your content for translation securely from within your CMS or web application, obtain instant quotes, receive faster turnarounds and eliminate the need for copy and pasting or sending documents by email.

Want to start integrating professional human translations into your PHP applications? Download the library here.

Getting started

In order to get started using the STREAM PHP library, you’ll need to request access by completing this form. Once you’ve been approved, you’ll be provided with a user account and an API key which you can use to authenticate your application and begin sending content for translation and receiving the translated content back into your application.


Before any requests can be sent to STREAM, you need to ensure you specify your username and API key.

$cTMAPI = new cTMAPI(‘[EMAIL]’,’[APIKEY]’,’’,’’);

When entering your API key, it’s important to use single quotes to specify it as a string. If you use double quotes then problems can be caused with PHP ‘special’ characters such as $ which is regarded as a variable to be parsed.


STREAM provides support for over 195 languages and locales. You can retrieve a list of languages by using the GetLanguagesList function.


This will return the Language ID in STREAM (languageID), RFC 5646 code (rfc5646) and description.

It’s also possible to return the language ID in STREAM by passing the description.

$languageName=”Arabic (Lebanon)”;

And it’s possible to return the language ID by passing the relevant RFC 5646 code to the GetLanguageIdRfc5646() function.


In order to return all the available target languages for a given source language, you can use the GetAvailableTargetLanguages function – passing each source language to the function as an array.



STREAM supports six distinct specialisms – General, Marketing, Finance, Medical, Legal and Technical. A list of all specialisms, along with their IDs can be retrieved using the GetSpecialitiesList function.


However, not all specialisms are available for every language as this is largely dependent on the number of qualified linguists we have available with the relevant specialist skills. So to return the available specialisms for a given language, you can use the GetAvailableSpecialities function passing the ID of the relevant language (in this case en-us).



Once you’ve got the content that you’d like to translate, you’ve identified the languages you’d like to translate that content into and the specialisms that apply to the project – you can begin to request a quote. There are a number of different functions that can help with this depending on whether the content is plain text, a document such as a Word file or PDF or other types of document such as XML.

One method is to translate a line of plain text. This can be done using the GetQuoteForPlainText function. You’ll need to pass the relevant IDs for source language, specialism, target language(s) and finally the source text.

$quotes=$cTMAPI->GetQuoteForPlainText (35, 16, array(40,41), ‘This is a test text to try translating in to a foreign language.’);

In order to get a quote for a document, you’ll need to use the GetQuoteForDocument function – again passing the relevant values for source language, specialism, target language(s), document path and file name.

$quotes=$cTMAPI->GetQuoteForDocument(35, 16, array(40,41), ‘Documentation/Please read.txt’,”Please Read.txt”);

If you require a document to be authenticated or partially translated, then you may want to use the GetAdvancedQuoteForDocument function to specify these additional parameters in the request along with the source and target languages.

$quotes=$cTMAPI->GetAdvancedQuoteForDocument(35, 16, array(40,41), ‘Documentation/Please read.txt’,”Please Read.txt”, NO_AUTHENTICITY_CERTIFICATION, false);

Or in some cases, you may just want to obtain a quick simple quote without sending any documents but simply specifying a word count. This can be done with the GetSimpleQuote function. Again, the source language, target language(s), specialism and word count need to be included in that order in the request.

$quotes=$cTMAPI->GetSimpleQuote(35, 16, array(40,41), 100, 92345);


Once you’ve received a quote that you’re happy with, you can use the quote ID returned from the relevant function above to create an order using the CreateOrder function.


Tracking job progress

The CreateOrder function will return a job ID which can be used to track the progress of your job using the TrackOrder function.


Upload more information

if you need to add additional information to a job that’s already in progress, this can also be done using the API using the UploadMoreInfoDocument function.

$jobstatus=$cTMAPI->UploadMoreInfoDocument(‘93267_1zwnyib8k0U96yT2ssBalQ!$£!$£’,’Documentation/Please read.txt’,”Please Read.txt”);

It’s also possible to track all orders within a given date range using the TrackOrders function.

$trackorders=$cTMAPI->TrackOrders(“2015-12-01”, “2015-12-30”, true);

Receiving the translated document

When your document has been translated and reviewed in-house, you can retrieve it using the RetrieveTranslatedDocument function.


And that’s it! However, there is a lot you can do with the API that’s not been outlined above so review the API documentation before you get started so you can build additional functionality into your application.

And do let us know if you have any specific requirements that haven’t been outlined in this demonstration and we’ll support you. If you have any problems accessing the API or would like more information on the PHP SDK, please contact

Written by Yusuf Bhana
Yusuf Bhana
Yusuf is Head of Digital at TranslateMedia. He has an interest in how technology can help businesses achieve their marketing objectives. He's been working in digital marketing and web development since 2001 across a wide range of industries and clients.

Related posts

Subscribe to our newsletter