October 22, 201312 yr 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
October 22, 201312 yr 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
October 22, 201312 yr Author that sounds like a good idea! I'll give that a try and report back. Thanks, Dana
October 22, 201312 yr Is there a way around this ...? Yes, there is. Do not use the web viewer but instead use the new ( only on 12 ) script step: Insert from URL
October 23, 201312 yr 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 )
October 23, 201312 yr The calculation is a little more complex but above all you need to edit the URL ( otherwise you'll lose the accented characters ) See the attachment. Google Translate.zip
October 24, 201312 yr Author 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!
November 7, 201312 yr 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
November 12, 201312 yr Author 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
Create an account or sign in to comment