我正在尝试使用reCAPTCHA.net的captcha服务,但是我想使用自定义翻译(https://developers.google.com/recaptcha/docs/customization#i18n),因为内置的翻译并不涵盖所有的语言。此外,我不想使用他们的标准主题之一,我想去完全定制,以匹配captcha的外观我的网站。
下面是我正在尝试的一个片段,但是由于一些有趣的原因,它不起作用(文本保留在英文中而不是翻译中)。我想知道像“获取另一个Captcha”、“获取音频Captcha”、“帮助”等文本链接是否会被翻译。如果我理解正确,这些应该根据我在custom_translations属性中设置的字符串进行转换。另外,如果我用图标而不是文本替换文本链接的内容,图标会自动获得带有适当内容的ALT标记吗?
因此,例如,如果我更改如下:
<div class="recaptcha_only_if_image"><a href="javascript:Recaptcha.switch_type('audio')">Get an audio CAPTCHA</a></div>
对此,图像的alt标记是否会自动填充,以便当您悬停在图标上时,它会说“获取音频captcha”吗?
<div class="recaptcha_only_if_image"><a href="javascript:Recaptcha.switch_type('audio')"><img height="16" width="16" src="audio.gif" alt="" /></a></div>
我问这个问题是因为当我试图选择一个标准主题时,比如‘主题:’红色‘,alt标签会根据语言自动翻译。
下面是我的代码片段。我已经把我的公钥从下面取走了。
JS
<script type="text/javascript">
var RecaptchaOptions = {
custom_translations : {
instructions_visual : "Scrivi le due parole:",
instructions_audio : "Trascrivi ci\u00f2 che senti:",
play_again : "Riascolta la traccia audio",
cant_hear_this : "Scarica la traccia in formato MP3",
visual_challenge : "Modalit\u00e0 visiva",
audio_challenge : "Modalit\u00e0 auditiva",
refresh_btn : "Chiedi due nuove parole",
help_btn : "Aiuto",
incorrect_try_again : "Scorretto. Riprova.",
},
lang : 'it', // Unavailable while writing this code (just for audio challenge)
theme : 'custom', // Make sure there is no trailing ',' at the end of the RecaptchaOptions dictionary
custom_theme_widget: 'recaptcha_widget'
};
</script>
<div id="recaptcha_widget" style="display:none">
<div id="recaptcha_image"></div>
<div class="recaptcha_only_if_incorrect_sol" style="color:red">Incorrect please try again</div>
<span class="recaptcha_only_if_image">Enter the words above:</span>
<span class="recaptcha_only_if_audio">Enter the numbers you hear:</span>
<input type="text" id="recaptcha_response_field" name="recaptcha_response_field" />
<div><a href="javascript:Recaptcha.reload()">Get another CAPTCHA</a></div>
<div class="recaptcha_only_if_image"><a href="javascript:Recaptcha.switch_type('audio')">Get an audio CAPTCHA</a></div>
<div class="recaptcha_only_if_audio"><a href="javascript:Recaptcha.switch_type('image')">Get an image CAPTCHA</a></div>
<div><a href="javascript:Recaptcha.showhelp()">Help</a></div>
</div>
<script type="text/javascript"
src="http://www.google.com/recaptcha/api/challenge?k=MY_PUBLIC_KEY">
</script>
<noscript>
<iframe src="http://www.google.com/recaptcha/api/noscript?k=MY_PUBLIC_KEY"
height="300" width="500" frameborder="0"></iframe><br>
<textarea name="recaptcha_challenge_field" rows="3" cols="40">
</textarea>
<input type="hidden" name="recaptcha_response_field"
value="manual_challenge">
</noscript>
我还附上了一个截图的结果。
发布于 2013-07-29 15:07:01
据我所知,如果使用自己的JavaScript模板,则不会使用JavaScript对象。在这种情况下,您将不得不使用您的应用程序使用的相同的本地化手动翻译。如果您不自己提供HTML,而是使用预定义的主题之一,则使用custom_translations
。
https://stackoverflow.com/questions/16101501
复制相似问题