Jump to content
Server Maintenance This Week. ×

web viewer google translate, eventually crashes filemaker


Reed

This topic is 3825 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi All,

 

So from Brian Dunning's website, I found that you can use the following URL to put google translate into a web viewer:

"http://translate.google.com/translate_t?hl=en&sl=en&tl=de&text="&FieldName

where FieldName is the english text which you want translated and you can change "de" to zh-CN or other supported languages.  This seems to work well and using the following function

Let(
[htmlcontent = GetLayoutObjectAttribute ( "google_translate"; "content" );
tran_result_start = Position ( htmlcontent; "TRANSLATED_TEXT="; 1; 1);
first_quote = Position (htmlcontent; "'";tran_result_start;1);
second_quote = Position (htmlcontent; "'";tran_result_start;2)
];
Middle ( htmlcontent; first_quote+1; second_quote-first_quote-1)
)

I can grab the part of the resulting web page that has the translated text.  So I proceeded to script this with a page refresh to get the content to get in the function, and a one second pause in the loop prior to getting values to allow the web viewer to work.  This seems to work well, except for the fact that after ~100 records, Filemaker will crash with a C++ runtime exception.  I guess this is due to gobbling up so much memory or too many processes from all the web viewer content.

 

Is there a way around this other than doing 75 records at a time and quitting Filemaker in between?

 

Thanks,

 

Dana

Link to comment
Share on other sites

I had a similar problem when running in a Windows environment.  The problem seemed to be that the web viewer was using Internet Explorer, and each time you moved to a different record, another IE session was created. Eventually the computer ran out of memory and crashed Filemaker.

 

One possible way around this might be to place the web viewer on a separate table, alter the URL FieldName value as you step through each record in the main table, and copy the result back into the main table.  This way you should only have one instance of the web viewer, not one per record.

 

Brian

Link to comment
Share on other sites

That is really cool! Here's a formula to parse out the translated text from all that junk:

Let([
  txt = yourGoogleResultField ;
  start = "TRANSLATED_TEXT='" ;
  end = "';" ;
  pos1 = Position ( txt ; start ; 1 ; 1 )+ Length( start ) ;
  pos2 = Position ( txt ; end ; pos1 ; 1 ) ;
  result = Middle ( txt ; pos1 ; pos2 - pos1 )
 ] ;
  result
)
Link to comment
Share on other sites

That's also a really good idea!  I didn't come back to read this though until I had already implemented it with the web viewer, but looping a portal instead of a found set.  Then it just uses one instance of IE, and works great.   

 

But yeah, I had forgot about the new Insert from URL step.  I had been using that to upload files into containers in IWP.  I had a script upload them to a temp location on the web server and then had IWP insert the image files into the container.  If I was better at PHP, I'd think I could get a whole custom web page to upload images into containers in one shot.  But Supercontainer is probably just easier...

 

Thanks guys for all the great suggestions!

Link to comment
Share on other sites

  • 2 weeks later...

While I am at it, does anyone know of any way to play the online translations audio in the webviewer? There are several translation sites that speak the translations but I was wondering if anyone has had those speak using filemaker on the fly. Thanks

Link to comment
Share on other sites

Does anyone know of a way to get Insert From URL to authenticate to ActiveDirectory?  The standard authentication in the URL doesn't work on our internal sharepoint site 

http://username:[email protected]/

I'm guessing that the site itself controls this, so unless there's another way to make the Script step do authentication, I'll have to continue using a web viewer for this one.

 

Thanks,

 

Dana

Link to comment
Share on other sites

This topic is 3825 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.