Skip to content

rosette-proj/rosette-tms-smartling

Repository files navigation

Build Status Code Climate Test Coverage

rosette-tms-smartling

A Rosette TMS (Translation Management System) that stores phrases and translations via Smartling, a 3rd-party translation service.

Installation

gem install rosette-tms-smartling

Then, somewhere in your project:

require 'rosette/tms/smartling-tms'

Introduction

This library is generally meant to be used with the Rosette internationalization platform. TMSs are configured per repo, so adding the Smartling TMS might cause your Rosette config to look like this:

require 'rosette/core'
require 'rosette/tms/smartling-tms'
require 'rosette/serializers/yaml-serializer'

rosette_config = Rosette.build_config do |config|
  config.add_repo('my-awesome-repo') do |repo_config|
    repo_config.add_serializer('rails', format: 'yaml/rails')

    repo_config.use_tms('smartling') do |tms_config|
      tms_config.set_serializer('yaml/rails')  # must add to repo_config above
      tms_config.set_api_options(
        smartling_api_key: 'fookey', smartling_project_id: 'fooid'
      )
    end
  end
end

Additional Configuration Options

rosette-tms-smartling supports additional configuration options:

Directives

Smartling directives give Smartling special instructions regarding how to interpret the files you send it. See their documentation for the supported directives for your file type. Note: Rosette determines the file type from the serializer you've told it to use, i.e. whatever you passed to #set_serializer.

repo_config.use_tms('smartling') do |tms_config|
  tms_config.set_directives(%Q[
    # smartling.plurals_detection = off
    # smartling.placeholder_format_custom = (\{\{.+?\}\})
  ])
end

Parse Frequency

rosette-tms-smartling looks up translations by maintaining an in-memory database downloaded and parsed from your Smartling project's translation memory. Translation memories contain all the translations that have ever been published in Smartling, and for this reason they can be very large. To avoid downloading and parsing the translation memory for every translation lookup, rosette-tms-smartling caches the download and parse result. All subsequent lookups will use the cache. After a certain amount of time has passed (called the "parse frequency"), the translation memory will be automatically re-downloaded on the next lookup. The default parse frequency is 1 hour. To avoid slow lookups in between refreshes, call the #re_download_memory method:

rosette_config.get_repo('my-awesome-repo').tms.re_download_memory

You can also set your own parse frequency (in seconds) during configuration:

repo_config.use_tms('smartling') do |tms_config|
  tms_config.set_parse_frequency(1800)  # 30 minutes
end

Thread Pool Size

Certain operations - eg. downloading translation memories for all locales - happen in parallel using multiple JVM threads. You can specify the maximum number of threads you want rosette-tms-smartling to use by using the #set_thread_pool_size method during configuration:

repo_config.use_tms('smartling') do |tms_config|
  tms_config.set_thread_pool_size(5)
end

Requirements

This project must be run under jRuby. It uses expert to manage java dependencies via Maven. Run bundle exec expert install in the project root to download and install java dependencies.

Running Tests

bundle exec rake or bundle exec rspec should do the trick.

Authors

About

Smartling support for the Rosette internationalization platform.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages