Elixir interface for the Lokalise APIv2.
View the Project on GitHub lokalise/elixir-lokalise-api
Add a new dependency to mix.exs
:
def deps do
[
{:elixir_lokalise_api, "~> 2.0"}
]
end
Obtain Lokalise API token in your personal profile and put it into config.exs
:
config :elixir_lokalise_api, api_token: "LOKALISE_API_TOKEN"
If you are using ENV variables, use the following approach:
config :elixir_lokalise_api, api_token: {:system, "ENV_VARIABLE_NAME"}
Now you can perform API calls:
project_data = %{name: "Elixir", description: "Created via API"}
{:ok, project} = ElixirLokaliseApi.Projects.create(project_data)
project.name |> IO.puts # => "Elixir"
translation_data = %{
data: "ZnI6...",
filename: "sample.yml",
lang_iso: "en"
}
{:ok, process} = ElixirLokaliseApi.Files.upload(project.project_id, data)
{:ok, process} = QueuedProcesses.find(project.project_id, process.process_id)
process.status |> IO.puts # => "finished"