Language translation is not working in FireFox 3

32 visninger
Gå til det første ulæste opslag

Tapas

ulæst,
25. aug. 2008, 08.17.1425.08.2008
til Google AJAX API
The piece of code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/
>
<title>Google AJAX Language API - Basic Translation</title>
<script type="text/javascript" src="http://www.google.com/jsapi"></
script>
<script type="text/javascript">

google.load("language", "1");

function initialize() {
google.language.translate("Hello world", "en", "es",
function(result) {
if (!result.error) {
var container = document.getElementById("translation");
container.innerHTML = result.translation;
}
});
}
//google.setOnLoadCallback(initialize);

</script>
</head>

<body onload="javascript:initialize();">
<div id="translation"></div>
</body>
</html>

is not working in FireFox 3.0 but it works on IE7. I want to use this
code over all major browser. Please help

Zvonko

ulæst,
26. aug. 2008, 04.11.2226.08.2008
til Google AJAX API
Is it me or you are missing '>' at the end of this line:

<meta http-equiv="content-type" content="text/html; charset=utf-8"/

Zvonko

Zvonko

ulæst,
26. aug. 2008, 04.15.3326.08.2008
til Google AJAX API
OK. I tried this version:
And it worked all right in FF2, FF3 and IE7, IE6.


On Aug 25, 2:17 pm, Tapas <tapasdutta2...@gmail.com> wrote:

Tapas Kumar Dutta

ulæst,
26. aug. 2008, 12.16.0526.08.2008
til Google-AJAX...@googlegroups.com
Thanks Zvonko for your help.

Ben Lisbakken

ulæst,
26. aug. 2008, 13.08.3226.08.2008
til Google-AJAX...@googlegroups.com
Also, your onload is = "javascript:", you can just do onload="initialize();"

-Ben

Asset

ulæst,
27. aug. 2008, 16.03.4327.08.2008
til Google AJAX API
http://www.mediawiki.org/wiki/Extension:GoogleTranslate will do the
trick for you, But for some reason running this in IE removes the line
breaks. I may well be that the detection of \n does not work in IE?

jgeerdes [AJAX APIs "Guru"]

ulæst,
27. aug. 2008, 16.40.5327.08.2008
til Google AJAX API
More likely than IE not recognizing \n, Windows uses a totally
different end of line character. You'll want to account for that.

Jeremy R. Geerdes
Effective website design & development
Des Moines, IA

For more information or a project quote:
http://jgeerdes.home.mchsi.com
jgee...@mchsi.com

If you're in the Des Moines, IA, area, check out Debra Heights
Wesleyan Church!

Balazs Endresz

ulæst,
28. aug. 2008, 03.44.2328.08.2008
til Google AJAX API
Hi! I read your code but since you are using the default content type
(html) linebreaks are removed during translation.
Have you tried this way?
google.language.translate( {text: 'new\nline', type: 'text'},
'en', 'de', function(r){
console.log(r.translation)
})

Btw here's a regex from the jQuery Translate plugin that breaks a 500
char long text on the last html tag or at the end of a sentence:
This won't break on a new line but you can extend it after these: \.\?
\!;:

var text1=substring(start, start+500)

var match1=/<(?![^<]*>)/.exec(text1);
if(!match1){//if no broken tag present
var match2=/>\s*$/.exec(text1);
if(!match2){//if doesn't end with '>'
var match3=/[\.\?\!;:](?![^\.\?\!;:]*[\.\?\!;:])/.exec(text1);
if(match3){//if broken sentence present
var match4=/>(?![^>]*<)/.exec(text1);
if(match4){
if(match3.index > match4.index){
text2=text1.substring(0, match3.index+1);
}else text2=text1.substring(0, match4.index+1);
}else text2=text1.substring(0, match3.index+1);
}else text2=text1;
}else text2=text1;
}else text2=text1.substring(0, match1.index);

http://code.google.com/p/jquery-translate/

On Aug 27, 10:03 pm, Asset <as...@asset.dk> wrote:
> http://www.mediawiki.org/wiki/Extension:GoogleTranslatewill do the

Asset

ulæst,
30. aug. 2008, 02.17.0430.08.2008
til Google AJAX API
Thanks Jeremy

On 27 Aug., 22:40, "jgeerdes [AJAX APIs \"Guru\"]"
<jgeer...@mchsi.com> wrote:
> More likely than IE not recognizing \n, Windows uses a totally
> different end of line character.  You'll want to account for that.

Well I'm running FF under Windows, and the code works under FF, while
not under IE or IE-Tab (addon to firefox).
So somehow I need to detect IE, and distinguish/identify/handle the
line break. Tied to use FireBug, but it wont work under IE-tab :( -
ant I'm now trying to ude MS Script Debugger, but is a long way to go
to do a simple task. ....

I would think that this is a rather trivial task - something that
everybody doing anything with texts handle??
Regards Per

Asset

ulæst,
30. aug. 2008, 03.40.5230.08.2008
til Google AJAX API
Thanks Balazs

as you can see I try to do something very similar - with this code:

function nextStop(text) {
var pos = text.length;
var pos2 = text.indexOf(".");
if (pos2 > 0 && pos >pos2) { pos = pos2 +
1}; // lastPos is the netx
Sentence stats
var pos2 = text.indexOf("!");
if (pos2 > 0 && pos >pos2) { pos = pos2 + 1};
var pos2 = text.indexOf("?");
if (pos2 > 0 && pos >pos2) { pos = pos2 + 1};
var pos2 = text.indexOf("\n");
if (pos2 > 0 && pos >pos2) { pos = pos2};

if (pos == 0) { pos = text.length };

return pos;

}

I thus try to narrow down to a clean snip of text and replaces this
snip with var myX = x.replace(str,result.translation);

I would simply try to bypass any HTML, line-breaks etc in the final
code, but for some reason the replace seems to corrupted when this is
done in IE.

I found this http://www.w3schools.com/jsref/jsref_regexp_modifier_newline.asp
- that says that you need to set the \n like this:

var str = "Visit W3Schools.\n Learn JavaScript.";
var patt1 = /\n/;
var result = str.search(patt1);
document.write("Match at: " + result);

Changing my code to use patt1 and search still works fine in FF but
not in IE... strange....

Regards Per

Balazs Endresz

ulæst,
30. aug. 2008, 09.40.5030.08.2008
til Google AJAX API
Firebug lite seems to have some problems with ietab, but you can also
use this: http://www.my-debugbar.com/wiki/IETester/HomePage
Though it's pretty strange that \n search doesn't work for you, I
tried it in IE 6 and 7, for me it works as it should.

On Aug 30, 9:40 am, Asset <as...@asset.dk> wrote:
> Thanks Balazs
>
> as you can see I try to do something very similar - with this code:
>
> function nextStop(text) {
>          var pos = text.length;
>          var pos2 = text.indexOf(".");
>          if (pos2 > 0 && pos >pos2) { pos = pos2 +
> 1};                                       // lastPos is the netx
> Sentence stats
>          var pos2 = text.indexOf("!");
>          if (pos2 > 0 && pos >pos2) { pos = pos2 + 1};
>          var pos2 = text.indexOf("?");
>          if (pos2 > 0 && pos >pos2) { pos = pos2 + 1};
>          var pos2 = text.indexOf("\n");
>          if (pos2 > 0 && pos >pos2) { pos = pos2};
>
>          if (pos == 0) { pos = text.length };
>
>    return pos;
>
> }
>
> I thus try to narrow down to a clean snip of text and replaces this
> snip with var myX = x.replace(str,result.translation);
>
> I would simply try to bypass any HTML, line-breaks etc in the final
> code, but for some reason the replace seems to corrupted when this is
> done in IE.
>
> I found thishttp://www.w3schools.com/jsref/jsref_regexp_modifier_newline.asp

Asset

ulæst,
31. aug. 2008, 08.13.2531.08.2008
til Google AJAX API
Thanks again,

I tried to install IETester/debugbar and the companion.js, and even
the MS Script Debugger, but apparently the developers of these tools
"forgot" how to write documentation? From what I can see debugbar
allows me to inspect the contents of the webpages, but I need to see
the code executing (like in FireBug) - I wonder how you guys get
anything done without it?

After installing Script Debugger from MS I was simply unable to locate
any good documentation what so ever on the MS site?? And after reading
the debugbar webpages several times I conclude that it is not possible
to put in breakpoint in the code?

Summing up, I would need to add console.log(whatever) to get some idea
of what is going on in my JS code?

Regards Per

Asset

ulæst,
31. aug. 2008, 08.36.5431.08.2008
til Google AJAX API
Hi
I just found this tool: http://www.ieinspector.com/scriptdebugger/download.html
and it seems to do what is needed.
Will get back when I figure the bug :)
Regards Per

jgeerdes [AJAX APIs "Guru"]

ulæst,
2. sep. 2008, 07.15.2302.09.2008
til Google AJAX API
Isn't debugging in IE a bundle of joy? At any rate, could you please
post a link to the page you're trying to debug so we can check it out
for ourselves. If you can't post a link, please post the complete
application code to a pasting service such as paste-it.net.

Asset

ulæst,
2. sep. 2008, 08.47.0202.09.2008
til Google AJAX API
Thanks a bunch
You can see the code here: http://www.mediawiki.org/w/index.php?title=Extension:GoogleTranslate
- this is working for FireFox, but not IE.

From what I can see via a very quick debug, the problem may well be
this statement var text =
document.getElementById("wpTextbox1").innerHTML;
While FF delivers '\n' as the line break, the IE debugger shows a
graphical character in this fields when I look at them in the
debuggers.....

Regarding you debugging, the Wiki I am working on contains copyrighted
texts, but I will attempt to open up for a special page for you to
access. This can be done tonight (2-4 hours).

Regards Per


On Sep 2, 1:15 pm, "jgeerdes [AJAX APIs \"Guru\"]"
<jgeer...@mchsi.com> wrote:
> Isn't debugging in IE a bundle of joy?  At any rate, could you please
> post a link to the page you're trying to debug so we can check it out
> for ourselves.  If you can't post a link, please post the complete
> application code to a pasting service such as paste-it.net.
>
> Jeremy R. Geerdes
> Effective website design & development
> Des Moines, IA
>
> For more information or a project quote:http://jgeerdes.home.mchsi.com
> jgeer...@mchsi.com

Asset

ulæst,
4. sep. 2008, 17.07.4604.09.2008
til Google AJAX API
Hi

Sorry for the delay, there have been some other tasks to look at. Any
way anyone should be able to trace this code:
http://forskelsproduktion.dk/wiki/index.php?title=Play:Translate_test

Please note that I have changed it a bit since the post on mediawiki.

Regards Per

On 2 Sep., 13:15, "jgeerdes [AJAX APIs \"Guru\"]" <jgeer...@mchsi.com>
wrote:
> Isn't debugging in IE a bundle of joy?  At any rate, could you please
> post a link to the page you're trying to debug so we can check it out
> for ourselves.  If you can't post a link, please post the complete
> application code to a pasting service such as paste-it.net.
>
> Jeremy R. Geerdes
> Effective website design & development
> Des Moines, IA
>
> For more information or a project quote:http://jgeerdes.home.mchsi.com
> jgeer...@mchsi.com

Asset

ulæst,
4. sep. 2008, 17.49.3804.09.2008
til Google AJAX API

Ben Lisbakken

ulæst,
5. sep. 2008, 11.35.2305.09.2008
til Google-AJAX...@googlegroups.com
Hey Asset --

Thanks for the links.  Are you still having IE problems with it?

-Ben

Asset

ulæst,
5. sep. 2008, 15.46.5705.09.2008
til Google AJAX API
Yes still problems! Very frustrating. FF works just fine, but in IE
the detection of linebreaks does not work at all. Somehow the text
string is not the same in the two. (Sadly because the target users are
probably using IE.)

You should be able to use the links - first one you can use 'redigér'
to start the edit, and then press Oversaet and then click on 'klik her
for at oversætte nu' to start the process. (curently this is in
danish only).

regards Per
> >http://forskelsproduktion.dk/wiki/index.php?title=Play:Translate_test...

Asset

ulæst,
8. sep. 2008, 07.31.4108.09.2008
til Google AJAX API
Sorry - the DNS is not working right now for unknown reasons. I will
report back here when it works again!

Asset

ulæst,
10. sep. 2008, 10.53.0110.09.2008
til Google AJAX API
Now this link works - so you should be abel to test/trace the
translation:

http://www.forskelsproduktion.dk/wiki/index.php?title=Play:Translate_test

Asset

ulæst,
10. sep. 2008, 10.53.1510.09.2008
til Google AJAX API
Now this link works - so you should be abel to test/trace the
translation:

http://www.forskelsproduktion.dk/wiki/index.php?title=Play:Translate_test


On 8 Sep., 13:31, Asset <as...@asset.dk> wrote:

Ben Lisbakken

ulæst,
10. sep. 2008, 13.57.3810.09.2008
til Google-AJAX...@googlegroups.com
Asset --

I see your problem, and I would agree that it seems like your splitting of text is not working correctly.  I'm sorry to say, though, that I don't know what the answer is.  Are you doing the translation on the server, or in Javascript?  If you're doing it on the server, you might as well split up the text there.

-Ben

Asset

ulæst,
10. sep. 2008, 15.50.5310.09.2008
til Google AJAX API
Hi Ben
I use JS code to do this. That is it runs as part of the mediawiki
extension. The code for this can be see below, where I have tried to
use various approaches to detect the line space. What puzzle me is
that EVERBODY aught to have problems like this.... so I would supect
that there is a common solution????
Regards Per
p.s. I dont know where this happens :-), but I expect that it happens
on your PC, when you do it.

This is one snipp of code that works in FF, but not in IE....:

// function returns the next full stop position in a string
function nextStop(text) {
var pos = text.length;
var pos2 = text.indexOf(".");
if (pos2 > 0 && pos >pos2) { pos = pos2 +
1};
var pos2 = text.indexOf("!");
if (pos2 > 0 && pos >pos2) { pos = pos2 + 1};
var pos2 = text.indexOf("?");
if (pos2 > 0 && pos >pos2) { pos = pos2 + 1};

var patt1 = /\x10/;
var pos2 = text.search(patt1);
if (pos2 > 0 && pos >pos2) { pos = pos2};

var patt1 = /\x13/;
var pos2 = text.search(patt1);
if (pos2 > 0 && pos >pos2) { pos = pos2};

var patt1 = /\n/;
var pos2 = text.search(patt1);
if (pos2 > 0 && pos >pos2) { pos = pos2};

if (pos == 0) { pos = text.length };

return pos;


}



On 10 Sep., 19:57, "Ben Lisbakken" <lisba...@google.com> wrote:
> Asset --
>
> I see your problem, and I would agree that it seems like your splitting of
> text is not working correctly.  I'm sorry to say, though, that I don't know
> what the answer is.  Are you doing the translation on the server, or in
> Javascript?  If you're doing it on the server, you might as well split up
> the text there.
>
> -Ben
>
> On Wed, Sep 10, 2008 at 7:53 AM, Asset <as...@asset.dk> wrote:
>
> > Now this link works  - so you should be abel to test/trace the
> > translation:
>
> >http://www.forskelsproduktion.dk/wiki/index.php?title=Play:Translate_...

Asset

ulæst,
10. sep. 2008, 16.12.2310.09.2008
til Google AJAX API
From what little I have been able to debug, with the poor IE tools, it
seems that this statement

var text = document.getElementById("wpTextbox1").innerHTML;

returns differnt results in FF the linebreak shows as \n while in the
IE debugger it shows as a graphics "block". Thus I thought that
something like the \x13\ would catch it but not.... .-((

Svar alle
Svar til forfatter
Videresend
0 nye opslag