Module: RubyLokaliseApi::Rest::Languages

Included in:
RubyLokaliseApi::Rest
Defined in:
lib/ruby_lokalise_api/rest/languages.rb

Instance Method Summary collapse

Instance Method Details

#create_project_languages(project_id, req_params) ⇒ RubyLokaliseApi::Collections::ProjectLanguages

Creates one or multiple languages for a project

Parameters:

  • project_id (String)
  • req_params (Hash, Array)

Returns:

See Also:



57
58
59
60
61
62
63
64
# File 'lib/ruby_lokalise_api/rest/languages.rb', line 57

def create_project_languages(project_id, req_params)
  name = 'ProjectLanguages'
  params = { query: project_id, req: req_params.to_array_obj(:languages) }

  data = endpoint(name: name, params: params).do_post

  collection name, data
end

#destroy_project_language(project_id, language_id) ⇒ RubyLokaliseApi::Generics::DeletedResource

Deletes a single language from the project

Parameters:

  • project_id (String)
  • language_id (String, Integer)

Returns:

See Also:



87
88
89
90
91
92
93
# File 'lib/ruby_lokalise_api/rest/languages.rb', line 87

def destroy_project_language(project_id, language_id)
  params = { query: [project_id, language_id] }

  data = endpoint(name: 'ProjectLanguages', params: params).do_delete

  RubyLokaliseApi::Generics::DeletedResource.new data.content
end

#project_language(project_id, language_id) ⇒ RubyLokaliseApi::Resources::ProjectLanguage

Returns a single project language

Parameters:

  • project_id (String)
  • language_id (String, Integer)

Returns:

See Also:



43
44
45
46
47
48
49
# File 'lib/ruby_lokalise_api/rest/languages.rb', line 43

def project_language(project_id, language_id)
  params = { query: [project_id, language_id] }

  data = endpoint(name: 'ProjectLanguages', params: params).do_get

  resource 'ProjectLanguage', data
end

#project_languages(project_id, req_params = {}) ⇒ RubyLokaliseApi::Collections::ProjectLanguages

Returns project languages

Parameters:

  • project_id (String)
  • req_params (Hash) (defaults to: {})

Returns:

See Also:



28
29
30
31
32
33
34
35
# File 'lib/ruby_lokalise_api/rest/languages.rb', line 28

def project_languages(project_id, req_params = {})
  name = 'ProjectLanguages'
  params = { query: project_id, req: req_params }

  data = endpoint(name: name, params: params).do_get

  collection name, data
end

#system_languages(req_params = {}) ⇒ RubyLokaliseApi::Collections::SystemLanguages

Returns Lokalise system languages

Parameters:

  • req_params (Hash) (defaults to: {})

Returns:

See Also:



13
14
15
16
17
18
19
20
# File 'lib/ruby_lokalise_api/rest/languages.rb', line 13

def system_languages(req_params = {})
  name = 'SystemLanguages'
  params = { req: req_params }

  data = endpoint(name: name, params: params).do_get

  collection name, data
end

#update_project_language(project_id, language_id, req_params = {}) ⇒ RubyLokaliseApi::Resources::ProjectLanguage

Updates a language for a project

Parameters:

  • project_id (String)
  • language_id (String, Integer)
  • req_params (Hash) (defaults to: {})

Returns:

See Also:



73
74
75
76
77
78
79
# File 'lib/ruby_lokalise_api/rest/languages.rb', line 73

def update_project_language(project_id, language_id, req_params = {})
  params = { query: [project_id, language_id], req: req_params }

  data = endpoint(name: 'ProjectLanguages', params: params).do_put

  resource 'ProjectLanguage', data
end