L10n.ws logo L10n.ws

Lightweight Java libraries that allow perform low-level calls to access messages of L10n account.

HTTP Client

This Java library provides general functionality related to HTTP v1 API, includes HTTP transport, error handling, authentication, JSON parsing.

Include in project

Library published in maven central repository.

Maven

<dependency>
    <groupId>ws.l10n</groupId>
    <artifactId>l10n-client-http</artifactId>
    <version>1.0.3</version>
</dependency>

Gradle

compile 'ws.l10n:l10n-client-http:1.0.3'

Usage

Create client

String serviceUrl = "https://l10n.ws/api/v1";
String accessToken = "YOUR_ACCESS_TOKEN";

MessageBundleService client = new HttpMessageBundleClient(serviceUrl, accessToken);

Load messages

String bundleKey = "YOUR_BUNDLE_KEY";
String bundleVersion = "YOUR_BUNDLE_VERSION";
MessageBundle messageBundle = client.loadMessageBundle(bundleKey, bundleVersion);

MessageBundleContext messageBundleContext = new SimpleMessageBundleContext(messageBundle);

messageBundleContext.getMessage("login.username", Locale.US);

Core Library

Core Library provides a configurable messages contexts. Context uses L10n Java Client Library for getting message from a service.

Maven

<dependency>
    <groupId>ws.l10n</groupId>
    <artifactId>l10n-core</artifactId>
    <version>1.0.3</version>
</dependency>

Gradle

compile 'ws.l10n:l10n-core:1.0.3'

Usage

Create reloadable context

ReloadableMessageBundleContext reloadableMessageBundleContext =
    new ReloadableMessageBundleContext(messageBundleService, bundleKey, bundleVersion);

Initialize context

reloadableMessageBundleContext.init(); // load all message

Reload messages

reloadableMessageBundleContext.reload();

Source Code

For more details source code you can find here https://github.com/l10nws/l10n-java