Crystal client for Glosbe API
Add this to your application's shard.yml
:
dependencies:
glosbe:
github: greyblake/crystal-glosbe
require "glosbe"
client = Glosbe::Client.new
# Translate a word from German to English
response = client.translate("de", "en", "Achtung", tm: true) # => #<Glosbe::TranslateResponse ... >
# Print translations
response.tuc.each do |translation|
puts translation.phrase.try(&.text)
end
# Print examples of usage
response.examples.each do |example|
puts example.first # sentence in German
puts example.second # translation in English
end
Please check Glosbe::Client and Glosbe API for more details.
Client methods may raise the following errors:
- Glosbe::Error
- Glosbe::HttpError
- Glosbe::ParseError
crystal spec
- greyblake Sergey Potapov - creator, maintainer