I have this line code:
$('#ss_account_submit').val('Create Account!');
So the .val() has a text within it. I wonder dow do I get to translate with qTranslate (WordPress plugin) a text within .js code like the line above:
The qTranslate allow to use quick shortcodes or regular shortcodes such as:
[:pt] For Brazilian Portuguese Language
[:en] For English Language
<!--:pt--><!--:--> For Brazilian Portuguese Language
<!--:en--><!--:--> For English Language
I tried a lot of things with my low knowledge in PHP/JS that didn’t work, such as:
$('#ss_account_submit').val('[:pt]Crie uma conta![:en]Create Account!');
$('#ss_account_submit').val('<--:pt-->Crie uma conta!<--:--><--:en-->Create Account!<--:pt-->');
$('#ss_account_submit').val __(('<--:pt-->Crie uma conta!<--:--><--:en-->Create Account!<--:pt-->'));
$('#ss_account_submit').val (<?php __('<--:pt-->Crie uma conta!<--:--><--:en-->Create Account!<--:pt-->') ?>);
Another way to make translation works is by using this kind of codes:
<?php echo __('<--:pt-->Crie uma conta!<--:--><--:en-->Create Account!<--:pt-->') ?>
OR
(__('[:pt]Crie uma conta![:en]Create Account!'))
Any idea what could work for this original line?
$('#ss_account_submit').val('Create Account!');
Your formatting looks a little off. Have you tried:
Note: that will not work inside a standard .js file.
Though its very late. But I see none answered it the right way.
When you are using
_()
or__()
orgettext()
or_e()
or_x()
or_ex()
or_n()
or_nx()
methods you are supposed to enclose only a single language inside it. See the full guide of i18nWhat the below line means is:
It would add the val in the current language of the site when executed.
You’d have to run a PoEdit on your template and get these lines with
__()
into the.po
and translate them.Alternatively,
You’d have to write conditional php section to select the right language.