Making FileMaker interact with Google Translate

2017-12-31 Update – It has been a while since I looked at this file. Reader Jose, informed me that it was no longer working, so I set out to modernize it using the new JSON functions in FileMaker 16. I have created a new demo file, which requires FM 16 to use.

  • The interface is mostly updated to use FM 16 elements such as a button bar.
  • Some of the scripts were simplified and reordered.
  • It no longer requires the Custom Functions to parse the JSON returning from Google.
  • I attempted to get the CURL functions working, to allow longer text files, but failed at this point. I left my testing script in there if anyone wants to take this on.
  • You will need to set up your own Google API key to get it working. I took mine out after testing.
  • Download: FileMaker 16 Demo File.

FM Google Translate

A reader from Germany recently thanked me for making the FileMaker to Google 2D Barcode example file and requested a similar demo of having FileMaker work with Google Translate. I took up the challenge, because I wish this functionality was built into things like Facebook (so I can understand my German, French and Danish friends when they post in their own languages), and figured that others might find this functionality useful in FileMaker.

It turned out to be a fairly simple integration, but requires users to sign up for their own Google API Key. Like many Google services these days, Translate is not free and there are no Courtesy Limit, so you start paying right away by the character. Pricing seems reasonable at low levels of usage. The full Google Translate API documentation is available here.

Download the FileMaker Google Translate Demo here.

Setting up


Once you have obtained a Google Translate API Key (you need to give them a current credit card for it to be functional), you can paste the API Key string into the FileMaker global settings field in the demo called, strangely, Google API Key.

Make sure the preferred method of translation is set to the Google API method. The Google Web Browser approach will open your default browser with your translation in a browser. This approach appears to be free and does not require an API key but does requires you cut and paste the result back into your database.

How to Translate text from a FileMaker field.


1) Enter the Language From
2) Select the Language To
3) Enter some text
4) Click Translate button
5) Translated Text

Translate Script


The main script in action here is one called “Translate Text – API Method”.

The basics are:

1) A test to see if you have an API key entered
2) Send a calculated URL to a named Web Viewer (Language FROM, Language TO and Text To Translate)
3) Wait for a response from the Web Viewer
4) Test for ‘error’ in the result – display the error message and halt script. The Google error is usually pretty descriptive and should help you solve the issue.
5) Parse a positive result into the Translated Text field using a Custom Function called ParseData
6) Reset the Web Viewer

The Calculated URL step


This is the step that sends a calculated URL to the named Web Viewer. These variables are coming from text fields in the database.

Important Variables:

  • Google API Key
  • Text To Translate
  • Language FROM
  • Language TO

Custom Function: ParseData


In File: Manage: Custom Functions, I have added a Custom Function called ParseData. I got this from, a web site that maintains a good collection of Custom Functions. This Custom Function helps to parse out the translated text from the source code that is returned from the Google Translate web service.

Limitation to the Length of Text to be Translated


Because this method is sending the text to Google Translate in the URL string, there are obviously going to be a limitations on the length of what can be sent. While there does not appear to be a set limit, different browsers have different limits.

Bonus Points: What if you don’t know the language you are starting from?


There appears to be a method in the Google Translate API of just sending text to the Translate engine and letting it figure out what language the text is in. I did not try this, but it may be an area others want to develop. If you improve on the demo, I encourage you to send me your changes and I can add them to the basic demo I have created.

Related Articles:
Getting Help about FileMaker – FAST!
Where Am I? Using FileMaker Go 12 to track your Location
Creating Google Cluster Maps from FileMaker
Creating and Storing 2D Bar Codes in FileMaker

8 Responses to “Making FileMaker interact with Google Translate”

  1. THis works great on a Mac and on iPads (FM Go) but not in Windows. I get “Download File – Security Warning” on Win XP and Win 7 using IE8. Any ideas?

    • A similar issue came up in my blog about integrating with MailChimp. There a JSON file is returned and IE pops up a dialog box as well. FileMaker is dependent on Internet Explorer for the Web Viewer functionality. So whatever IE does with the file, that dialog will display in FileMaker’s Web Viewer.

      In that situation various workarounds were suggested, including employing BaseElements free plugin. The plugin includes a function BE_GetURL ( ) which could be used to send the request to Google, avoiding the web viewer step. By using a plug-in, instead of a Web Viewer, one presumably would avoid any dialog boxes from IE.

  2. First, thanks– this is really cool. I did get it to work via the Google Web Browser but not via the Google API. I get the error
    “error”: {

    This is very new to me– so my apologies if I’m being a knucklehead!

    • I get the same thing now. The error message if you stretch it out says something about usage limits. Google often changes their licensing, so this demo file may be a victim of a recent change. Did you get your own API key? If you have one, make sure you put it in the Settings area.

  3. Does this still work?


  1. Creating and Storing 2D Bar Codes in FileMaker | HomeBase Software - July 14, 2012

    […] Articles: Making FileMaker interact with Google Translate Creating Google Cluster Maps from FileMaker FileMaker and Image Maps in a […]

  2. FileMaker Progress Indicators using a Web Viewer and Animated GIFs | HomeBase Software - July 14, 2012

    […] Articles: Where Am I? Using FileMaker Go 12 to track your Location Making FileMaker interact with Google Translate Creating Google Cluster Maps […]

  3. Shortening URLs using FileMaker | HomeBase Software - July 14, 2012

    […] Related Articles: URLs in PDFs – Yet another reason to shorten URLs in FileMaker Creating and Storing 2D Bar Codes in FileMaker Making FileMaker interact with Google Translate […]

%d bloggers like this: