DEVELOPER BLOG

HOME > DEVELOPER BLOG > 【Introduction to GCP】Try to do text translation using Cloud Translation API- PrismScaler

【Introduction to GCP】Try to do text translation using Cloud Translation API- PrismScaler

1. Introduction

Hello! We are a writer team from Definer Inc. In this issue, you are wondering how to translate text files using the Cloud Translation API. Let's take a look at the actual screens and resources to explain in detail.

2. Purpose/Use Cases

This article will utilize the Cloud Translation API technology for the purpose of translating text files. It summarizes information and practices that can be helpful when you want to translate text with the Google Translate API in the IT field.

3. What is Cloud Translation API?

Overview: The Cloud Translation API is a dynamic text translation API that can be used in applications and websites. It is provided by Google Cloud Platform (GCP) that allows developers to integrate language translation capabilities into their applications or systems. It is part of Google's Cloud Translation suite of tools and technologies.It can translate using Google's pre-trained models and can also be custom trained. With the Cloud Translate API, developers can send text to the API and receive translations in real-time. The API supports translation between various languages. The Cloud Translation API can translate more than 100 language peers. It can also automatically detect unknown languages.   Key features of the Cloud Translate API include:
  1. Language Detection: The API can automatically detect the language of the input text if it is not specified, saving developers from explicitly providing the source language.
  2. Translation: The API can translate text from one language to another, making it useful for building multilingual applications or supporting global user bases.
  3. Batch Translation: Developers can perform bulk translations by sending multiple text inputs to the API simultaneously, making it efficient for processing large amounts of text.
  4. Glossary and Customization: The Cloud Translate API allows users to customize translations by providing specific glossaries or translation models. This helps maintain consistency and accuracy in specialized domains or industry-specific terminology.
  5. Integration and Scalability: The API is designed to be easily integrated into various applications, websites, or backend systems. It offers scalability and can handle a high volume of translation requests.
  About Pricing: It is free for the first 500,000 characters and available for $20 per million characters. Cloud Translation - Basic: The pricing information applies to the detect and the translate methods. Cloud Translation - Advanced: The following pricing information applies to the translateText, batchTranslateText, translateDocument, batchTranslateDocument, detectLanguage, and romanizeText methods. Cloud Translation does not charge for other requests such as glossary creation. Custom model training costs: Model training is charged by the hour. The time that is required to train your model depends on the size and complexity of your training data. If training fails for any reason, you aren't billed for that training time.

4. Translate text data

Now, let's try to translate text data using Python.   (1) Install the GoogleCloud Translate library. First, install the library with the following command.   (2) Issue a service key for Google Cloud From IAM of GCP console, issue a service key (Json file) with the authority of Translate API. Set the issued service key (Json file) to the environment variable.
## GoogleCloud Translate Install API Library
pip install --upgrade google-cloud-translate

## Set environment variables for key
export GOOGLE_APPLICATION_CREDENTIALS="/${key path}/${key name}.json"                
 

(3) Execution of translation
Translation can be performed with the following program.
By changing the contents of translate_content, you can translate any text.
In this case, the source and target languages are specified.
from google.cloud import translate_v3beta1 as translate

translate_content=["hello!!"]

client = translate.TranslationServiceClient()
response = client.translate_text(
    parent=parent,
    contents=translate_content,
    mime_type='text/plain',  #text/html can also be specified
    source_language_code='en',
    target_language_code='ja')

for translation in response.translations:
    print('Translated Text: {}'.format(translation))
    ## hello!!                  

5. Cited/Referenced Articles

6. About the proprietary solution "PrismScaler"

・PrismScaler is a web service that enables the construction of multi-cloud infrastructures such as AWS, Azure, and GCP in just three steps, without requiring development and operation. ・PrismScaler is a web service that enables multi-cloud infrastructure construction such as AWS, Azure, GCP, etc. in just 3 steps without development and operation. ・The solution is designed for a wide range of usage scenarios such as cloud infrastructure construction/cloud migration, cloud maintenance and operation, and cost optimization, and can easily realize more than several hundred high-quality general-purpose cloud infrastructures by appropriately combining IaaS and PaaS.  

7. Contact us

This article provides useful introductory information free of charge. For consultation and inquiries, please contact "Definer Inc".

8. Regarding Definer

・Definer Inc. provides one-stop solutions from upstream to downstream of IT. ・We are committed to providing integrated support for advanced IT technologies such as AI and cloud IT infrastructure, from consulting to requirement definition/design development/implementation, and maintenance and operation. ・We are committed to providing integrated support for advanced IT technologies such as AI and cloud IT infrastructure, from consulting to requirement definition, design development, implementation, maintenance, and operation. ・PrismScaler is a high-quality, rapid, "auto-configuration," "auto-monitoring," "problem detection," and "configuration visualization" for multi-cloud/IT infrastructure such as AWS, Azure, and GCP.