# google-cloud-translate [Google Cloud Translation API](https://cloud.google.com/translation/) ([docs](https://cloud.google.com/translation/docs)) provides a simple, programmatic interface for translating an arbitrary string into any supported language. It is highly responsive, so websites and applications can integrate with Translation API for fast, dynamic translation of source text. Language detection is also available in cases where the source language is unknown. Translation API supports more than one hundred different languages, from Afrikaans to Zulu. Used in combination, this enables translation between thousands of language pairs. Also, you can send in HTML and receive HTML with translated text back. You don't need to extract your source text or reassemble the translated content. - [google-cloud-translate API documentation](http://googlecloudplatform.github.io/google-cloud-ruby/docs/google-cloud-translate/latest) - [google-cloud-translate on RubyGems](https://rubygems.org/gems/google-cloud-translate) - [Google Cloud Translation API documentation](https://cloud.google.com/translation/docs) ## Quick Start ```sh $ gem install google-cloud-translate ``` ## Authentication Like other Cloud Platform services, Google Cloud Translation API supports authentication using a project ID and OAuth 2.0 credentials. In addition, it supports authentication using a public API access key. (If both the API key and the project and OAuth 2.0 credentials are provided, the API key will be used.) Instructions and configuration options are covered in the [Authentication Guide](https://googlecloudplatform.github.io/google-cloud-ruby/docs/google-cloud-translate/latest/file.AUTHENTICATION). ## Example ```ruby require "google/cloud/translate" translate = Google::Cloud::Translate.new translation = translate.translate "Hello world!", to: "la" puts translation #=> Salve mundi! translation.from #=> "en" translation.origin #=> "Hello world!" translation.to #=> "la" translation.text #=> "Salve mundi!" ``` ## Enabling Logging To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library. The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below, or a [`Google::Cloud::Logging::Logger`](https://googlecloudplatform.github.io/google-cloud-ruby/docs/google-cloud-logging/latest/Google/Cloud/Logging/Logger) that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb) and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information. Configuring a Ruby stdlib logger: ```ruby require "logger" module MyLogger LOGGER = Logger.new $stderr, level: Logger::WARN def logger LOGGER end end # Define a gRPC module-level logger method before grpc/logconfig.rb loads. module GRPC extend MyLogger end ``` ## Supported Ruby Versions This library is supported on Ruby 2.3+. Google provides official support for Ruby versions that are actively supported by Ruby Core—that is, Ruby versions that are either in normal maintenance or in security maintenance, and not end of life. Currently, this means Ruby 2.3 and later. Older versions of Ruby _may_ still work, but are unsupported and not recommended. See https://www.ruby-lang.org/en/downloads/branches/ for details about the Ruby support schedule. ## Versioning This library follows [Semantic Versioning](http://semver.org/). ## Contributing Contributions to this library are always welcome and highly encouraged. See the [Contributing Guide](https://googlecloudplatform.github.io/google-cloud-ruby/docs/google-cloud-translate/latest/file.CONTRIBUTING) for more information on how to get started. Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See [Code of Conduct](https://googlecloudplatform.github.io/google-cloud-ruby/docs/google-cloud-translate/latest/file.CODE_OF_CONDUCT) for more information. ## License This library is licensed under Apache 2.0. Full license text is available in [LICENSE](https://googlecloudplatform.github.io/google-cloud-ruby/docs/google-cloud-translate/latest/file.LICENSE). ## Support Please [report bugs at the project on Github](https://github.com/GoogleCloudPlatform/google-cloud-ruby/issues). Don't hesitate to [ask questions](http://stackoverflow.com/questions/tagged/google-cloud-platform+ruby) about the client or APIs on [StackOverflow](http://stackoverflow.com).