Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

translate: api updates #1781

Merged
merged 5 commits into from
Nov 14, 2016
Merged

translate: api updates #1781

merged 5 commits into from
Nov 14, 2016

Conversation

callmehiphop
Copy link
Contributor

@callmehiphop callmehiphop commented Nov 9, 2016

The most notable change with this request is that ap keys are no longer required and users can now authenticate in a similar fashion to our other APIs.

TODO

  • Docs
  • Unit tests
  • System tests
  • Support model parameter - this needs more discussion as it is a beta feature!

@callmehiphop callmehiphop added don't merge api: translate Issues related to the Cloud Translation API. labels Nov 9, 2016
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Nov 9, 2016
@callmehiphop
Copy link
Contributor Author

callmehiphop commented Nov 9, 2016

@stephenplusplus @jgeewax @omaray @bjwatson The thing I'm missing here is the model parameter, my understanding is that it is in beta and users will have to be whitelisted to use it. Do we want to cut a separate release to support this parameter?

It's just a string, so I think we could probably get away with just adding it here and making note that users need to be whitelisted to use it. WDYT?

@stephenplusplus
Copy link
Contributor

Can you link to any docs on what the model property is?

@callmehiphop
Copy link
Contributor Author

@stephenplusplus I'm not sure any exists yet :( but it would essentially just be a string that the user supplies.

@callmehiphop
Copy link
Contributor Author

Seeing an e2e failure, not sure if it's an actual error or not.

If we send the word Hello! to be translated into Spanish it comes back as ¡Hola!. (This is expected). However when we send the same text in the form of html <body>Hello!</body> we are returned <body>Hola!</body> (The ¡ is no longer present).

@bjwatson
Copy link

bjwatson commented Nov 9, 2016

@callmehiphop I've pinged @akeran to see if he has any thoughts on that behavior.

@akeran
Copy link

akeran commented Nov 9, 2016

If you set format=html you will get "\u003cbody\u003e ¡Hola! \u003c/body\u003e"
html is the default value for this API, please check that you don't overwrite it to format=text

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling b1c0d25 on callmehiphop:translate-updates into 116436f on GoogleCloudPlatform:master.

@stephenplusplus
Copy link
Contributor

Seeing an e2e failure, not sure if it's an actual error or not.

Which test? should autodetect HTML returns what I would expect:

<body> ¡Hola! </body>

@callmehiphop
Copy link
Contributor Author

@akeran the assertion we made actually included the html tags wrapping the content - however, it would appear the issue I was seeing disappeared at some point in the night!

@@ -312,6 +312,9 @@ Translate.prototype.getLanguages = function(target, callback) {
* is written in.
* @param {string} options.to - The ISO 639-1 language code to translate the
* input to.
* @param {string} options.model - **Note:** Users must be whitelisted to use

This comment was marked as spam.

This comment was marked as spam.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling b1d2392 on callmehiphop:translate-updates into 116436f on GoogleCloudPlatform:master.

It's also possible to authenticate with an API key. To create an API key:

1. Visit the [Google Developers Console][dev-console].
2. 2. Create a new project or click on an existing project.

This comment was marked as spam.

This comment was marked as spam.

@@ -305,6 +312,9 @@ Translate.prototype.getLanguages = function(target, callback) {
* is written in.
* @param {string} options.to - The ISO 639-1 language code to translate the
* input to.
* @param {string} options.model - **Note:** Users must be whitelisted to use

This comment was marked as spam.

This comment was marked as spam.

}

var translate = new Translate(extend({}, env, { key: API_KEY }));
describe('translate', function() {

This comment was marked as spam.

This comment was marked as spam.

@@ -38,9 +42,16 @@ var fakeUtil = extend({}, util, {
}
});

function FakeService() {
this.calledWith_ = arguments;
Service.apply(this, arguments);

This comment was marked as spam.

This comment was marked as spam.

});

it('should localize the api key', function() {
assert.equal(translate.key, KEY_OPTIONS.key);

This comment was marked as spam.

This comment was marked as spam.

}, /An API key is required to use the Translate API\./);
});
it('should inherit from Service', function() {
assert(translate instanceof Service);

This comment was marked as spam.

This comment was marked as spam.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 023359d on callmehiphop:translate-updates into * on GoogleCloudPlatform:master*.

baseUrl: baseUrl,
scopes: ['https://www.googleapis.com/auth/cloud-platform'],
packageJson: require('../package.json'),
projectIdRequired: false

This comment was marked as spam.

This comment was marked as spam.

@@ -303,6 +310,9 @@ Translate.prototype.getLanguages = function(target, callback) {
* not, we set the format as `text`.
* @param {string} options.from - The ISO 639-1 language code the source input
* is written in.
* @param {string} options.model - **Note:** Users must be whitelisted to use
* this parameter. Set the model type requested for this translation. Please
* refer to the upstread documentation for possible values.

This comment was marked as spam.

This comment was marked as spam.

@@ -381,16 +391,20 @@ Translate.prototype.translate = function(input, options, callback) {
if (options.to) {
query.target = options.to;
}

if (options.model) {
query.model = options.model;

This comment was marked as spam.

This comment was marked as spam.

a: 'b',
c: 'd',
qs: {
beforeEach(function() {

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling b68c187 on callmehiphop:translate-updates into * on GoogleCloudPlatform:master*.

@stephenplusplus stephenplusplus removed their assignment Nov 14, 2016
@stephenplusplus
Copy link
Contributor

Please re-assign if it needs another look.

@stephenplusplus stephenplusplus merged commit 6e9ae57 into googleapis:master Nov 14, 2016
sofisl pushed a commit that referenced this pull request Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: translate Issues related to the Cloud Translation API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants