SDKs overview

Lokalise provides a suite of Software Development Kits (SDKs) and libraries designed to facilitate interaction with its translation management system. These tools assist in automating various localization tasks, from fetching and pushing translation keys to managing projects and contributors programmatically. The SDKs abstract the underlying RESTful API, offering language-specific constructs to simplify development and integration for developers working with different technology stacks.

The core functionality of the Lokalise API, which the SDKs wrap, includes operations such as reading and modifying project data, managing translation keys and their associated translations, handling screenshots for context, and orchestrating localization workflows. Developers can integrate Lokalise SDKs into their build processes, CI/CD pipelines, and application codebases to maintain synchronized translation data across development and production environments. For example, integration with version control systems like Git allows for automating the update of translation files whenever code changes occur, a common practice in modern software development for continuous delivery (Google Cloud continuous delivery overview).

Lokalise's SDKs are categorized into official libraries, maintained directly by Lokalise, and community-contributed projects. This page focuses on the official SDKs, their installation procedures, and practical quickstart examples across supported languages. For a complete reference of all API endpoints and data models, consult the Lokalise API reference documentation.

Official SDKs by language

Lokalise offers official SDKs for several popular programming languages, each designed to provide a native development experience for integrating with the Lokalise platform. These SDKs are maintained to reflect the latest API versions and best practices.

Language Package/Library Name Installation Command (Example) Maturity
JavaScript (Node.js) @lokalise/node-api npm install @lokalise/node-api Stable
PHP lokalise/php-api composer require lokalise/php-api Stable
Ruby lokalise_api gem install lokalise_api Stable
Python python-lokalise-api pip install python-lokalise-api Stable
Java com.lokalise.api:lokalise-java-api Add to pom.xml or build.gradle Stable
Go github.com/lokalise/go-lokalise-api go get github.com/lokalise/go-lokalise-api Stable
Flutter lokalise_flutter_sdk Add to pubspec.yaml Stable
React Native @lokalise/react-native-sdk npm install @lokalise/react-native-sdk Stable
Swift (iOS) Lokalise Via CocoaPods/Swift Package Manager Stable
Kotlin (Android) com.lokalise.sdk:lokalise-android-sdk Add to build.gradle Stable

Each SDK provides a client object that can be initialized with an API token, enabling authenticated requests to the Lokalise API. Developers can find detailed documentation for each specific SDK, including initialization, method calls, and error handling, within the Lokalise developer documentation portal.

Installation

Installing Lokalise SDKs typically follows the standard package management practices for each respective programming language. Below are common installation methods for several official SDKs. Ensure you have the correct package manager installed and configured for your environment.

JavaScript (Node.js)

For Node.js environments, the @lokalise/node-api package is installed via npm or yarn:


npm install @lokalise/node-api
# or
yarn add @lokalise/node-api

PHP

PHP projects use Composer to manage dependencies. Add lokalise/php-api to your composer.json file or install directly:


composer require lokalise/php-api

Python

Python developers can install the python-lokalise-api package using pip:


pip install python-lokalise-api

Java

For Java projects, you typically include the Lokalise Java API as a dependency in your build tool configuration (Maven or Gradle).

Maven (pom.xml):


<dependency>
    <groupId>com.lokalise.api</groupId>
    <artifactId>lokalise-java-api</artifactId&n>
    <version>YOUR_VERSION</version> <!-- Replace with the latest version -->
</dependency>

Gradle (build.gradle):


implementation 'com.lokalise.api:lokalise-java-api:YOUR_VERSION' // Replace with the latest version

Go

Go modules are used to install the Go SDK:


go get github.com/lokalise/go-lokalise-api

Flutter

Integrate the Flutter SDK by adding it to your pubspec.yaml file:


dependencies:
  flutter:
    sdk: flutter
  lokalise_flutter_sdk: ^YOUR_VERSION # Replace with the latest version

Then run flutter pub get to fetch the package.

React Native

Install the React Native SDK using npm or yarn:


npm install @lokalise/react-native-sdk
# or
yarn add @lokalise/react-native-sdk

Swift (iOS)

For iOS development, you can use CocoaPods or Swift Package Manager. For CocoaPods, add to your Podfile:


pod 'Lokalise', '~> YOUR_VERSION' # Replace with the latest version

Then run pod install.

Kotlin (Android)

For Android development, add the dependency to your app's build.gradle file:


implementation 'com.lokalise.sdk:lokalise-android-sdk:YOUR_VERSION' // Replace with the latest version

Quickstart example

This quickstart demonstrates how to fetch a list of projects using the Lokalise SDK for Node.js. Replace YOUR_API_TOKEN and YOUR_PROJECT_ID with your actual Lokalise credentials. For security, API tokens should never be hardcoded in production applications; use environment variables or a secure configuration management system.


const { LokaliseApi } = require('@lokalise/node-api');

const lokaliseApi = new LokaliseApi({
  apiKey: 'YOUR_API_TOKEN' // Replace with your Lokalise API token
});

async function getProjects() {
  try {
    const projects = await lokaliseApi.projects.list();
    console.log('Lokalise Projects:', projects.items.map(p => p.name));
  } catch (error) {
    console.error('Error fetching projects:', error.message);
  }
}

getProjects();

// Example: Fetching keys for a specific project
async function getProjectKeys(projectId) {
  try {
    const keys = await lokaliseApi.keys.list({
      project_id: projectId
    });
    console.log(`Keys for project ${projectId}:`, keys.items.map(k => k.key_name.web));
  } catch (error) {
    console.error(`Error fetching keys for project ${projectId}:`, error.message);
  }
}

// Call this with a specific project ID
// getProjectKeys('YOUR_PROJECT_ID'); // Uncomment and replace with actual project ID

This example initializes the Lokalise API client with your API token and then calls the projects.list() method to retrieve a list of all accessible projects. It then prints the names of these projects to the console. The commented-out section shows how to retrieve keys for a specific project, demonstrating a common operation in localization workflows. For more complex operations, such as creating keys, updating translations, or managing contributors, refer to the Lokalise API reference and specific SDK documentation.

Community libraries

Beyond the officially supported SDKs, the Lokalise ecosystem includes community-contributed libraries and integrations. These tools often extend functionality to niche use cases, provide bindings for additional languages, or offer specific integrations with other developer tools. While not officially maintained by Lokalise, they can be valuable resources for developers seeking alternative approaches or specialized functionality.

Community libraries are typically hosted on platforms like GitHub and distributed via language-specific package managers. Before incorporating a community library into a production environment, it is advisable to review its documentation, community support, and maintenance status. Developers should refer to the Lokalise documentation for any officially recommended community projects or integration guidelines. Examples of such integrations might include plugins for content management systems, CLI tools, or specialized deployment scripts that automate translation updates as part of a continuous integration/continuous deployment (CI/CD) pipeline, a strategy widely adopted in modern software development (Mozilla CI/CD explanation).

The developer community also contributes to supporting integrations with various frameworks and platforms. These contributions can range from simple scripts to more comprehensive libraries that facilitate tasks like syncing translation files with version control systems or automating content delivery network (CDN) updates after translation changes. Always check the official Lokalise resources for the most up-to-date information on recommended community tools and their compatibility with the latest Lokalise API versions.