0

I know that it may sound weird but please solve this.

I have a textbox and an autocomplete extender, I just need that when I type something in textbox then the auto fill options shall appear in hindi(other language) .

I know that I need to use some API, but I don't know How to achieve my goal . Please help.

string Text = txtbox1.Text;
        Text = Google.API.Translate.Translator.Translate(Text, Google.API.Translate.Language.English,
        Google.API.Translate.Language.Hindi);
        label1.Text = Text;

This is how I translate in Hindi and show in a label on click event but I need autofill options same as google provides. I've used google api translate for this

Thank You

  • Where does the data for your options comes from (database?) and how do you know which language is it on? Do you have your data in multiple languages, or do you need to call google translate for it (you added google-api tag)? Can you post a code you tried? – Fedor Hajdu Feb 24 '14 at 10:53
  • Please see the edits in the question – user1679776 Feb 24 '14 at 11:22
  • @FedorHajdu Sir I'm waiting for your response – user1679776 Feb 24 '14 at 11:40

1 Answers1

1

You need to send the request for translation from javascript, and get the results back as JSON (this should help: https://developers.google.com/translate/v2/using_rest). After that you need to assign the result to the autocomplete function, the code should be something like:

$('#textbox1').autocomplete({
    source: function (request, response) {
        $.getJSON("https://www.googleapis.com/language/translate/v2/languages?key" + request.term, function (data) {
            response($.map(data, function (value, key) {
                return { label: value, value: key
                };
            }));
        });
    },
    minLength: 3,
    delay: 25
});
Fedor Hajdu
  • 4,657
  • 3
  • 32
  • 50
  • tHANK yOU FOR YOUR REPLY, bUT YOUR CODE IS NOT VERY CLEAR TO ME, CAN YOU PLEASE EXPLAIN MORE ABOUT THE API KEY , VALUE &etc. What shoud I pass in the `https://www.googleapis.com/language/translate/v2/languages?key" + request.term, function (data)` – user1679776 Feb 25 '14 at 06:55