ultimatepp/bazaar/GoogleTranslator/GoogleTranslator.h
tojocky 39ed21b88e GoogleTranslator library + GUI example + simple console example
git-svn-id: svn://ultimatepp.org/upp/trunk@1245 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2009-05-29 21:07:52 +00:00

55 lines
No EOL
2.3 KiB
C++

#ifndef _GoogleTranslator_GoogleTranslator_h
#define _GoogleTranslator_GoogleTranslator_h
#include <Web/Web.h>
using namespace Upp;
class GoogleTranslator {
public:
typedef GoogleTranslator CLASSNAME;
GoogleTranslator();
//~GoogleTranslator();
bool Translate(Gate2<int, int> _progress = false);
bool Translate(String source_text, Gate2<int, int> _progress = false) {sourceText = source_text; return Translate(_progress);};
bool Translate(String source_text, String lang_from, Gate2<int, int> _progress = false) {sourceText = source_text; languageFrom = lang_from; return Translate(_progress);};
bool Translate(String source_text, String lang_from, String lang_to, Gate2<int, int> _progress = false) {sourceText = source_text; languageFrom = lang_from; languageTo = lang_to; return Translate(_progress);};
String GetLanguageFrom() {return languageFrom;};
String GetLanguageTo() {return languageTo;};
String GetSourceText() {return sourceText;};
String GetTranslatedText() {return translatedText;};
String GetFormatedText();
String GetCorrectionText() {return correctionText;};
String GetCorrectedText() {return correctedText;};
bool IsTranslated() {return isTranslated;}
bool SetCorrectionText(String correction_text, String& result_text, Gate2<int, int> _progress = false);
bool SetProxy(bool use_proxy) {return(useProxy = use_proxy);};
void SetProxy(String proxy_address, int port) {useProxy = true; proxyHTTPAddress = proxy_address; proxyHTTPPort = port;};
bool UseProxy() {return useProxy;}
String GetProxyAddress() {return proxyHTTPAddress;}
int GetproxyPort() {return proxyHTTPPort;}
private:
void refreshProxy();
bool sendHttpPost(String& url, String& post, String& result_text, Gate2<int, int> _progress = false);
String sourceText;
String translatedText;
String formatedText; // If I use many time GetFormatedText, the result is cashed in this property
String correctionText; // if is term get only first term, in other case is identic as sourcetranslatedtext
String correctedText;
String languageFrom;
String languageTo;
bool useProxy;
String proxyHTTPAddress;
int proxyHTTPPort;
bool isTranslated;
HttpClient httpClient;
};
// Need discuss about this and add in String or get core function
String replace_string (String& s1, String& find, String replace);
#endif