Click here to Skip to main content
13,097,012 members (81,136 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi I am Working on a multilingual Web application which is developed in 4.0 with C#. I am creating a resource file for each language in which i have to translate whole application. For this First i create a Main resource file in English Language. Now We Fetch Key value pair of Language.resx file and Translate value into desired language and insert this value in another resx file.(e.g. Language.hi.resx). For the conversion of value i am using Google Language translator API for each value of language.resx file and use following function to translate this value.

public static string TranslateText(string Text, string tragetlan, string sourceLang)
            LanguagesListResponse ls = new LanguagesListResponse();
            Google.Apis.Translate.v2.Data.LanguagesResource ss = new Google.Apis.Translate.v2.Data.LanguagesResource();
            ss.Language = tragetlan;
            // GetLanguageCode
            string googlekey = "Axxxxxxxxxxxxxxxxxxxxxxxxxxxxw";
            var service = new TranslateService(new BaseClientService.Initializer()
                ApiKey = googlekey
            //new TranslateService { Key = googlekey };
            ICollection<string> data = new Collection<string>();
            string[] srcText = new[] { Text };
            TranslationsListResponse response = service.Translations.List(srcText, tragetlan).Fetch();
            var translations = new List<string>();
            // We need to change this code...
            // currently this code 
            foreach (Google.Apis.Translate.v2.Data.TranslationsResource translation in response.Translations)
            return translations[0];
        catch (Exception ex)
            return Text;

Above function is Working fine for me, but for some values this function through an exception says "Google.Apis.Requests.RequestError Access Not Configured [403] The remote server returned an error: (403) Forbidden.". This Exception occur in random manner that means for same sentence (Value) it translate correctly in all languages but through exception for one or two languages. This problem is occur after 8-12 requests. Note : The Character length of my Input values are always less than 500 characters and this problem occur for all size sentences (i.e. Small 10-20 Characters and large 250-400 Characters) I am not sure why google API behaving like this.
Posted 24-Jun-13 1:06am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Increase quota of Google Translator API by increasing characters/second/user Limit.
Steps to go to this page:
1. Login to Google
2. Go to url :
3. Click on Quotas
4. Increase Translate API Quote Up to 100000

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170813.1 | Last Updated 14 Aug 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100