Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Feb 19, 2022. It is now read-only.
This repository was archived by the owner on Feb 19, 2022. It is now read-only.

Can't use the Translate API #82

Copy link
Copy link

Description

@kanafghan
Issue body actions

The following does not work:

app.run(function (GApi) {
    // Load Google Translate Client Library
    GApi.load('translate', 'v2');
});

app.controller('FooCtrl', function(GApi) {
     var params = {}; 
     GApi.execute('translate', 'detections.list', params).then(function (result) {
         // ...
     });
});

The issue is that the Translate API is available as language under window.gapi.client and not as translate. The call to execute() method results in an error since the following is tried:

$window.gapi.client['translate'].detections.list.execute(params);

whereas $window.gapi.client['translate'] results to undefined.

My workaround has been as follows:

app.run(function (GApi, $window) {
    // Load Google Translate Client Library
    GApi.load('translate', 'v2').then(function (result) {
        // the API has been loaded successfully
        $window.gapi.client.translate = $window.gapi.client.language;
    });
});

This works nicely, but the library should take care of this case and not the client. I can start a PR on this if needed!?

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.