Please note that this article covers a solution for plain Ruby. You might also be interested in our Ruby on Rails integration.
Prerequisites
You'll need an existing Lokalise project. Specifically, you'll require the project ID that can be found in the project settings.
A read/write Lokalise API token is required. Learn how to work with the API tokens in the corresponding article.
Exchanging translation files
If you are building a plain Ruby application and would like to exchange translation files with Lokalise, you can take advantage of a special library to manage translation files (lokalise_manager
gem) which allows to run the import/export task programmatically from any Ruby script.
Here's an example:
require "#{Rails.root}/config/lokalise_rails.rb"
importer = LokaliseManager.importer({api_token: '1234abc', project_id: '123.abc'}, LokaliseRails::GlobalConfig)
importer.import!
# OR
exporter = LokaliseManager.exporter({api_token: '1234abc', project_id: '123.abc'}, LokaliseRails::GlobalConfig)
exporter.export!