Google Translate Element
What is the Google Translate Element?
Even though individuals can use browser plugins to translate content on the web, sometimes it may be necessary to give visitors an easier way to enable translations on a website. The Google Translate Element puts a button directly on the webpage with a long list of languages to select.
Adding Google Translate to a Drupal site
You will need to be a site builder to complete the following instructions. You will be creating a basic custom block, adding the code to the source editor, and then using Block Layout under Structure to place the block.
- Create a new basic custom block by going to Structure -> Block Layout -> Add Custom Block
- Select "Basic block"
- Name your block description "Google Translate Element" or something similar that can be easily found later.
- Switch to the Text format "Rich Text Editor (Source)" (located at the bottom of the editor) and then click on the "Source" icon on the editor.
- When in source mode, paste in the following code:
- This image depicts what it looks like when the block description and code has been added in source mode.
- Click out of source mode. Then Save as Published.
- On the next screen, you will determine where you want your Google Translate button to appear.
Toggle "off" the option to Display Title.
Restrict the Visibility if applicable. Remember, if you do not restrict the visibility, this will display on ALL pages of the website. You can restrict by adding the root relative page URLs or by content type.
Select the Region of where this Google Translate button will display. It is recommended to place it in the Site Notification Region. If you have access, possibly even the Header Top region.
- Save Block.
To see more options for the Translate button or see it in action before placing on your site, please see The W3 School website's How To - Google Translate.