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.
-
5Please post your exact problem, not demand. Thank you.Ali Gajani– Ali Gajani2014-06-06 06:09:26 +00:00Commented Jun 6, 2014 at 6:09
-
1Post 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.scunliffe– scunliffe2014-07-07 23:06:10 +00:00Commented 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.panofish– panofish2014-07-14 20:16:59 +00:00Commented Jul 14, 2014 at 20:16
-
1Possible duplicate of How to localize a simple HTML website page in my case?StardustGogeta– StardustGogeta2016-04-21 22:12:12 +00:00Commented Apr 21, 2016 at 22:12
-
1There 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.Anth12– Anth122016-11-08 14:05:18 +00:00Commented Nov 8, 2016 at 14:05
|
Show 1 more comment
1 Answer
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.