Ruby interface for the Lokalise APIv2 that represents returned data as Ruby objects.
View the Project on GitHub lokalise/ruby-lokalise-api
@client.system_languages(params = {}) # Input:
## params (hash)
### :page and :limit
# Output:
## Collection of system languages supported by Lokalise
For example:
params = {
limit: 10,
page: 3
}
languages = @client.system_languages params
languages[0].lang_name # => 'Abkhaz'
@client.project_languages(project_id, params = {}) # Input:
## project_id (string, required)
## params (hash)
### :page and :limit
# Output:
## Collection of languages available in the given project
For example:
project_id = '123.abc'
params = {
imit: 1,
page: 2
}
languages = @client.project_languages project_id, params
languages[0].lang_iso # => 'fr'
Alternatively:
project = @client.project project_id
languages = project.languages params
@client.project_language(project_id, language_id) # Input:
## project_id (string, required)
## language_id (string, required)
# Output:
## A single language in the given project
For example:
project_id = '123.abc'
language_id = '1234'
language = client.project_language project_id, language_id
language.lang_iso # => 'fr'
Alternatively:
project = @client.project project_id
language = project.language language_id
@client.create_project_languages(project_id, params) # Input:
## project_id (string, required)
## params (array of hashes or hash, required) - contains parameter of newly created languages. Pass array of hashes to create multiple languages, or a hash to create a single language
### :lang_iso (string, required)
### :custom_iso (string)
### :custom_name (string)
### :custom_plural_forms (array) - can contain only plural forms initially supported by Lokalise
# Output:
## Collection of newly created languages
For example:
params = [{
lang_iso: 'de'
}, {
lang_iso: 'nl'
}]
languages = @client.create_project_languages project_id, params
languages[0].lang_iso # => 'de'
Alternatively:
project = @client.project project_id
languages = project.create_languages params
@client.update_project_language(project_id, language_id, params) # Input:
## project_id (string, required)
## language_id (string, required)
## params (hash, required)
### :lang_iso (string, required)
### :custom_name (string)
### :plural_forms (array) - can contain only plural forms initially supported by Lokalise
# Output:
## Updated language
For example:
params = {
lang_name: 'Updated custom language',
plural_forms: %w[one]
}
language = @client.update_project_language project_id, language_id, params
language.lang_name # => 'Updated custom language'
Alternatively:
language = @client.project_language project_id, language_id
language.update params
# OR
project = @client.project project_id
language = @client.update_language language_id, params
@client.destroy_project_language(project_id, language_id) # Input:
## project_id (string, required)
## language_id (string, required)
# Output:
## Generic with the project id and "language_deleted"=>true
For example:
response = @client.destroy_project_language project_id, language_id
response.language_deleted # => true
Alternatively:
language = @client.language project_id, language_id
response = language.destroy
# OR
project = @client.project project_id
response = project.destroy_language language_id