How does WordPress qTranslate work with JavaScript?

I use the plugin qTranslate in WordPress to change to the language of the website. Now, I have a form with some input fields. Each input has validation of the input data through Javascript. When there’s an error, of course, the message will show. By the default, my language is English. Now I want to add Japanese.

For example:

Read More
"Your field is required" <= English

"ここはデータが欲しいです" <= Japanese

The validation messages are controlled by Javascript. I tried [en:] and [ja:] or <--!en:--> and <--!ja:--> but was not successful.

So my question is: How can I control the language in Javascript with the qTranslate plugin?

Thank all!

Update:

I found the way to get the language in Javascript. When we change the language, the HTML tag will change the attribute lang="en" to lang="ja". Basically, I used:

    document.documentElement.lang=="en-US"

That will get the current language and your job is put it in the if condition.

    if(document.documentElement.lang=="en-US"){}

Hope it helps. Thanks all for reviewing it.

Related posts