WPML Localizing inside javascript

admin

Administrator
Staff member
Well, I have this javascript code in my multilanguage wordpress website's header.php:

Code:
<script language="JavaScript">
<!--
function calculateBmi() {
var weight = document.bmiForm.weight.value
var height = document.bmiForm.height.value
if(weight > 0 && height > 0){
var finalBmi = weight/(height/100*height/100)
document.bmiForm.bmi.value = finalBmi
if(finalBmi > 18.5 && finalBmi < 25){
document.bmiForm.meaning.value = "Normal weight."
}
if(finalBmi > 25 && finalBmi < 30){
document.bmiForm.meaning.value = "You have overweight."
}
if(finalBmi > 30 && finalBmi < 35){
document.bmiForm.meaning.value = "Overweight - I Stage."
}
if(finalBmi > 35 && finalBmi < 40){
document.bmiForm.meaning.value = "Overweight - II Stage."
}
if(finalBmi > 40) {
document.bmiForm.meaning.value = "Overweight - III Stage."
}
}
else{
alert("Please Fill in everything correctly")
}
}
//-->
</script>

And want to know how to translate it with WPML plugin.
Only these strings must be translated.

"Normal weight."
"You have overweight."
"Overweight - I Stage."
"Overweight - II Stage."
"Overweight - III Stage."

I asked on the official forum, but they are too slow for me.