Automate your content translation with the Google Translate API. Bill Juda Github: judaw
Who am I? Webmaster Office of the Vice Provost for International Affairs Mario Einaudi Center for International Studies 8 area studies programs of the center Been working in Drupal for about 5 years Frontend and Backend Developer, Server Admin
Why are we trying to solve this problem? Mario Einaudi Center for International Studies and it partners want to create a forum site where members can have scholarly conversation. Members should be able to post in their native languages. Our first use case: 4 languages: English, Chinese Simplified, Japanese, Korean
Defining what we want from our multilingual site. A multilingual site Automated, instantaneous translation Content added in any language Ability to edit translations
What modules will we use? Core Modules Languages Content Translation Custom Module We will use the many Entity API functions. We will connect to the Google Translate API using the Google Client Library
The process. Create a node. Upon saving you will view node. (hook_entity_view). Get all languages of the site excluding the source language. For each language. Add translation. Get all the translatable fields. Send each field to Google to be translated. Put translated content into new translation. Save the translation. View translations.
Step 1: Configure Drupal Turn on Language and Content Translation Create a content type and configure the fields to be translatable.
Step 2: Connect to Google Translate API I wrote a custom module. Uses the Google client library and custom code to connect to API. For developers using composer composer require google/cloud
Step 3: Create content Once we have configured Drupal and enabled our custom code we will be ready to add content to our site.
Live Demo
Google API Links Google API overview documentation https://cloud.google.com/translate/docs/apis Google API client libraries https://cloud.google.com/translate/docs/reference/libraries Google client libraries documentation https://googlecloudplatform.github.io/google-cloud-php/#/docs/google-cloud/v0.39.2/translate/translateclient
Contact Information Email: wfj24@cornell.edu Office: 164 Uris Hall Phone: 607-255-1004