Project

polylingo

0.0
The project is in a healthy, maintained state
Ruby client for the PolyLingo translation API (https://usepolylingo.com).
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 13.0
~> 3.12
~> 3.19
 Project Readme

polylingo (Ruby)

Ruby client for the PolyLingo translation API.

Requires Ruby 2.7+. Runtime dependencies: none (uses only the standard library).

Install

gem install polylingo

Or in your Gemfile:

gem "polylingo"

Quick start

require "polylingo"

client = PolyLingo.new(api_key: ENV.fetch("POLYLINGO_API_KEY"))
# Optional:
# client = PolyLingo.new(
#   api_key: ENV.fetch("POLYLINGO_API_KEY"),
#   base_url: "https://api.usepolylingo.com/v1",
#   timeout: 120, # seconds (open + read)
# )

result = client.translate(content: "# Hello", targets: %w[es fr], format: "markdown")
puts result["translations"]["es"]

API

Method Notes
client.health GET /health
client.languages GET /languages
client.translate(...) POST /translate
client.batch(...) POST /translate/batch
client.usage GET /usage
client.jobs.create(...) POST /jobs (202)
client.jobs.get(job_id) GET /jobs/:id
client.jobs.translate(...) Submit job, poll until done

client.jobs.translate options

All time values are in seconds (Ruby convention):

  • poll_interval — delay between polls (default: 5)
  • timeout — wall-clock limit for polling (default: 1200, 20 minutes)
  • on_progress — optional callable, e.g. ->(queue_position) { ... } (called while status is pending or processing)

Errors

  • PolyLingo::PolyLingoError — base class (#status, #error, #message)
  • PolyLingo::AuthError — HTTP 401
  • PolyLingo::RateLimitError — HTTP 429; optional #retry_after (integer seconds) from JSON retry_after or Retry-After header
  • PolyLingo::JobFailedError — failed job or polling timeout; #job_id set when known

Documentation

Ruby SDK on usepolylingo.com

Repository

github.com/UsePolyLingo/polylingo-ruby

License

MIT