{"id":297326,"date":"2021-07-12T18:20:39","date_gmt":"2021-07-12T15:20:39","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/heres-how-developers-can-implement-the-google-translate-api-in-their-apps\/"},"modified":"2021-07-12T18:20:39","modified_gmt":"2021-07-12T15:20:39","slug":"heres-how-developers-can-implement-the-google-translate-api-in-their-apps","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/heres-how-developers-can-implement-the-google-translate-api-in-their-apps\/","title":{"rendered":"#Here\u2019s how developers can implement the Google Translate API in their apps"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a383d5a69c1f\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a383d5a69c1f\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/heres-how-developers-can-implement-the-google-translate-api-in-their-apps\/#How_localization_tools_are_driving_innovation_in_AI-driven_APIs\" >How localization tools are driving innovation in AI-driven APIs<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/heres-how-developers-can-implement-the-google-translate-api-in-their-apps\/#What_does_Google_offer_for_translation\" >What does Google offer for translation?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/heres-how-developers-can-implement-the-google-translate-api-in-their-apps\/#Getting_started_with_Google_Translate_API\" >Getting started with Google Translate API<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/buradabiliyorum.com\/en\/heres-how-developers-can-implement-the-google-translate-api-in-their-apps\/#Setting_up_for_Your_First_Translation\" >Setting up for Your First Translation<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/buradabiliyorum.com\/en\/heres-how-developers-can-implement-the-google-translate-api-in-their-apps\/#Executing_Your_First_Translation\" >Executing Your First Translation<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/buradabiliyorum.com\/en\/heres-how-developers-can-implement-the-google-translate-api-in-their-apps\/#Next_steps_in_the_translation_process\" >Next steps in the translation process<\/a><\/li><\/ul><\/nav><\/div>\n<p>&#8220;<strong>#Here\u2019s how developers can implement the Google Translate API in their <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">app<\/a>s<\/strong>&#8221;<br \/>\n<img decoding=\"async\" src=\"https:\/\/img-cdn.tnwcdn.com\/image?fit=796%2C417&amp;url=https%3A%2F%2Fcdn0.tnwcdn.com%2Fwp-content%2Fblogs.dir%2F1%2Ffiles%2F2021%2F07%2FGoogleTranslateAI.jpg&amp;signature=8454c10525313ddb4c247ebeee968873\" \/><\/p>\n<div>Even if most of us can\u2019t <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/trip-and-travel\/\" data-internallinksmanager029f6b8e52c=\"10\" title=\"Trip &amp; Travel\" target=\"_blank\" rel=\"noopener\">travel<\/a> as we once did, the world is a more accessible place, at least online. Business people may not be attending international conferences or flying around the world for meetings so much. But in many respects, businesses are finding that they can access and develop foreign markets by localizing their websites and apps to speak the language of locals and adapt to their standards. Developers can play an integral role in the localization process.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"How_localization_tools_are_driving_innovation_in_AI-driven_APIs\"><\/span>How localization tools are driving innovation in AI-driven APIs<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Developers can hop on this trend, increase the value of their software, and expand online on capabilities to their apps. Google has emerged as a leader in translation algorithms in the past decade, leveraging advances in AI-driven<span>\u00a0<\/span><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/bdtechtalks.com\/2019\/08\/05\/what-is-artificial-neural-network-ann\/\">neural network tech<\/a>. This powers Google Translate, well-known to businesses for their companies or clients. They can do so readily by adding auto-translators Google Translate, well-known to businesses and consumers, an app that has made an impact on the translation profession as we know it. We\u2019ll explore here how developers can add Google-powered translations to their apps by leveraging the powers of the company\u2019s Translate API. Localization tools, which drive<a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.tomedes.com\/translator-hub\/best-localization-tools\"><span>\u00a0<\/span>greater accuracy<\/a><span>\u00a0<\/span>in translation mechanics, are also necessary for the translator to work more efficiently.<\/p>\n<p>Before diving into the software weeds, it\u2019s worth noting alternatives to the Google Translate API route. Third-party conversion tools like Zapier and IFTTT let you link your software workflow to auto-translation modules via webhooks and web services, with a minimum of coding. Even a tech-savvy non-programmer should be able to implement these solutions. The main drawback, however, is that you are likely to settle for a translation engine inferior to the one offered by Google.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"What_does_Google_offer_for_translation\"><\/span>What does Google offer for translation?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Google is a pioneer in both<span>\u00a0<\/span><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/bdtechtalks.com\/2017\/08\/28\/artificial-intelligence-machine-learning-deep-learning\/\">machine language<\/a><span>\u00a0<\/span>and machine learning\u2014the two L-words representing two sides of the same coin. Language needs to be learned, and that learning is achievable by mastery of a natural language. AI-driven mastery these days is driven by neural machines or NMT in 2016, bringing a \u201cparadigm shift\u201d in translation tech. From that year forward, NMT has been the preferred method of translating.<\/p>\n<p>Back in 2006, Google started training its translation algorithm by digesting tens of millions of words extracted from translated documents of the European Union parliament and the United Nations. Today Google confronts competition from <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/social-mediaa\/\" data-internallinksmanager029f6b8e52c=\"1\" title=\"Social Media\" target=\"_blank\" rel=\"noopener\">Facebook<\/a>, which is leveraging the learnings from comments and posts by its 2 billion users to translate more casual conversations, including rendering LOL and WTF in scores of languages. NMT continues to be a way to go.<\/p>\n<p>Happily, the language learning process didn\u2019t stop with bureaucratese and Emoji. Google Translate today supports over 100 languages, several dozen with voice support. You can talk in one language and get the translation vocalized in another, usually with a choice of voice. And, as we will see, machine learning has been productized so that you can effectively translate a domain-specific language of your own.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Getting_started_with_Google_Translate_API\"><\/span>Getting started with Google Translate API<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Google promotes its API as fast and dynamic, adaptable to diverse content needs. The company markets not just to professional coders but to a broader spectrum of users, including those with \u201climited machine learning expertise\u201d who can quickly \u201ccreate high-quality, production-ready models.\u201d<\/p>\n<p>For the latter, you can just upload translated language pairs (a structured list of words\/phrases with their translations) and AutoML Translation will train a custom translation model. The workflow allows either customized-by-the-client or pre-trained (by Google) inputs. To translate an English product description into French, Korean, and Portuguese, for example, you could customize a Google AutoML model for French and rely on an off-the-shelf pre-trained model for Korean and Portuguese. Then you simply upload your English HTML file to Google Cloud Storage and send a batch request to the Translation API pointing to your AutoML and the pre-trained models. Google\u2019s AutoML Translation will then output your HTML in three separate language files to your Cloud Storage.<\/p>\n<p>Training is key, but the initial model is pre-trained to render 100+ languages. And if you have a domain-specific lexicon (medical or legal terms, for example) these require just a little more training and tweaking of the basic API, if they don\u2019t already exist. A Glossary lets users \u201cwrap\u201d proprietary terminology not to be translated (like brand and product names) to ensure they stay intact during translation. There is also built-in support Media Translation API, which handles real-time, low latency streaming of audio translations.<\/p>\n<p>The process is essentially three steps: Upload a language pair. Train AutoML. Evaluate.<\/p>\n<p>This translation power is not free but the pricing is fair. Typically, you\u2019ll be using Google\u2019s Translate API and its Media Translation API (if you need voice support). You\u2019ll need the AutoML service only if you need to train more language pairs.<\/p>\n<p>The fee for the Translate API is $20 per million characters. The Media Translation API will set you back $0.068 to $0.084 per minute. AutoML is a bit pricier, costing $45 per hour for training a language pair, to a max of $300\/pair. Pay only for what you use, as you use it. (Google is patient: it wants to get you hooked, so it throws in free processing as you get up to speed, with a full year to practice before needing to pay up.)<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Setting_up_for_Your_First_Translation\"><\/span>Setting up for Your First Translation<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The RESTful Translate API is the easiest way to get started. Google offers a basic and advanced setup. You can do this with localization tools, but you can also do it manually. If you\u2019ve set up any Google API service, you\u2019re probably comfortable with the drill and may already have a Cloud Console Account. Assuming this is true, the next things you need to do, if you haven\u2019t already, are:<\/p>\n<ul>\n<li>Create or select your project.<\/li>\n<li>Enable the Cloud Translation API.<\/li>\n<li>Create a service account.<\/li>\n<li>Download your private key in JSON format. Keep the full path to this file for the next step.<\/li>\n<\/ul>\n<p>Go to the shell prompt on your Mac OS X, Linux, or Windows (Powershell) system and set the environment variable<span>\u00a0<\/span><strong>GOOGLE_APPLICATION_CREDENTIALS<\/strong><span>\u00a0<\/span>to the path of your JSON service account key using the following commands. This variable only applies to the current shell session. If you open a new session, you\u2019ll need to reset this variable, replacing [PATH] with the path of the JSON file with your key.<\/p>\n<p>If you\u2019re using Linux or macOS:<\/p>\n<div class=\"wp-block-jetpack-markdown\">\n<pre><code class=\"language-sh\">export GOOGLE_APPLICATION_CREDENTIALS=\"[PATH]\"&#13;\n<\/code><\/pre>\n<\/div>\n<p>For Windows, in PowerShell:<\/p>\n<div class=\"wp-block-jetpack-markdown\">\n<pre><code class=\"language-sh\">$env:GOOGLE_APPLICATION_CREDENTIALS=\"[PATH]\"&#13;\n<\/code><\/pre>\n<\/div>\n<p>Or, from a command prompt:<\/p>\n<div class=\"wp-block-jetpack-markdown\">\n<pre><code class=\"language-sh\">set GOOGLE_APPLICATION_CREDENTIALS=[PATH]&#13;\n<\/code><\/pre>\n<\/div>\n<p>Then install and initialize Google\u2019s Cloud SDK. Depending on which operating system you\u2019re using, the Cloud SDK may have a dependency on a version of Python that isn\u2019t installed on your system. So be sure to double-check the Cloud SDK documentation to ensure the appropriate version of Python is installed.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Executing_Your_First_Translation\"><\/span>Executing Your First Translation<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Make a Translation API Request with a REST call using the v2 translate method.<\/p>\n<p>Use<span>\u00a0<\/span><em>curl<\/em><span>\u00a0<\/span>to make your request to the\u00a0<a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/translation.googleapis.com\/language\/translate\/v2\">https:\/\/translation.googleapis.com\/language\/translate\/v2<\/a><span>\u00a0<\/span>endpoint.<\/p>\n<p>The command includes JSON with (1) the text to be translated (q), (2) the language to translate from (source), and (3) the language to translate to (target).<\/p>\n<p>Source and target languages are identified with ISO-639-1 codes. In this example, the source language is English (en), the target is French (fr). The query format is plain \u201ctext\u201d.<\/p>\n<p>The sample<span>\u00a0<\/span><strong>curl<\/strong><span>\u00a0<\/span>command uses the<span>\u00a0<\/span><strong>gcloud auth application-default print-access-token<\/strong><span>\u00a0<\/span>command to get an authentication token.<\/p>\n<div class=\"wp-block-jetpack-markdown\">\n<pre><code class=\"language-js\">curl -s -X POST -H \"Content-Type: application\/json\" &#13;\n    -H \"Authorization: Bearer \"$(gcloud auth application-default print-access-token) &#13;\n    --data \"{&#13;\n  'q': 'The quick brown fox jumps over the lazy dog',&#13;\n  'source': 'en',&#13;\n  'target': 'fr',&#13;\n  'format': 'text'&#13;\n}\" \"https:\/\/translation.googleapis.com\/language\/translate\/v2\"&#13;\n<\/code><\/pre>\n<\/div>\n<p>The response should resemble the following:<\/p>\n<div class=\"wp-block-jetpack-markdown\">\n<pre><code class=\"language-js\">{&#13;\n  \"data\": {&#13;\n    \"translations\": [&#13;\n      {&#13;\n        \"translatedText\": \"Le renard brun rapide saute par-dessus le chien paresseux\"&#13;\n      }&#13;\n    ]&#13;\n  }&#13;\n}&#13;\n<\/code><\/pre>\n<\/div>\n<p>Congratulations! You\u2019ve sent your first request to the Cloud Translation API!<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Next_steps_in_the_translation_process\"><\/span>Next steps in the translation process<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>For most apps, you can rely on one of the over 100 language pairs already trained and tested.\u00a0 (If the pair you require is not available, or you need a custom translation with the AutoML training module.) The full process is as follows:<\/p>\n<ol>\n<li>Create a file containing the desired language pairs, using the CURL example above. Choose the source and target languages from the list<span>\u00a0<\/span><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/cloud.google.com\/translate\/docs\/languages\">here<\/a><span>\u00a0<\/span>(e.g., \u201cen\u201d or \u201cfr\u201d).<\/li>\n<li>Write code that reads the content of your website and makes a REST call to the Cloud Translation API (including a parameter pointing to your model and then producing a translated version of that text).<\/li>\n<li>Create a new page in your content management system to contain and then display the translated text. Even better, if your CMS is programmable (either directly or by way of API), improve the code by automating this step.<\/li>\n<li>Configure your CMS and website to display the appropriate pages when a specific language is selected by your site\u2019s end users.<\/li>\n<\/ol>\n<p>Client libraries are currently available for seven popular programming languages \u2013 C#, Go, Java, Node.js, PHP, Python, and Ruby. Just install the library of your choice.\u00a0Go to Translation Client Libraries for installation instructions.<\/p>\n<p><i><span>This article was originally published by Richard Koret on\u00a0<\/span><\/i><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/bdtechtalks.com\/\"><i><span>TechTalks<\/span><\/i><\/a><i><span>, a publication that examines trends in <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/technology\/\" data-internallinksmanager029f6b8e52c=\"4\" title=\"Technology\" target=\"_blank\" rel=\"noopener\">technology<\/a>, how they affect the way we live and do business, and the problems they solve. But we also discuss the evil side of technology, the darker implications of new tech, and what we need to look out for. You can read the original article <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/bdtechtalks.com\/2021\/07\/04\/google-translate-api-beginners-guide\/\">here<\/a>.<\/span><\/i><\/p>\n<\/div>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong>\n<\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/thenextweb.com\/news\/developers-implement-google-translate-apps-syndication\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#Here\u2019s how developers can implement the Google Translate API in their apps&#8221; Even if most of us can\u2019t travel as we once did, the world is a more accessible place, at least online. Business people may not be attending international conferences or flying around the world for meetings so much. But in many respects, businesses&#8230;<\/p>\n","protected":false},"author":1,"featured_media":297327,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/img-cdn.tnwcdn.com\/image\/neural?filter_last=1&fit=1280,640&url=https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2021\/07\/GoogleTranslateAI.jpg&signature=ec60a3389abb868bd3a35f69a793cbb2","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-297326","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/297326","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=297326"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/297326\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/297327"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=297326"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=297326"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=297326"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}