Getting Started
The Lara SDK gives developers direct, programmatic access to Lara’s translation capabilities, making it easy to build custom translation features into any application or workflow.
Step 1 - Check Requirements
The requirements for installing the SDK vary depending on the framework and language you use.
Framework | Required Version |
---|---|
Python | >= 3.8 |
NodeJS | >= 12 |
Java | >= 1.8 (8) |
PHP | >= 5.6 |
To check your currently installed version, use this command:
python --version
node -v
java --version
php -v
Step 2 - Install the SDK
pip install lara-sdk
npm install @translated/lara
<dependency>
<groupId>com.translated.lara</groupId>
<artifactId>lara-sdk</artifactId>
<version>1.2.3</version>
</dependency>
// Project build.gradle
dependencies {
configuration('com.translated.lara:lara-sdk:1.2.3')
}
// if you are using Gradle Kotlin DSL
// Project build.gradle.kts
dependencies {
implementation("com.translated.lara:lara-sdk:1.2.3")
}
composer require translated/lara-sdk:1.0.1
Step 3 - Configure Your Credentials
- Go to the Lara Translate website, subscribe any plan (including the free one)
- Create a new pair of Lara credentials in the API section of your account
Store them in a secure location. If lost they cannot be recovered, you will need to generate new ones.
Step 4 - Translate
With the SDK installed and the credentials got from the website, you are ready to perform your first translation with Lara.
from lara_sdk import Translator, Credentials
LARA_ACCESS_KEY_ID = "ABC123..." # Replace with your Access Key ID
LARA_ACCESS_KEY_SECRET = "aBc123..." # Replace with your Access Key SECRET
if __name__ == '__main__':
credentials = Credentials(access_key_id=LARA_ACCESS_KEY_ID, access_key_secret=LARA_ACCESS_KEY_SECRET)
lara = Translator(credentials)
# This translates your text from English ("en-US") to Italian ("it-IT").
res = lara.translate("Hello, how are you? This text can be very long.",
source="en-US",
target="it-IT")
# Prints the translated text: "Ciao, come stai? Questo testo può essere molto lungo."
print(res.translation)
import {Credentials, Translator} from "@translated/lara";
const LARA_ACCESS_KEY_ID = "ABC123..." // Replace with your Access Key ID
const LARA_ACCESS_KEY_SECRET = "aBc123..." // Replace with your Access Key SECRET
const credentials = new Credentials(LARA_ACCESS_KEY_ID, LARA_ACCESS_KEY_SECRET);
const lara = new Translator(credentials);
async function main() {
// This translates your text from English ("en-US") to Italian ("it-IT").
const res = await lara.translate('Hello, how are you? This text can be very long.',
'en-US', 'it-IT');
// Prints the translated text: "Ciao, come stai? Questo testo può essere molto lungo."
console.log(res.translation)
}
main().finally(() => console.log('Done!'))
package mypackage.example
import com.translated.lara.Credentials;
import com.translated.lara.errors.LaraException;
import com.translated.lara.translator.TextResult;
import com.translated.lara.translator.Translator;
public class Main {
// Replace with your Access Key ID
private static final String LARA_ACCESS_KEY_ID = "ABC123...";
// Replace with your Access Key SECRET
private static final String LARA_ACCESS_KEY_SECRET = "aBc123...";
public static void main(String[] args) throws LaraException {
Credentials credentials = new Credentials(LARA_ACCESS_KEY_ID, LARA_ACCESS_KEY_SECRET);
Translator lara = new Translator(credentials);
// This translates your text from English ("en-US") to Italian ("it-IT").
TextResult res = lara.translate("Hello, how are you? This text can be very long.",
"en-US", "it-IT");
// Prints the translated text: "Ciao, come stai? Questo testo può essere molto lungo."
System.out.println(res.getTranslation());
}
}
<?php
require 'vendor/autoload.php';
use Lara\Translator;
use Lara\LaraCredentials;
$LARA_ACCESS_KEY_ID = "ABC123..."; // Replace with your Access Key ID
$LARA_ACCESS_KEY_SECRET = "aBc123..."; // Replace with your Access Key SECRET
$credentials = new LaraCredentials($LARA_ACCESS_KEY_ID, $LARA_ACCESS_KEY_SECRET);
$lara = new Translator($credentials);
// This translates your text from English ("en-US") to Italian ("it-IT").
$result = $lara->translate('Hello, how are you? This text can be very long.',
'en-US', 'it-IT');
// Prints the translated text: "Ciao, come stai? Questo testo può essere molto lungo."
echo $result->getTranslation();
Full documentation for the translate
function can be found in the SDK Reference.
Git Security Recommendation
If you are using git, always double-check before committing or pushing code to a Git repository to ensure that neither your key nor secret is included.
We strongly recommend storing your credentials in a git-ignored
.env
within your project and relying on one of the many tools available to load credentials at runtime, such asdotenv
.Exposing both the key and secret can lead to unauthorized access, security breaches, and potential financial losses.
Next Steps
With the SDK successfully set up and working, you’re ready to dive deeper into Lara. Explore the following pages and examples to discover its full capabilities.
Updated 16 days ago