Grinder-Smartling

Runtime Release License Coverage Build

Grinder plug-in dedicated to the synchronization of translations with the Smartling service, based on the File API v2.

Getting started

If you haven't used Grinder before, be sure to check out the related documentation, as it explains how to create a grind.dart file and to define project tasks. Once you're familiar with that process, you may install this plug-in.

Installing via Pub

1. Depend on it

Add this to your package's pubspec.yaml file:

devDpendencies:
  grinder_smartling: *

2. Install it

Install this package and its dependencies from a command prompt:

$ pub get

Once the plug-in has been installed, it may be enabled inside your grind.dart file.

Usage

The plug-in lets you synchronize translations with the Smartling service. Two functions are dedicated to this feature:

  • download(): Downloads the message translations from the remote server.
  • upload(): Uploads the source messages to the remote server.

These functions require four named parameters:

  • String fileUri : A value that uniquely identifies the remote file.
  • String projectId : The project identifier.
  • String userId : The identifier used to identify the API user.
  • String userSecret : The secret used to authenticate the API user.

Download the message translations from the Smartling service

The download() function takes a file pattern and a list of locales as inputs, indicating the path of the downloaded files and their target language. The {{locale}} placeholder will be replaced by the locale of each file.

import 'dart:async';
import 'package:grinder/grinder.dart';
import 'package:grinder_smartling/grinder_smartling.dart' as smartling;

@Task('Download the message translations from the Smartling service')
Future i18nDownload() => smartling.download(
  'path/to/i18n/{{locale}}.json', ['es-ES', 'fr-FR', 'ja-JP'],
  fileUri: '/Gulp-Smartling/messages.json',
  projectId: 'FooBar',
  userId: 'john.doe',
  userSecret: 'MyPassword'
);

The supported options are:

  • bool includeOriginalStrings = false : A value indicating whether to return the original string when no translation is available.
  • String retrievalType = "published" : The desired format for the download.

Upload the message source to the Smartling service

The upload() function takes a file path as input, specifying the message source to be uploaded.

import 'dart:async';
import 'package:grinder/grinder.dart';
import 'package:grinder_smartling/grinder_smartling.dart' as smartling;

@Task('Upload the source messages to the Smartling service')
Future i18nUpload() => smartling.upload(
  'path/to/i18n/en-US.json',
  fileUri: '/Gulp-Smartling/messages.json',
  projectId: 'FooBar',
  userId: 'john.doe',
  userSecret: 'MyPassword'
);

The supported options are:

  • bool authorize = false : A value indicating whether content in the file is authorized in all locales.
  • dynamic callbackUrl = null : The URL of the callback called when the file is 100% published for a locale.
  • String fileType = "" : The file type. If empty, will be guessed from the extension of the input file.

See also

License

Grinder-Smartling is distributed under the Apache License, version 2.0.

Libraries

grinder_smartling
Grinder plug-in dedicated to the synchronization of translations with the Smartling service.