Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8785311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:19:15+00:00 2026-06-13T21:19:15+00:00

I need to translate the text in a textarea . when I press the

  • 0

I need to translate the text in a textarea. when I press the space key, an ajax request is made with the text in that field & then replaced by the response text.

But It would be better if I could just make an ajax request with the single word just before that space & then replace only that word by the response word. This way I could translate word by word & that’s exactly what I need.

Any ideas? Please share if you have any.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T21:19:16+00:00Added an answer on June 13, 2026 at 9:19 pm

    Function getLast returns the last word in the textarea

    function getLast(o) {
        return ("" + o).replace(/[\s-]+$/, '').split(/[\s-]/).pop();
    }
    

    If the spacebar is pressed (keyCode 32), then call the getLast function on the value of the textarea. Then make an AJAX call passing the last word as a variable.

    $('#textArea').keyup(function(e) {
        if (e.keyCode == 32) {
            var textArea = $('textArea');
            var word = getLast(textArea.val());
            $.ajax({
                type: "POST",
                url: "index.cfm?fuseaction=user.test2",
                data: {
                    currentWord: word
                }
            }).done(function(translation) {
                var translatedWord = $.trim(translation);
                var string = textArea.val();
                string = string.replace(word, translatedWord);
                textArea.val(string);
            });
        }
    });​
    

    I feel like your best bet would be to translate the entire textarea word by word at the end, however.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to translate some text & i am trying to use google translator
I need TextBlock.Text to be retrieved from translation manager, something like <TextBlock Text={Binding TranslateManager.Translate('word')}
I am needing translate parts of a text (in twig). Something like that: //
I need to make an HTTP request to get back translated text. If I
I have some text which I need to translate into Japanese. Translate text, webpage,
I have the following app.config section that I need to translate into code. I
I have a scrolling text line, and I need to achieve effect that immediately
I need to translate text in controller.body My code: controller.body = [NSString stringWithFormat:@\n\n Label
I need to translate what is commented within the method, to assembler. I have
I need to translate the a carbon method into cocoa into and I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.