U++ framework
Do not panic. Ask here before giving up.

Home » Extra libraries, Code snippets, applications etc. » Applications created with U++ » Google Translator
Google Translator [message #20392] Mon, 16 March 2009 13:06 Go to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

I was finished first variant of Google Translator in u++.
It seems nice... but i don't know how to resolve:
1. Problems with char encode, (for example when i translate from English to Russian)?
2. Set progress bar on execute http.
3. Integrate user suggestion to improve Google Translator Dictionary!

I can continue to develop:
1. Parse dictionary when i translate only an word.
2. Cash translated terms in xml file.
3. Languages icons.

I attached the source code of GoogleTranslator!

Any ideas is welcome!

[Updated on: Mon, 16 March 2009 13:19]

Report message to a moderator

Re: Google Translator [message #20419 is a reply to message #20392] Tue, 17 March 2009 22:54 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

I test Google translator on php and it work fine in utf8 encoding!
The function is (this php code is from here):
function translate($str, $from='en', $to='ru'){
	$fp = fsockopen("www.google.com", 80, $errno, $errstr, 30);
	if (!$fp) {
		trigger_error("$errstr ($errno) \n", E_USER_WARNING);
		return "";
	} else {
		$text = "text=".urlencode($str);
		$out = "POST /translate_a/t?client=t&sl=".$from."&tl=".$to." HTTP/1.1\r\n";
		$out .= "Host: www.google.com\r\n";
		$out .= "User-Agent: Mozilla/5.0\r\n";
		$out .= "Accept-Encoding: deflate\r\n";
		$out .= "Content-length: ".strlen($text)."\r\n";
		$out .= "Connection: Close\r\n\r\n";
		$out .= $text;
		
		fputs($fp, $out);
		$res = "";
		while (!feof($fp)) {
			$res .=  fgets($fp, 1024);
		}
		fclose($fp);
	}
	
	$res = explode("\r\n\r\n",$res);
	$res = explode("\r\n",$res[1]);
	return stripslashes(substr($res[1],1,-1));
}


Anybody can help what wrong I did in u++ that i get unknown char encoding?

[Updated on: Wed, 18 March 2009 11:45]

Report message to a moderator

Re: Google Translator [message #20425 is a reply to message #20419] Wed, 18 March 2009 10:00 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

The problem with char encoding is resolved! U++ works fine. The problem was in incomplete url address "&ie=utf-8&oe=utf-8";
Also i was corrected code when compile on linux (thanks to Andrei).

Remain how can I put the progress bar on execute http.

The current source is in attachment.
Re: Google Translator [message #20426 is a reply to message #20425] Wed, 18 March 2009 10:37 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
Depends on how you want it to work. First you should be running the Http request in a Thread so that you can still process Gui messages.

Normally to get a progress bar on an Http request you would just pass in a Gate (the Progress class has an operator for this) that the HttpClient uses to update the progress indicator. Remember to create the Gate outside of the Http thread or it won't work properly (I think).

In your case however, I don't think the amount of data you're recieving is actually large enough to make a progress bar work properly. It will do nothing until connection is established and then update and close almost immediately. I'd suggest faking it with a timer and a looping Progress indicator. Something like:

(Add to header)
	Progress progress;
	String result;
	volatile Atomic translating;

	enum {
		TIMEID_PROGRESS = Ctrl::TIMEID_COUNT,
		TIMEID_COUNT	
	};
	
	void HttpThread(String url, String post, Gate2<int, int> _progress);
	void UpdateProgress();
	bool CheckCancel(int, int);


Source:
void GoogleTranslator::TranslateText(){
	String from = inputwindow.fromlanguagectrl.GetKey(inputwindow.fromlanguagectrl.GetIndex());
	String to = inputwindow.tolanguagectrl.GetKey(inputwindow.tolanguagectrl.GetIndex());
	//... need to add proxy
	//http_client.Proxy("");
	String url = "www.google.com/translate_a/t?client=t&sl=" + from + "&tl=" + to;
	String post = String("text=") << inputwindow.textfrom.GetData();

	progress.Reset();
	progress.SetText("Contacting Google Translator");
	progress.Title("Translating");
	progress.Set(0, 50);
	
	AtomicWrite(translating, 1);
	SetTimeCallback(-200, THISBACK(UpdateProgress), TIMEID_PROGRESS);
	Thread().Run(THISBACK3(HttpThread, url, post, THISBACK(CheckCancel)));
	while(AtomicRead(translating)) {
		ProcessEvents();
		GuiSleep(300);
	}
	KillTimeCallback(TIMEID_PROGRESS);
	progress.Close();
	textto.Set(result, CHARSET_UTF8);	
}

void GoogleTranslator::UpdateProgress()
{
	int p = progress.GetPos() + 1;
	progress.Set((p > progress.GetTotal()) ? 0 : p, progress.GetTotal());
}

bool GoogleTranslator::CheckCancel(int, int)
{
	return progress.Canceled();
}

void GoogleTranslator::HttpThread(String url, String post, Gate2<int, int> _progress)
{
	HttpClient http_client;
	
	http_client.URL(url);
	//http_client.Agent("Mozilla/5.0");
	http_client.TimeoutMsecs(5000);
	http_client.Post();
	http_client.PostData(post);

	result = http_client.ExecuteRedirect(HttpClient::DEFAULT_MAX_REDIRECT, 
						HttpClient::DEFAULT_RETRIES, _progress);

	result = Nvl(result
		,String(", error:")<<Nvl(http_client.GetError(), "")
		<<", status: "<<http_client.GetStatusCode()<<", "<<http_client.GetStatusLine()
		<<", header: "<<http_client.GetHeaders());
	AtomicWrite(translating, 0);	
}
Re: Google Translator [message #20428 is a reply to message #20426] Wed, 18 March 2009 10:55 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

Thanks! Very useful example!
Maximum amount of data is 32kb. My goal is to understand how can i use progress bar! Thank you!

This example may be add in examples? From this example, new user can learn how to use http client, progress bar and a little threads.

ADD:
In attachment is source code with progress bar!

[Updated on: Wed, 18 March 2009 11:43]

Report message to a moderator

Re: Google Translator [message #21170 is a reply to message #20428] Wed, 06 May 2009 13:01 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1239
Registered: March 2006
Location: Italy
Senior Contributor
tojocky wrote on Wed, 18 March 2009 10:55

Thanks! Very useful example!
Maximum amount of data is 32kb. My goal is to understand how can i use progress bar! Thank you!



Hi,
I compiled your package and got the following error:

main.cpp
C:\MyApps\GoogleTranslator\main.cpp: In member function 'void GoogleTranslator::TranslateText()':
C:\MyApps\GoogleTranslator\main.cpp:80: error: no match for 'operator<<' in 'Upp::String(((const char*)"text=")) << Upp::UrlEncode(Upp::S
tring)()'
C:\upp20081\uppsrc/Web/html.h:224: note: candidates are: Upp::Htmls& Upp::operator<<(Upp::Htmls&, const char*)
C:\upp20081\uppsrc/Web/html.h:223: note: Upp::Htmls& Upp::operator<<(Upp::Htmls&, Upp::String)
C:\upp20081\uppsrc/Web/html.h:222: note: Upp::Htmls& Upp::operator<<(Upp::Htmls&, const Upp::Htmls&)
C:\upp20081\uppsrc/Web/html.h:221: note: Upp::Htmls& Upp::operator<<(Upp::Htmls&, const Upp::HtmlTag&)
C:\upp20081\uppsrc/CtrlCore/CtrlCore.h:1389: note: Upp::Ctrl* Upp::operator<<(Upp::Ctrl*, Upp::Ctrl&)
C:\upp20081\uppsrc/Core/Cbgen.h:850: note: Upp::Gate& Upp::operator<<(Upp::Gate&, Upp::Gate)
C:\upp20081\uppsrc/Core/Cbgen.h:108: note: Upp::Callback& Upp::operator<<(Upp::Callback&, Upp::Callback)
C:\upp20081\uppsrc/Core/Stream.h:611: note: Upp::Stream& Upp::operator<<(Upp::Stream&, void*)
C:\upp20081\uppsrc/Core/Stream.h:605: note: Upp::Stream& Upp::operator<<(Upp::Stream&, const void*)
C:\upp20081\uppsrc/Core/Stream.h:599: note: Upp::Stream& Upp::operator<<(Upp::Stream&, char)
C:\upp20081\uppsrc/Core/Stream.h:593: note: Upp::Stream& Upp::operator<<(Upp::Stream&, const Upp::String&)
C:\upp20081\uppsrc/Core/Stream.h:587: note: Upp::Stream& Upp::operator<<(Upp::Stream&, char*)
C:\upp20081\uppsrc/Core/Stream.h:581: note: Upp::Stream& Upp::operator<<(Upp::Stream&, const char*)
C:\upp20081\uppsrc/Core/String.h:518: note: Upp::StringBuffer& Upp::operator<<(Upp::StringBuffer&, void*)
C:\upp20081\uppsrc/Core/String.h:512: note: Upp::StringBuffer& Upp::operator<<(Upp::StringBuffer&, const void*)
C:\upp20081\uppsrc/Core/String.h:506: note: Upp::StringBuffer& Upp::operator<<(Upp::StringBuffer&, char)
C:\upp20081\uppsrc/Core/String.h:500: note: Upp::StringBuffer& Upp::operator<<(Upp::StringBuffer&, const Upp::String&)
C:\upp20081\uppsrc/Core/String.h:494: note: Upp::StringBuffer& Upp::operator<<(Upp::StringBuffer&, char*)
C:\upp20081\uppsrc/Core/String.h:488: note: Upp::StringBuffer& Upp::operator<<(Upp::StringBuffer&, const char*)
C:\upp20081\uppsrc/Core/String.h:434: note: Upp::String& Upp::operator<<(Upp::String&, void*)
C:\upp20081\uppsrc/Core/String.h:428: note: Upp::String& Upp::operator<<(Upp::String&, const void*)
C:\upp20081\uppsrc/Core/String.h:422: note: Upp::String& Upp::operator<<(Upp::String&, char)
C:\upp20081\uppsrc/Core/String.h:416: note: Upp::String& Upp::operator<<(Upp::String&, const Upp::String&)
C:\upp20081\uppsrc/Core/String.h:410: note: Upp::String& Upp::operator<<(Upp::String&, char*)
C:\upp20081\uppsrc/Core/String.h:404: note: Upp::String& Upp::operator<<(Upp::String&, const char*)
GoogleTranslator: 1 file(s) built in (0:03.34), 3344 msecs / file, duration = 3344 msecs

May it depend by the fact that I'm using the old 2008.1 and mingw?

Thanks,
Luigi
Re: Google Translator [message #21171 is a reply to message #21170] Wed, 06 May 2009 13:12 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
It's mingw. Using GCC/Mingw temporary variables are always 'const', and the << is a non-const operator.

Just change all the << operators to + and it will work (also in HttpThread)
Re: Google Translator [message #21176 is a reply to message #21171] Wed, 06 May 2009 20:22 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1239
Registered: March 2006
Location: Italy
Senior Contributor
mrjt wrote on Wed, 06 May 2009 13:12

It's mingw. Using GCC/Mingw temporary variables are always 'const', and the << is a non-const operator.

Just change all the << operators to + and it will work (also in HttpThread)


Thanks, now it works.
This is a very useful application much better than that offered by online site!

Luigi
Re: Google Translator [message #21180 is a reply to message #20392] Thu, 07 May 2009 01:10 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3460
Registered: August 2008
Senior Veteran
Hello tojocky

Nice example. I promise to use it.

One thing I have found is that if in the text to translate there are cr+lf, they are translated as '\' 'r' '\' 'n' letters instead of the cr = \r = ascii 13 and the same for \n.

Best regards
Koldo


Best regards
Iñaki
Re: Google Translator [message #21184 is a reply to message #21180] Thu, 07 May 2009 21:09 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

Sorry for my delay!
I was improve a little this project with the following changes:

- Add proxy settings (address and port)
- Changed main interface.
- Add possibility for show program in tray, close in tray, minimize in tray.
- Save and restore settings
- Integrate progress bar (many thanks to "mrjt")
- Show confirmation message box when exit from application.

I was attached the latest version!

In future I would like to add:
- Possibility for send to google corrected translation by user.
- Parse translated terms and other specific characters
- Handle global shortcut events for translation, as in Abby Lingvo
- Save and restore more settings, as: language from, language to, source text, destination text and other.
- Make multilingual interface!

If anybody have other ideas or want to contribute, I would be glad!


I do not know how can I handle global events (keyboard for shortcut, mouse)?
Can anybody help me?

[Updated on: Sat, 09 May 2009 22:10]

Report message to a moderator

Re: Google Translator [message #21450 is a reply to message #21184] Thu, 21 May 2009 10:56 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

Hello everyone!

I was improve a little this project with the following changes:

- Possibility for send to google corrected translation by user.
- Parse translated terms and other specific characters
- Handle global shortcut [Ctrl]+[C]+[C] events for translate copied text, as in Abby Lingvo (only for win32). In this case will translate in baloon from trayicon.
- Save and restore more settings, as: language from, language to, source text.
- Separated core google translate by GUI which named "GoogleTranslator" but demo package I named GoogleTranslatorDemo.
- Corrected errors on mingw and linux (ubuntu 9.04) GCC build
- Correct other errors.
- Added a simple console example to demonstrate google translator
#include <GoogleTranslator/GoogleTranslator.h>

using namespace Upp;

CONSOLE_APP_MAIN
{
	String str_status = "";
	GoogleTranslator g_instance;
	Cout() << "Set proxy: 172.16.0.65 , port 3128" << "\n";
	Cout() << "Translate \"translator\" word" << "\n";
	g_instance.SetProxy("172.16.0.65", 3128);
	if(g_instance.Translate("translator", String("en"), String("ro"))){
		Cout() << "Translation: " << g_instance.GetFormatedText() << "\n";
		if(g_instance.GetCorrectionText()!="translator"){
			Cout() << "Send corrected translator if not correct: \"translator\"" << "\n";
			if(g_instance.SetCorrectionText("translator", str_status))
				Cout() << str_status;
		}
	}
}


I was attached the latest version!

In future I would like to add:
- Multilingual interface!
- finish global shortcut for x11 and improve for win32.

Ballon message is only for win32, if somebody can add for x11 too I will be glad.

If anybody have other ideas or want to contribute, I would be glad!
Re: Google Translator [message #21471 is a reply to message #21450] Fri, 22 May 2009 00:36 Go to previous messageGo to next message
Mindtraveller is currently offline  Mindtraveller
Messages: 917
Registered: August 2007
Location: Russia, Moscow rgn.
Experienced Contributor

Excuse me for little offtopic, but I have found google translate client app is out:
http://googletranslateclient.com/googletranslateclient.exe
( discussion @ http://mokkey.habrahabr.ru/blog/60103/#comments )
so I recommend to discover it`s features and may be liberate some of them.
Re: Google Translator [message #21475 is a reply to message #21471] Fri, 22 May 2009 08:09 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

Mindtraveller wrote on Fri, 22 May 2009 01:36

Excuse me for little offtopic, but I have found google translate client app is out:
http://googletranslateclient.com/googletranslateclient.exe
( discussion @ http://mokkey.habrahabr.ru/blog/60103/#comments )
so I recommend to discover it`s features and may be liberate some of them.


Very nice!

Thanks, I will do!

But the main goal is to use GoogleTranslator class in other programs as source code, not only for general translate. For ex. it can be integrated in auto translate of interface.
Re: Google Translator [message #21499 is a reply to message #21475] Sat, 23 May 2009 08:48 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

Hello!

My last question about GoogleTranslator is:
Is need to add this package in bazaar or not?

Re: Google Translator [message #21507 is a reply to message #21499] Sat, 23 May 2009 12:41 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1239
Registered: March 2006
Location: Italy
Senior Contributor
tojocky wrote on Sat, 23 May 2009 08:48

Hello!

My last question about GoogleTranslator is:
Is need to add this package in bazaar or not?




I vote yes. I'm thinking to integrate it in my application if there are not license restriction.

Thank you,
Luigi
Re: Google Translator [message #21508 is a reply to message #21507] Sat, 23 May 2009 13:29 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

forlano wrote on Sat, 23 May 2009 13:41

tojocky wrote on Sat, 23 May 2009 08:48

Hello!

My last question about GoogleTranslator is:
Is need to add this package in bazaar or not?




I vote yes. I'm thinking to integrate it in my application if there are not license restriction.

Thank you,
Luigi


I didn't found any restriction about this!
Re: Google Translator [message #21564 is a reply to message #21508] Wed, 27 May 2009 08:40 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

OK, Is only one person is interested in GoogleTranslator to add in bazaar.
Mirek, is any reason to put this in bazaar?
Re: Google Translator [message #21565 is a reply to message #21564] Wed, 27 May 2009 09:17 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1428
Registered: September 2007
Ultimate Contributor
It is up to you to decide if you want to keep it in bazaar or just release on the forum. If you wish to put it in bazaar and you don't have write access to it, please pm Mirek and he may grant you the right.
Re: Google Translator [message #21573 is a reply to message #20392] Wed, 27 May 2009 21:04 Go to previous messageGo to next message
Didier is currently offline  Didier
Messages: 740
Registered: November 2008
Location: France
Contributor
Hi,

I think Google Translator can be very intersting.

For example how about creating a default translation for an app (if the language is not available ) by using Google Translator facility ?? Rolling Eyes

I don't time for this right now but some other person may have it in the future.

Re: Google Translator [message #21575 is a reply to message #21573] Wed, 27 May 2009 22:03 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3460
Registered: August 2008
Senior Veteran
Hello all

I also think it is interesting to have this technology available for all Upp users.

Best regards
Koldo


Best regards
Iñaki
Re: Google Translator [message #21580 is a reply to message #21565] Thu, 28 May 2009 10:10 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

cbpporter wrote on Wed, 27 May 2009 10:17

It is up to you to decide if you want to keep it in bazaar or just release on the forum. If you wish to put it in bazaar and you don't have write access to it, please pm Mirek and he may grant you the right.


I was released on the forum. and every time when I will change this I will release this.

I would like to put this in bazaar, in case if exist who interested in this!

Thank you for suggestion!
Re: Google Translator [message #21625 is a reply to message #21575] Sat, 30 May 2009 05:32 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

Hello All!

I'm happy to put GoogleTranslator in Bazaar svn version.

If is any propouses I'm glad to add in GoogleTranslator!

Have a nice day!
Re: Google Translator [message #21698 is a reply to message #21625] Mon, 01 June 2009 12:13 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3460
Registered: August 2008
Senior Veteran
Hello tojocky

GoogleTranslator works well for me without proxy, but with proxy it does not.

The program waits for about 10 seconds moving the progress bar in:

	result_text = httpClient.ExecuteRedirect(HttpClient::DEFAULT_MAX_REDIRECT, 
						HttpClient::DEFAULT_RETRIES, _progress);


And after that result_text is filled with

Quote:

Error: 171.20.1.44:808: connecting to host timed out,
status: 0,
header:


The proxy address is the same I use in Firefox and IExplorer.
The real port used is 8080 instead of 808, but if I put it the progress bar moves fast some tenths of second and the message I get in result_text is

Quote:

Error:HTTP/1.1 407 Proxy Authenti


Perhaps this problem is not due to GoogleTranslator but U++ http client. I cannot answer about this.

Best regards
Koldo


Best regards
Iñaki
Re: Google Translator [message #21700 is a reply to message #21698] Mon, 01 June 2009 12:59 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

koldo wrote on Mon, 01 June 2009 13:13

Hello tojocky

GoogleTranslator works well for me without proxy, but with proxy it does not.
..............
Perhaps this problem is not due to GoogleTranslator but U++ http client. I cannot answer about this.

Best regards
Koldo


I use not default port and proxy address and everything works fine!

Add:
Maybe you didn't check option "Use HTTP proxy" on the connection tab in options?

[Updated on: Mon, 01 June 2009 13:03]

Report message to a moderator

Re: Google Translator [message #21704 is a reply to message #21700] Mon, 01 June 2009 13:57 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3460
Registered: August 2008
Senior Veteran
Hello tojocky

The "Use HTTP proxy" option is checked.

With
Quote:

GoogleTranslator works well for me without proxy, but with proxy it does not.
I meant that running the program in a site without proxy, it works well, but if I use it in a site with a proxy it does not and I get the symptoms I have reported.

Any ideas?

Best regards
Koldo


Best regards
Iñaki
Re: Google Translator [message #21705 is a reply to message #21704] Mon, 01 June 2009 15:20 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

koldo wrote on Mon, 01 June 2009 14:57

Hello tojocky

The "Use HTTP proxy" option is checked.
.............
Any ideas?

Best regards
Koldo


Maybe in proxy server setting is:
1. username and password. I didn't implemented yet. But if is need I will add for you!
2. filter by specific protocols (ex: Mozila, IE or other)

Over Ideas I have not.

Ion Lupascu (tojocky)
Re: Google Translator [message #21707 is a reply to message #21705] Mon, 01 June 2009 16:42 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3460
Registered: August 2008
Senior Veteran
Hello Ion

I do not have any idea about proxy, but perhaps it is a matter of username and password. If you can implement it I will try it.

Best regards
Koldo


Best regards
Iñaki
Re: Google Translator [message #23847 is a reply to message #21707] Thu, 26 November 2009 10:48 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

koldo wrote on Mon, 01 June 2009 17:42

Hello Ion

I do not have any idea about proxy, but perhaps it is a matter of username and password. If you can implement it I will try it.

Best regards
Koldo


Hello Koldo,
Sorry for my delay.

I was finished with new release of GoogleTranslator.

I was attached the new release here. In evening I will upload in svn repository.

Please test user name and password. I didn't tested this.

Change log:

  • User name and password for proxy setting (in option form)
  • [Ctrl]+[C]+[C] shortcut works for linux too(thanks to Mirek). To show notify message of translatet text need to apply the patch from andrei_natanael(full address:http://www.ultimatepp.org/forum/index.php?t=msg& goto=23834&#msg_23823)
  • New languages for translate (total 80 languagies)
  • Translit method (non latin chars will write in latin chars).
  • Show translation without parsing. (option: "Do not parse translated text"). This option will show original translation text as "{"sentences":[{"trans":"écrivez ici le texte à traduire","orig":"write here text for translation","translit":""}],"src":"en"}"
  • Can translate from Unknown language.


[Updated on: Thu, 26 November 2009 10:51]

Report message to a moderator

Re: Google Translator [message #23850 is a reply to message #23847] Thu, 26 November 2009 14:21 Go to previous messageGo to next message
masu is currently offline  masu
Messages: 378
Registered: February 2006
Senior Member
Hello Ion,

thanks for the tool.
I have tried it in WinXP, compiled with MSC9.

I had to change declaration of 2nd function parameter of SetProxyAuth to String (it was int before).

What is not working correctly is translation for multi-line phrases. Translation always stops after first line.

Regards,
Matthias
Re: Google Translator [message #23857 is a reply to message #23850] Fri, 27 November 2009 09:53 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

masu wrote on Thu, 26 November 2009 15:21

Hello Ion,

thanks for the tool.
I have tried it in WinXP, compiled with MSC9.

I had to change declaration of 2nd function parameter of SetProxyAuth to String (it was int before).

What is not working correctly is translation for multi-line phrases. Translation always stops after first line.

Regards,
Matthias


Thank you Matthias for test.

I was attached the new version of GoogleTranslator with correction!
Can you test?

Regards,
Ion.

file deleted!

[Updated on: Fri, 27 November 2009 19:56]

Report message to a moderator

Re: Google Translator [message #23859 is a reply to message #23857] Fri, 27 November 2009 12:31 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3460
Registered: August 2008
Senior Veteran
Hello Ion

I have tried it under a proxy and I get this:

Quote:

Error:HTTP/1.1 407 Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. )
, status: 407, HTTP/1.1 407 Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. )
, header: Via: 1.1 BNT44
Proxy-Authenticate: Negotiate
Proxy-Authenticate: Kerberos
Proxy-Authenticate: NTLM
Connection: Keep-Alive
Proxy-Connection: Keep-Alive
Pragma: no-cache
Cache-Control: no-cache
Content-Type: text/html
Content-Length: 4112


In configuration I have entered the same proxy data I have in Firefox, that works well.

Perhaps I can try something to try to solve this. Could you give me some advice ?

Best regards
Koldo


Best regards
Iñaki
Re: Google Translator [message #23860 is a reply to message #23859] Fri, 27 November 2009 13:30 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

koldo wrote on Fri, 27 November 2009 13:31

Hello Ion

I have tried it under a proxy and I get this:

Quote:

Error:HTTP/1.1 407 Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. )
, status: 407, HTTP/1.1 407 Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. )
, header: Via: 1.1 BNT44
Proxy-Authenticate: Negotiate
Proxy-Authenticate: Kerberos
Proxy-Authenticate: NTLM
Connection: Keep-Alive
Proxy-Connection: Keep-Alive
Pragma: no-cache
Cache-Control: no-cache
Content-Type: text/html
Content-Length: 4112


In configuration I have entered the same proxy data I have in Firefox, that works well.

Perhaps I can try something to try to solve this. Could you give me some advice ?

Best regards
Koldo


Did you check the option "Use HTTP proxy"?
regards, Ion
Re: Google Translator [message #23861 is a reply to message #23860] Fri, 27 November 2009 14:05 Go to previous messageGo to next message
masu is currently offline  masu
Messages: 378
Registered: February 2006
Senior Member
Hello Ion,

it works like a charm now, thanks !

BTW, I also have to use a proxy ...

Regards,
Matthias
Re: Google Translator [message #23862 is a reply to message #23860] Fri, 27 November 2009 14:16 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3460
Registered: August 2008
Senior Veteran
tojocky wrote on Fri, 27 November 2009 13:30

koldo wrote on Fri, 27 November 2009 13:31

Hello Ion

I have tried it under a proxy and I get this:

Quote:

Error:HTTP/1.1 407 Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. )
, status: 407, HTTP/1.1 407 Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. )
, header: Via: 1.1 BNT44
Proxy-Authenticate: Negotiate
Proxy-Authenticate: Kerberos
Proxy-Authenticate: NTLM
Connection: Keep-Alive
Proxy-Connection: Keep-Alive
Pragma: no-cache
Cache-Control: no-cache
Content-Type: text/html
Content-Length: 4112


In configuration I have entered the same proxy data I have in Firefox, that works well.

Perhaps I can try something to try to solve this. Could you give me some advice ?

Best regards
Koldo


Did you check the option "Use HTTP proxy"?
regards, Ion



Hello Ion

Yes. I check "Use HTTP Proxy:" and "Use HTTP Proxy password:" and I fill "Address", "port", "Username" and "Password". This data is the same I use for Internet browser Firefox I use daily.

I have also debugged the program and it does what it seems it have to do. Any additional advice ?

Best regards
Koldo


Best regards
Iñaki
Re: Google Translator [message #23864 is a reply to message #23862] Fri, 27 November 2009 16:08 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

koldo wrote on Fri, 27 November 2009 15:16



Hello Ion

Yes. I check "Use HTTP Proxy:" and "Use HTTP Proxy password:" and I fill "Address", "port", "Username" and "Password". This data is the same I use for Internet browser Firefox I use daily.

I have also debugged the program and it does what it seems it have to do. Any additional advice ?

Best regards
Koldo


Hello Koldo,

Try this:
If it is web authorization, I thing that you need first login in Firefox, leave Firefox browser opened and try to translate with GoogleTranslator without option "Use HTTP Proxy password:".

Can you upload screenshots with your firefox proxy settings and user authentication?

Regards,
Ion.

P.S. I thing that your http proxy server do not filter by browser Agent from request packet data. Now the GoogleTranslator Agent is: "Ultimate++ HTTP clientUltimate++ HTTP client":
request << "Agent: " << Nvl(agent, "Ultimate++ HTTP client") << "\r\n";
Re: Google Translator [message #23865 is a reply to message #23864] Fri, 27 November 2009 19:53 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

Hello All!

I was changed a little my Google Translator.

Change log:
- in option form when I do not check option "Use HTTP Proxy" set disable proxy address, port, username, password.

Any other suggestions are welcome!

New to do to do item:
- Set in option form available languages and possibility user add new language. To find needed language in all 80 languages is too boring.

regards,
Ion.

[Updated on: Fri, 27 November 2009 19:54]

Report message to a moderator

Re: Google Translator [message #23877 is a reply to message #23864] Mon, 30 November 2009 08:50 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3460
Registered: August 2008
Senior Veteran
Hello Ion

No success doing this:
Quote:

Try this:
If it is web authorization, I thing that you need first login in Firefox, leave Firefox browser opened and try to translate with GoogleTranslator without option "Use HTTP Proxy password:".


I do not know what to do with this.

Quote:

P.S. I thing that your http proxy server do not filter by browser Agent from request packet data. Now the GoogleTranslator Agent is: "Ultimate++ HTTP clientUltimate++ HTTP client":
request << "Agent: " << Nvl(agent, "Ultimate++ HTTP client") << "\r\n";


Probably the problem does not come from Google Translator but from the U++ http support. Perhaps my proxy is tricky in any way so that Firefox is enough smart to pass it but not U++.

Best regards
Koldo


Best regards
Iñaki
Re: Google Translator [message #23885 is a reply to message #23877] Tue, 01 December 2009 08:27 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
While trying to compile to check the reported DocEdit bug:

u:\temp.src\googletranslator\GoogleTranslator.h(32) : error C2679: binary '=' : no operator found which takes a right-hand operand of type 'int' (or there is no acceptable conversio

(password parameter needs to be String)

[Updated on: Tue, 01 December 2009 08:29]

Report message to a moderator

Re: Google Translator [message #23972 is a reply to message #23885] Sun, 13 December 2009 10:40 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

luzr wrote on Tue, 01 December 2009 09:27

While trying to compile to check the reported DocEdit bug:

u:\temp.src\googletranslator\GoogleTranslator.h(32) : error C2679: binary '=' : no operator found which takes a right-hand operand of type 'int' (or there is no acceptable conversio

(password parameter needs to be String)

Thank you Mirek for found error.
Now I updated the latest version to svn! I tested your commend. it seems I already corrected this!
Re: Google Translator [message #24125 is a reply to message #23877] Sun, 27 December 2009 18:37 Go to previous messageGo to previous message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

koldo wrote on Mon, 30 November 2009 09:50

Hello Ion
Probably the problem does not come from Google Translator but from the U++ http support. Perhaps my proxy is tricky in any way so that Firefox is enough smart to pass it but not U++.

Best regards
Koldo

Can you put screenshot of your firefox settings?
Previous Topic: Open Source Project
Next Topic: Distance - geodesic - Vincenty - very accurate
Goto Forum:
  


Current Time: Wed Jun 03 14:49:49 GMT+2 2026

Total time taken to generate the page: 0.00974 seconds