Lokalise APIv2 Ruby SDK

Ruby interface for the Lokalise APIv2 that represents returned data as Ruby objects.

View the Project on GitHub lokalise/ruby-lokalise-api




Changelog

9.0.0 (09-11-2023)

8.0.1 (24-Aug-2023)

8.0.0 (21-Jul-2023)

In this version SDK has been fully rewritten to make it more robust, better tested, and even more comfortable to work with. While most of the methods have similar signatures, there are a few major changes.

Breaking changes:

token = @client.create_jwt project_id, service: :ota

token.jwt # => '123abcd'
branch = @client.branch project_id, branch_id

branch.name # => 'my-branch'
branch[:name] # => 'my-branch'

Updates:

params = {
  lang_name: 'Updated custom language',
  plural_forms: %w[one many]
}

language = @client.project_language project_id, language_id

updated_language = language.update params

updated_language.lang_name # => 'Updated custom language'
project = @client.project project_id

restored_project = project.restore_snapshot snapshot_id

restored_project.name # => 'Project copy'
response = @client.destroy_screenshot project_id, screen_id
response.screenshot_deleted # => true
response[:screenshot_deleted] # => true

7.2.0 (11-Jan-2023)

resp = @client.jwt("123.abcd")
resp.jwt # => 'eyJ0eXAiOi...`

7.1.1 (03-Jan-2023)

7.1.0 (30-Nov-2022)

resp = @client.jwt
resp.jwt # => 'eyJ0eXAiOi...`

7.0.0 (18-Nov-2022)

RubyLokaliseApi.auth_client('client_id', 'client_secret')

# Previously:

token = auth_client.token 'oauth2_code' # this method used to return a hash

token['access_token']
token['refresh_token']

refresh = auth_client.refresh 'refresh_token' # this method used to return a hash

token['access_token']
token['expires_in']

# NOW:

token = auth_client.token 'oauth2_code' # this is an instance of the Token class

token.access_token
token.refresh_token

refresh = auth_client.refresh 'refresh_token' # this is an instance of the Refresh class

token.access_token
token.expires_in
auth_client = RubyLokaliseApi.auth_client('id', 'secret', timeout: 5, open_timeout: 10)

6.2.0 (02-Aug-2022)

New feature: added ability to access resources’ attributes with the [] notation. In other words, previously you could only write:

branch.branch_id
branch.name

Now you can also write:

branch[:branch_id]
branch['name']

This feature was introduced so that all resources can play nicely with methods like pluck.

6.1.0 (27-Jul-2022)

6.0.0 (11-Mar-2022)

require 'ruby-lokalise-api'

@client = Lokalise.client 'YOUR_TOKEN_HERE'

Now you should say:

require 'ruby_lokalise_api'

@client = RubyLokaliseApi.client 'YOUR_TOKEN_HERE'

5.0.0 (08-Feb-2022)

auth_client = RubyLokaliseApi.auth_client 'OAUTH2_CLIENT_ID', 'OAUTH2_CLIENT_SECRET'

# Generate authentication URL:
url = auth_client.auth scope: %w[read_projects write_tasks]

# Generate a new token:
response = auth_client.token 'secret code'
access_token = response['access_token']
refresh_token = response['refresh_token']

# Refresh an expired token:
response = auth_client.refresh('YOUR_REFRESH_TOKEN')['access_token']

# Use the access token to perform requests on the user's behalf:
@client = RubyLokaliseApi.oauth2_client access_token
@client.projects # list user's projects

4.5.1 (27-Jan-22)

4.5.0 (16-Dec-21)

4.4.0 (25-Oct-21)

@client = RubyLokaliseApi.oauth_client("TOKEN_OBTAINED_VIA_OAUTH2", params)
RubyLokaliseApi.reset_oauth_client! # effectively sets the `@oauth_client` to `nil`

4.3.1 (21-Sep-21)

4.3.0 (15-Jul-21)

client = RubyLokaliseApi.client('YOUR_TOKEN', enable_compression: true)

4.2.0 (28-Apr-21)

4.1.0 (01-Mar-21)

4.0.0 (02-Feb-21)

3.1.0 (08-Jul-20)

3.0.0 (18-May-20)

queued_process = @client.upload_file project_id,
                                     data: 'Base-64 encoded data... ZnI6DQogI...',
                                     filename: 'my_file.yml',
                                     lang_iso: 'en'

queued_process.status # => 'queued'
# ...after some time...
queued_process = queued_process.reload_data
queued_process.status # => 'finished'

2.10.0 (28-Feb-20)

2.9.0.1 (21-Jan-20)

2.9.0 (05-Jan-20)

2.8.0 (13-Nov-19)

2.7.0 (30-Oct-19)

2.6.1 (27-Sep-19)

2.6.0 (21-Aug-19)

2.5.0 (01-Aug-19)

2.4.0 (31-Jul-19)

2.3.0 (17-Jul-19)

2.2.0 (19-May-19)

2.1.1 (17-May-19)

2.1.0 (19-Mar-19)

2.0.1 (21-Feb-19)

2.0.0 (14-Dec-18)

1.1.0 (11-Dec-18)

1.0.1 (10-Dec-18)

1.0.0 (10-Dec-18)