Download the PHP package translated/lara-sdk without Composer
On this page you can find all versions of the php package translated/lara-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download translated/lara-sdk
More information about translated/lara-sdk
Files in translated/lara-sdk
Package lara-sdk
Short Description Official Lara SDK for PHP
License MIT
Homepage https://laratranslate.com/
Informations about the package lara-sdk
Lara PHP SDK
This SDK empowers you to build your own branded translation AI leveraging our translation fine-tuned language model.
All major translation features are accessible, making it easy to integrate and customize for your needs.
๐ Features:
- Text Translation: Single strings, multiple strings, and complex text blocks
- Document Translation: Word, PDF, and other document formats with status monitoring
- Image Translation: Translate whole images or extract and translate text blocks
- Translation Memory: Store and reuse translations for consistency
- Glossaries: Enforce terminology standards across translations
- Styleguides: Define tone, voice, and writing style rules for translations
- Language Detection: Automatic source language identification
- Advanced Options: Translation instructions and more
๐ Documentation
Lara's SDK full documentation is available at https://developers.laratranslate.com/
๐ Quick Start
Installation
Basic Usage
๐ Examples
The examples/ directory contains comprehensive examples for all SDK features.
All examples use environment variables for credentials, so set them first:
Text Translation
- text_translation.php - Complete text translation examples
- Single string translation
- Multiple strings translation
- Translation with instructions
- TextBlocks translation (mixed translatable/non-translatable content)
- Auto-detect source language
- Advanced translation options
- Get available languages
- Detect language
Document Translation
- document_translation.php - Document translation examples
- Basic document translation
- Advanced options with memories and glossaries
- Step-by-step translation with status monitoring
Image Translation
- image_translation.php - Image translation examples
- Basic image translation
- Advanced options with memories and glossaries
- Extract and translate text from an image
- Edit translations and render them with layout or text-only paragraphs
Translation Memory Management
- memories_management.php - Memory management examples
- Create, list, update, delete memories
- Add individual translations
- Multiple memory operations
- TMX file import with progress monitoring
- Translation deletion
- Translation with TUID and context
Glossary Management
- glossaries_management.php - Glossary management examples
- Create, list, update, delete glossaries
- CSV import with status monitoring
- Glossary export (sync and async)
- Glossary terms count
- Import status checking
Styleguide Management
- styleguides_management.php - Styleguide management examples
- Create, list, get, update, delete styleguides
- Update name, content, or both at once
- Handling of non-existent styleguides
๐ง API Reference
Core Components
๐ Authentication
The SDK supports authentication via access key and secret:
Environment Variables (Recommended):
๐ Translator
Text Translation
Quality Estimation
Use qualityEstimation() to score how well a translation matches its source. Pass a single sentence/translation pair to get a single result, or two parallel arrays to get one result per pair.
๐ Document Translation
Simple document translation
Document translation with status monitoring
Document upload
Document translation status monitoring
Download translated document
๐ผ๏ธ Image Translation
renderTranslated($filePath, $source, $target, $paragraphs, $model = null, $noTrace = false)
renders supplied translations without translating them again. Pass null for the source language to omit it.
Supported models are overlay, inpainting, generative, and generative_fast; omitting the model uses
the API default, generative_fast. Set $noTrace to true to disable request tracing. As with translate,
the returned value is a stream resource that the caller must close.
overlay and inpainting require every entry to be an ImageLayoutParagraph, with bbox, linesBboxes,
textInfo, and alignment. Generative models accept both ImageParagraph and ImageLayoutParagraph.
The API validates paragraph contents; incomplete layout is invalid. Memory and glossary matches are
excluded from rendering requests.
includeLayout can be set in the options constructor or with setIncludeLayout(true). When it is true,
every entry is an ImageLayoutParagraph containing the complete metadata required by classic rendering.
Omitting the option, or setting it to false or null, preserves the text-only response.
The independent verbose option (or setVerbose(true)) requests memory and glossary matches.
ImageBBox exposes getTopLeft(), getTopRight(), getBottomRight(), and getBottomLeft() integer
coordinate pairs ([x, y]). ImageTextInfo exposes direction (ltr, rtl, or ttb), text color, and
background color through getters. Alignment is left, center, or right. The SDK serializes layout
using the API's snake_case field names.
๐ง Memory Management
๐ Glossary Management
๐ Styleguide Management
Translation Options
Language Codes
The SDK supports full language codes (e.g., en-US, fr-FR, es-ES) as well as simple codes (e.g., en, fr, es):
๐ Supported Languages
The SDK supports all languages available in the Lara API. Use the getLanguages() method to get the current list:
Asset permissions
Memories, glossaries, styleguides, and their share entries expose getPermissionMask() from the API's permission_mask field. Masks use read (r), write (w), export (e), and share (s) positions; - means absent. Supported masks are r---, rw--, r-e-, r--s, rwe-, rw-s, r-es, and rwes.
On memory, glossary, and styleguide resources, getPermissionMask() is optional and is null when omitted by the API, including POST, PUT, and DELETE resource responses. GET list and detail responses report the combined effective mask from the caller's applicable shares. Resources embedded in GET /shares responses report the selected share's stored mask; individual share entries report their own required stored mask.
The legacy permissions field and its read/write compatibility API have been removed. Use getPermissionMask() to inspect the read, write, export, and share bits. Share-entry masks are required, matching the service contract. Resource masks remain optional.
โ๏ธ Configuration
Error Handling
The SDK provides detailed error information:
๐ Requirements
- PHP 7.4 or higher
- Composer
- Valid Lara API credentials
๐งช Testing
Run the examples to test your setup:
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
Happy translating! ๐โจ
All versions of lara-sdk with dependencies
ext-curl Version *
ext-json Version *
ext-fileinfo Version *