google-cloud-translate 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +8 -1
- data/README.md +20 -11
- data/lib/google-cloud-translate.rb +2 -2
- data/lib/google/cloud/translate.rb +2 -205
- data/lib/google/cloud/translate/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20aedb79118d5f0746a0518fd9d62a707a0ee58f3538c4d8e50fe5868a92ca7c
|
4
|
+
data.tar.gz: 2df9d69ede2de2f7f0a6b206c44ca8d31849b91763af7c94283cd84723909488
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a5e0b020842c1e96dcd033c06c12e69e42b1f6c9fe894f31664fe3664683f5deaef4172239915f650bdf237c91167f3687d74d7c5991dc91b12edec53db3f69
|
7
|
+
data.tar.gz: af719e821badb9d811591774f41d62d84429e398592f8c6728d15102c33d76c84340d80e6f8ef5c3500382b18307835a41b61dcc0f4da95a08159df0209f093e
|
data/.yardopts
CHANGED
@@ -2,7 +2,14 @@
|
|
2
2
|
--title=Google Cloud Translation API
|
3
3
|
--markup markdown
|
4
4
|
--markup-provider redcarpet
|
5
|
+
--main OVERVIEW.md
|
5
6
|
|
6
7
|
./lib/**/*.rb
|
7
8
|
-
|
8
|
-
|
9
|
+
OVERVIEW.md
|
10
|
+
AUTHENTICATION.md
|
11
|
+
CONTRIBUTING.md
|
12
|
+
TROUBLESHOOTING.md
|
13
|
+
CHANGELOG.md
|
14
|
+
CODE_OF_CONDUCT.md
|
15
|
+
LICENSE
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
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.
|
6
6
|
|
7
|
-
- [google-cloud-translate API documentation](http://googlecloudplatform.github.io/google-cloud-ruby
|
7
|
+
- [google-cloud-translate API documentation](http://googlecloudplatform.github.io/google-cloud-ruby/docs/google-cloud-translate/latest)
|
8
8
|
- [google-cloud-translate on RubyGems](https://rubygems.org/gems/google-cloud-translate)
|
9
9
|
- [Google Cloud Translation API documentation](https://cloud.google.com/translation/docs)
|
10
10
|
|
@@ -21,7 +21,7 @@ authentication using a project ID and OAuth 2.0 credentials. In addition,
|
|
21
21
|
it supports authentication using a public API access key. (If both the API
|
22
22
|
key and the project and OAuth 2.0 credentials are provided, the API key
|
23
23
|
will be used.) Instructions and configuration options are covered in the
|
24
|
-
[Authentication Guide](https://googlecloudplatform.github.io/google-cloud-ruby
|
24
|
+
[Authentication Guide](https://googlecloudplatform.github.io/google-cloud-ruby/docs/google-cloud-translate/latest/file.AUTHENTICATION).
|
25
25
|
|
26
26
|
## Example
|
27
27
|
|
@@ -42,7 +42,7 @@ translation.text #=> "Salve mundi!"
|
|
42
42
|
|
43
43
|
## Enabling Logging
|
44
44
|
|
45
|
-
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
|
45
|
+
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.
|
46
46
|
|
47
47
|
Configuring a Ruby stdlib logger:
|
48
48
|
|
@@ -67,9 +67,9 @@ end
|
|
67
67
|
This library is supported on Ruby 2.3+.
|
68
68
|
|
69
69
|
Google provides official support for Ruby versions that are actively supported
|
70
|
-
by Ruby Core—that is, Ruby versions that are either in normal maintenance or
|
71
|
-
|
72
|
-
|
70
|
+
by Ruby Core—that is, Ruby versions that are either in normal maintenance or in
|
71
|
+
security maintenance, and not end of life. Currently, this means Ruby 2.3 and
|
72
|
+
later. Older versions of Ruby _may_ still work, but are unsupported and not
|
73
73
|
recommended. See https://www.ruby-lang.org/en/downloads/branches/ for details
|
74
74
|
about the Ruby support schedule.
|
75
75
|
|
@@ -81,15 +81,24 @@ This library follows [Semantic Versioning](http://semver.org/).
|
|
81
81
|
|
82
82
|
Contributions to this library are always welcome and highly encouraged.
|
83
83
|
|
84
|
-
See the [Contributing
|
84
|
+
See the [Contributing
|
85
|
+
Guide](https://googlecloudplatform.github.io/google-cloud-ruby/docs/google-cloud-translate/latest/file.CONTRIBUTING)
|
86
|
+
for more information on how to get started.
|
85
87
|
|
86
|
-
Please note that this project is released with a Contributor Code of Conduct. By
|
88
|
+
Please note that this project is released with a Contributor Code of Conduct. By
|
89
|
+
participating in this project you agree to abide by its terms. See [Code of
|
90
|
+
Conduct](https://googlecloudplatform.github.io/google-cloud-ruby/docs/google-cloud-translate/latest/file.CODE_OF_CONDUCT)
|
91
|
+
for more information.
|
87
92
|
|
88
93
|
## License
|
89
94
|
|
90
|
-
This library is licensed under Apache 2.0. Full license text is available in
|
95
|
+
This library is licensed under Apache 2.0. Full license text is available in
|
96
|
+
[LICENSE](https://googlecloudplatform.github.io/google-cloud-ruby/docs/google-cloud-translate/latest/file.LICENSE).
|
91
97
|
|
92
98
|
## Support
|
93
99
|
|
94
|
-
Please [report bugs at the project on
|
95
|
-
|
100
|
+
Please [report bugs at the project on
|
101
|
+
Github](https://github.com/GoogleCloudPlatform/google-cloud-ruby/issues). Don't
|
102
|
+
hesitate to [ask
|
103
|
+
questions](http://stackoverflow.com/questions/tagged/google-cloud-platform+ruby)
|
104
|
+
about the client or APIs on [StackOverflow](http://stackoverflow.com).
|
@@ -34,7 +34,7 @@ module Google
|
|
34
34
|
# it supports authentication using a public API access key. (If both the API
|
35
35
|
# key and the project and OAuth 2.0 credentials are provided, the API key
|
36
36
|
# will be used.) Instructions and configuration options are covered in the
|
37
|
-
#
|
37
|
+
# {file:AUTHENTICATION.md Authentication Guide}.
|
38
38
|
#
|
39
39
|
# @param [String] key a public API access key (not an OAuth 2.0 token)
|
40
40
|
# @param [String, Array<String>] scope The OAuth 2.0 scopes controlling the
|
@@ -87,7 +87,7 @@ module Google
|
|
87
87
|
# it supports authentication using a public API access key. (If both the API
|
88
88
|
# key and the project and OAuth 2.0 credentials are provided, the API key
|
89
89
|
# will be used.) Instructions and configuration options are covered in the
|
90
|
-
#
|
90
|
+
# {file:AUTHENTICATION.md Authentication Guide}.
|
91
91
|
#
|
92
92
|
# @param [String] key a public API access key (not an OAuth 2.0 token)
|
93
93
|
# @param [String] project_id Project identifier for the Cloud Translation
|
@@ -36,209 +36,7 @@ module Google
|
|
36
36
|
# with translated text back. You don't need to extract your source text or
|
37
37
|
# reassemble the translated content.
|
38
38
|
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
# Like other Cloud Platform services, Google Cloud Translation API supports
|
42
|
-
# authentication using a project ID and OAuth 2.0 credentials. In addition,
|
43
|
-
# it supports authentication using a public API access key. (If both the API
|
44
|
-
# key and the project and OAuth 2.0 credentials are provided, the API key
|
45
|
-
# will be used.) Instructions and configuration options are covered in the
|
46
|
-
# [Authentication Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-translate/guides/authentication).
|
47
|
-
#
|
48
|
-
# ## Enabling Logging
|
49
|
-
#
|
50
|
-
# To enable logging for this library, set the logger for the underlying
|
51
|
-
# [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library. The
|
52
|
-
# logger that you set may be a Ruby stdlib
|
53
|
-
# [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html)
|
54
|
-
# as shown below, or a
|
55
|
-
# [`Google::Cloud::Logging::Logger`](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/cloud/logging/logger)
|
56
|
-
# that will write logs to [Stackdriver
|
57
|
-
# Logging](https://cloud.google.com/logging/). See
|
58
|
-
# [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
|
59
|
-
# and the gRPC
|
60
|
-
# [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb)
|
61
|
-
# for additional information.
|
62
|
-
#
|
63
|
-
# Configuring a Ruby stdlib logger:
|
64
|
-
#
|
65
|
-
# ```ruby
|
66
|
-
# require "logger"
|
67
|
-
#
|
68
|
-
# module MyLogger
|
69
|
-
# LOGGER = Logger.new $stderr, level: Logger::WARN
|
70
|
-
# def logger
|
71
|
-
# LOGGER
|
72
|
-
# end
|
73
|
-
# end
|
74
|
-
#
|
75
|
-
# # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
|
76
|
-
# module GRPC
|
77
|
-
# extend MyLogger
|
78
|
-
# end
|
79
|
-
# ```
|
80
|
-
#
|
81
|
-
# ## Translating texts
|
82
|
-
#
|
83
|
-
# Translating text from one language to another is easy (and extremely
|
84
|
-
# fast.) The only required arguments to
|
85
|
-
# {Google::Cloud::Translate::Api#translate} are a string and the [ISO
|
86
|
-
# 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) code of the
|
87
|
-
# language to which you wish to translate.
|
88
|
-
#
|
89
|
-
# ```ruby
|
90
|
-
# require "google/cloud/translate"
|
91
|
-
#
|
92
|
-
# translate = Google::Cloud::Translate.new
|
93
|
-
#
|
94
|
-
# translation = translate.translate "Hello world!", to: "la"
|
95
|
-
#
|
96
|
-
# puts translation #=> Salve mundi!
|
97
|
-
#
|
98
|
-
# translation.from #=> "en"
|
99
|
-
# translation.origin #=> "Hello world!"
|
100
|
-
# translation.to #=> "la"
|
101
|
-
# translation.text #=> "Salve mundi!"
|
102
|
-
# ```
|
103
|
-
#
|
104
|
-
# You may want to use the `from` option to specify the language of the
|
105
|
-
# source text, as the following example illustrates. (Single words do not
|
106
|
-
# give Translation API much to work with.)
|
107
|
-
#
|
108
|
-
# ```ruby
|
109
|
-
# require "google/cloud/translate"
|
110
|
-
#
|
111
|
-
# translate = Google::Cloud::Translate.new
|
112
|
-
#
|
113
|
-
# translation = translate.translate "chat", to: "en"
|
114
|
-
#
|
115
|
-
# translation.detected? #=> true
|
116
|
-
# translation.from #=> "en"
|
117
|
-
# translation.text #=> "chat"
|
118
|
-
#
|
119
|
-
# translation = translate.translate "chat", from: "fr", to: "en"
|
120
|
-
#
|
121
|
-
# translation.detected? #=> false
|
122
|
-
# translation.from #=> "fr"
|
123
|
-
# translation.text #=> "cat"
|
124
|
-
# ```
|
125
|
-
#
|
126
|
-
# You can pass multiple texts to {Google::Cloud::Translate::Api#translate}.
|
127
|
-
#
|
128
|
-
# ```ruby
|
129
|
-
# require "google/cloud/translate"
|
130
|
-
#
|
131
|
-
# translate = Google::Cloud::Translate.new
|
132
|
-
#
|
133
|
-
# translations = translate.translate "chien", "chat", from: "fr", to: "en"
|
134
|
-
#
|
135
|
-
# translations.size #=> 2
|
136
|
-
# translations[0].origin #=> "chien"
|
137
|
-
# translations[0].text #=> "dog"
|
138
|
-
# translations[1].origin #=> "chat"
|
139
|
-
# translations[1].text #=> "cat"
|
140
|
-
# ```
|
141
|
-
#
|
142
|
-
# By default, any HTML in your source text will be preserved.
|
143
|
-
#
|
144
|
-
# ```ruby
|
145
|
-
# require "google/cloud/translate"
|
146
|
-
#
|
147
|
-
# translate = Google::Cloud::Translate.new
|
148
|
-
#
|
149
|
-
# translation = translate.translate "<strong>Hello</strong> world!",
|
150
|
-
# to: :la
|
151
|
-
# translation.text #=> "<strong>Salve</strong> mundi!"
|
152
|
-
# ```
|
153
|
-
#
|
154
|
-
# ## Detecting languages
|
155
|
-
#
|
156
|
-
# You can use {Google::Cloud::Translate::Api#detect} to see which language
|
157
|
-
# the Translation API ranks as the most likely source language for a text.
|
158
|
-
# The `confidence` score is a float value between `0` and `1`.
|
159
|
-
#
|
160
|
-
# ```ruby
|
161
|
-
# require "google/cloud/translate"
|
162
|
-
#
|
163
|
-
# translate = Google::Cloud::Translate.new
|
164
|
-
#
|
165
|
-
# detection = translate.detect "chat"
|
166
|
-
#
|
167
|
-
# detection.text #=> "chat"
|
168
|
-
# detection.language #=> "en"
|
169
|
-
# detection.confidence #=> 0.59922177
|
170
|
-
# ```
|
171
|
-
#
|
172
|
-
# You can pass multiple texts to {Google::Cloud::Translate::Api#detect}.
|
173
|
-
#
|
174
|
-
# ```ruby
|
175
|
-
# require "google/cloud/translate"
|
176
|
-
#
|
177
|
-
# translate = Google::Cloud::Translate.new
|
178
|
-
#
|
179
|
-
# detections = translate.detect "chien", "chat"
|
180
|
-
#
|
181
|
-
# detections.size #=> 2
|
182
|
-
# detections[0].text #=> "chien"
|
183
|
-
# detections[0].language #=> "fr"
|
184
|
-
# detections[0].confidence #=> 0.7109375
|
185
|
-
# detections[1].text #=> "chat"
|
186
|
-
# detections[1].language #=> "en"
|
187
|
-
# detections[1].confidence #=> 0.59922177
|
188
|
-
# ```
|
189
|
-
#
|
190
|
-
# ## Listing supported languages
|
191
|
-
#
|
192
|
-
# Translation API adds new languages frequently. You can use
|
193
|
-
# {Google::Cloud::Translate::Api#languages} to query the list of supported
|
194
|
-
# languages.
|
195
|
-
#
|
196
|
-
# ```ruby
|
197
|
-
# require "google/cloud/translate"
|
198
|
-
#
|
199
|
-
# translate = Google::Cloud::Translate.new
|
200
|
-
#
|
201
|
-
# languages = translate.languages
|
202
|
-
#
|
203
|
-
# languages.size #=> 104
|
204
|
-
# languages[0].code #=> "af"
|
205
|
-
# languages[0].name #=> nil
|
206
|
-
# ```
|
207
|
-
#
|
208
|
-
# To receive the names of the supported languages, as well as their [ISO
|
209
|
-
# 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) codes,
|
210
|
-
# provide the code for the language in which you wish to receive the names.
|
211
|
-
#
|
212
|
-
# ```ruby
|
213
|
-
# require "google/cloud/translate"
|
214
|
-
#
|
215
|
-
# translate = Google::Cloud::Translate.new
|
216
|
-
#
|
217
|
-
# languages = translate.languages "en"
|
218
|
-
#
|
219
|
-
# languages.size #=> 104
|
220
|
-
# languages[0].code #=> "af"
|
221
|
-
# languages[0].name #=> "Afrikaans"
|
222
|
-
# ```
|
223
|
-
#
|
224
|
-
# ## Configuring retries and timeout
|
225
|
-
#
|
226
|
-
# You can configure how many times API requests may be automatically
|
227
|
-
# retried. When an API request fails, the response will be inspected to see
|
228
|
-
# if the request meets criteria indicating that it may succeed on retry,
|
229
|
-
# such as `500` and `503` status codes or a specific internal error code
|
230
|
-
# such as `rateLimitExceeded`. If it meets the criteria, the request will be
|
231
|
-
# retried after a delay. If another error occurs, the delay will be
|
232
|
-
# increased before a subsequent attempt, until the `retries` limit is
|
233
|
-
# reached.
|
234
|
-
#
|
235
|
-
# You can also set the request `timeout` value in seconds.
|
236
|
-
#
|
237
|
-
# ```ruby
|
238
|
-
# require "google/cloud/translate"
|
239
|
-
#
|
240
|
-
# translate = Google::Cloud::Translate.new retries: 10, timeout: 120
|
241
|
-
# ```
|
39
|
+
# See {file:OVERVIEW.md Translation Overview}.
|
242
40
|
#
|
243
41
|
module Translate
|
244
42
|
##
|
@@ -250,8 +48,7 @@ module Google
|
|
250
48
|
# addition, it supports authentication using a public API access key. (If
|
251
49
|
# both the API key and the project and OAuth 2.0 credentials are provided,
|
252
50
|
# the API key will be used.) Instructions and configuration options are
|
253
|
-
# covered in the
|
254
|
-
# Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-translate/guides/authentication).
|
51
|
+
# covered in the {file:AUTHENTICATION.md Authentication Guide}.
|
255
52
|
#
|
256
53
|
# @param [String] project_id Project identifier for the Cloud Translation
|
257
54
|
# service you are connecting to. If not present, the default project for
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-cloud-translate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Moore
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-09-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: google-cloud-core
|
@@ -183,16 +183,16 @@ dependencies:
|
|
183
183
|
name: yard-doctest
|
184
184
|
requirement: !ruby/object:Gem::Requirement
|
185
185
|
requirements:
|
186
|
-
- - "
|
186
|
+
- - "~>"
|
187
187
|
- !ruby/object:Gem::Version
|
188
|
-
version: 0.1.
|
188
|
+
version: 0.1.13
|
189
189
|
type: :development
|
190
190
|
prerelease: false
|
191
191
|
version_requirements: !ruby/object:Gem::Requirement
|
192
192
|
requirements:
|
193
|
-
- - "
|
193
|
+
- - "~>"
|
194
194
|
- !ruby/object:Gem::Version
|
195
|
-
version: 0.1.
|
195
|
+
version: 0.1.13
|
196
196
|
description: google-cloud-translate is the official library for Google Cloud Translation
|
197
197
|
API.
|
198
198
|
email:
|