locked
asp.net google translate api RRS feed

  • Question

  • User318137752 posted

    Hi,
     
    I have developed a web
    application and now I want to integrate Google Translate Api,

     
    I am calling Google Translate API
    via :
     
    https://www.googleapis.com/language/translate/v2?key=
      
     
    and getting
    following string
     
     
    { "data": {"translations": [ { "translatedText": "नमस्ते अतिथि..." } ] } }
     
     
     
    I am interested in “नमस्ते अतिथि” only but getting above string
     
    Please anyone can direct me to
    the right direction?
     
    How can I integrate Google
    translate correctly,
     
     
     
    Regards

    Sunday, July 17, 2011 9:01 AM

All replies

  • User-484744148 posted

    Try this code.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Text.RegularExpressions;
    
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                string input = @"{ ""data"": {""translations"": [ { ""translatedText"": ""नमस्ते अतिथि..."" } ] } }";
                Regex regex = new Regex(@"\""[^""]*\""");
                Console.WriteLine(input);
                Console.WriteLine("Extracted");
                Console.WriteLine(regex.Matches(input)[3]);
                Console.ReadLine();
            }
        }
    }

    Regards,

    Sgt. 8log

    Sunday, July 17, 2011 11:07 AM