Search code examples
phpapizend-frameworkgoogle-translation-api

Problem in Google Translater API


I am doing Language translation using Google Translater API.

Sometimes I am getting following error.

Fatal error: Uncaught GTranslateException: [0]: Unable to perform Translation:Suspected Terms of Service Abuse. Please see http://code.google.com/apis/errors thrown in C:\xampp\htdocs\MyProjectName\public\function\GTranslate.php on line 263

Can anybody help me to fix this problem.

Thanks in advance.

Kanji.


Solution

  • Sign up for a Google API key at https://code.google.com/apis/console/ and activate the Google Translate API. Use the provided key in your project.

    From the Google API Console page, follow on the traffic controls link on the left, then click the Configure Traffic Controls button. Increase the characters/second/user for Google Translate to something much larger than the default 100. Keep in mind you have a limit of 100,000 characters total per day.

    Edit: as mentioned in my comment, this is how you would set the API key.

    $apikey = 'xyz123';
    $gt = new Gtranslate();
    $gt->setApiKey($apikey);