Open GoogleCodeExporter opened 8 years ago
In the example for solution 3 above 5th line should read:
options.put("custom_translations", translations);
To implement solution 3) replace ReCaptchaImpl.fetchJSOptions implementation
with the following:
/**
* Produces javascript array with the RecaptchaOptions encoded.
*
* @param properties
* @return
*/
private String fetchJSOptions(Properties properties) {
if (properties == null || properties.size() == 0) {
return "";
}
StringBuffer jsOptions = new StringBuffer();
jsOptions.append("<script type=\"text/javascript\">\r\n" +
"var RecaptchaOptions = ");
appendDictionary(jsOptions, properties);
jsOptions.append(";\r\n</script>\r\n");
return jsOptions.toString();
}
/**
* Appends javascript dictionary representation of a Properties object to given StringBuffer
*
* @param jsOptions the target StringBuffer object.
* @param properties a Properties object.
*/
private void appendDictionary(StringBuffer jsOptions, Properties properties)
{
jsOptions.append("\r\n{");
for (Enumeration e = properties.keys(); e.hasMoreElements(); ) {
Object property = e.nextElement();
jsOptions.append((String)property).append(": ");
Object value = properties.get(property);
if(value instanceof Properties) {
appendDictionary(jsOptions, (Properties)value);
} else {
jsOptions.append("'").append(value).append("'");
}
if (e.hasMoreElements()) {
jsOptions.append(",\r\n");
}
}
jsOptions.append("}");
}
If you'd rather have it as a patch, let me know.
Original comment by rafal.kr...@gmail.com
on 3 Feb 2011 at 12:52
Original issue reported on code.google.com by
rafal.kr...@gmail.com
on 3 Feb 2011 at 12:06