Good Morning,
I've the following problem :
I want to translate some page of my site using babelfish translator of
Altavista,
To avoid manual job I want to deliver a c# script that produce this
result.
I've putted this page on my site at the url
http://www.etantonio.it/EN/Economia/indexTest.aspx
////////////////////////////////////////////////////////
<html>
<title>Economy</title>
</head>
<body>
<p align="center">Economy</p>
</body>
</html>
////////////////////////////////////////////////////////
If I try to translate this using altavista, the result is directly
available at
the url http://babelfish.altavista.com/babelfish/trurl_pagecontent?doit=done&tt=url&intl
=1&lp=en_fr&url=http%3A%2F%2Fwww.etantonio.it%2Fen%2Feconomia%2FindexTest.aspx
and it's working OK, the translation of Economy in French is Économie
, the problem is in the first letter of Économie
, the É is not well recognized instead by the following my c# script
///////////////////////////////////////////////////////////////////////////////
<%@ Page Language="c#" debug="true" trace="true"
ResponseEncoding="utf-8"%>
<%@ import Namespace="System" %>
<%@ import Namespace="System.IO" %>
<%@ import Namespace="System.Net" %>
<script runat="server">
void Page_Load(Object Src, EventArgs E )
{
String sAddress =
"http://babelfish.altavista.com/babelfish/trurl_pagecontent?doit=done&tt=url&intl
=1&lp=en_fr&url=http%3A%2F%2Fwww.etantonio.it%2Fen%2Feconomia%2FindexTest.aspx"
;
WebRequest req = WebRequest.Create(sAddress);
WebResponse result = req.GetResponse();
Stream ReceiveStream = result.GetResponseStream();
StreamReader reader = new StreamReader(ReceiveStream, Encoding.UTF8
);
String sHtmlTradotto = reader.ReadToEnd();
Trace.Write("sHtmlTradotto", sHtmlTradotto);
}
</script>
///////////////////////////////////////////////////////////////////////////////
whose result is available at the url
http://www.etantonio.it/Utility/Traduzioni/TraduttoreAltavistaPaginaWebEnFrRidot
to.aspx
and basically shows that the É of Économie is blanked.
How can I solve the problem and finally obtain this translation ??
I think the problem is not in the code because if I use it for this
other address string
String sAddress =
"http://www.etantonio.it/Utility/Traduzioni/FR.aspx" ;
Can you help me ???
Many thanks in any case ...
Engineer Antonio D'Ottavio
www.etantonio.it/en
postmaster@etantonio.it
Marin [MS] - 29 Dec 2004 20:53 GMT
I kept getting an error on the WebRequest from Altavista, so I couldn't test
your code with this theory. However, I think the problem is that Altavista
is not returning the request in utf-8, which means that it's most likely
returning the in the ANSI encoding. So you're trying to interpret characters
from the ANSI encoding with utf-8, which won't work correctly. Try changing
the encoding like this:
Encoding enc = Encoding.GetEncoding("iso-8859-1");
StreamReader reader = new StreamReader(ReceiveStream, enc);
I think this should work. Now if this is the case, the encoding may change
with the language being return, which means that you will have to detect the
correct encoding for each language. You may be able to detect the encoding
by parsing WebResponse.ContentType, but you'll have to check what altavista
returns for this value.
Otherwise, you may have to check with Altavista to determine how they are
encoding their results.
Marin [MS]
> Good Morning,
> I've the following problem :
[quoted text clipped - 67 lines]
> www.etantonio.it/en
> postmaster@etantonio.it