File #ikehuw82-224 - C - Sourcecode

Uploaded by 0rb - 26/04/2009 14:08 - 1450 Views
Compare revisions
26/04/2009 - 14:08    1 - ikehuw82-224
20/12/2011 - 18:08      1.1 - znelct04-6275
Source code
  1. //googletranslate.inc
  2. //by 0rb (yom)
  3. //26-04-09 14:06
  4.  
  5. GoogleTranslate(text[], from[], to[], size = sizeof text)
  6. {
  7. 	new
  8. 		tmp[384],
  9. 		idx = -1,
  10. 		pos
  11. 	;
  12.  
  13. 	while (text[++idx])
  14. 	{
  15. 		switch (text[idx])
  16. 		{
  17. 			case ' ' : tmp[idx] = '+';
  18. 			default  : tmp[idx] = text[idx];
  19. 		}
  20. 	}
  21.  
  22. 	format(tmp, sizeof tmp, "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=%s&langpair=%s%%7C%s", tmp, from, to);
  23. 	pwncurl_get(tmp, tmp, sizeof tmp);
  24. 	pos = strfind(tmp,"ext\":\"");
  25.  
  26.  	if (pos != -1)
  27. 	{
  28. 		strdel(tmp, 0, pos + 6);
  29. 		strdel(tmp, strfind(tmp, "\"}, \"res"), sizeof tmp);
  30. 	}
  31. 	else
  32. 	{
  33. 		format(tmp, size, text);
  34. 	}
  35.  
  36. 	return tmp;
  37. }