-1

Hey I was wondering if someone can help show me how to make a button to convert text from one language to another using a button? I commonly see this on many sites.

6
  • 5
    Please post your exact problem, not demand. Thank you. Commented Jun 6, 2014 at 6:09
  • 1
    Post what code you have so far. We can help you solve your programming question but we are not here to write the whole solution for you from scratch. Commented Jul 7, 2014 at 23:06
  • I always assumed that most sites simply build the multiple language versions of their site and depending on php or javascript... the button toggles the display to the appropriate version. Google / chrome provide a automatic text translator to your own language, but I wouldn't depend on that. Commented Jul 14, 2014 at 20:16
  • 1
    Possible duplicate of How to localize a simple HTML website page in my case? Commented Apr 21, 2016 at 22:12
  • 1
    There is no special html to convert your site into multiple language variants, the implementation of this is heavily dependent on the platform/programming language you use. If however you are looking for a simple 'plugin' that requires little effort have a look at translate.google.com/manager/website, it offers good translations but is by no means perfect. Commented Nov 8, 2016 at 14:05

1 Answer 1

-1

You can have two options of languages separated by different classes and have one of them visible at a time and the button will toggle the language, like this:

<script>
    let button = $("button");
    let toggleable = $(".toggleable");
    
    function toggle_lang() {
        toggleable.each(function(index, value) {
            value.text(translate(value.text()));
        });
    };
    button.click(toggle_lang());
</script>
<button type="button">Change Language</button>
<p class="toggleable">Hello</p>

Where translate() translates the text that it is given.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.