{Translate}ステップ 4: 開始方法 (AWS CLI)


https://docs.aws.amazon.com/ja_jp/translate/latest/dg/get-started-cli.html


-- 1. コマンド等のインストール

-- 1.1 aws cli version 2 インストール

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
aws --version

 

-- 1.2 jqインストール
sudo yum -y install jq


-- 2. テキストの翻訳
aws translate list-languages

 

aws translate translate-text \
--source-language-code "en" \
--target-language-code "ja" \
--text "hello, world"

 

vim a.json

{
    "Text": "Amazon Translate translates documents between languages in     real time. It uses advanced machine learning technologies     to provide high-quality real-time translation. Use it to     translate documents or to build applications that work in     multiple languages.", 
    "SourceLanguageCode": "en", 
    "TargetLanguageCode": "ja"
}

aws translate translate-text \
--cli-input-json file://a.json


vim b.json

{
    "Text": "In the following exercises, you use the AWS command line interface (AWS CLI) to translate text. To complete these exercises, you need to be familiar with the CLI and have a text editor. For more information, see Step 2: Set up the AWS Command Line Interface (AWS CLI).", 
    "SourceLanguageCode": "en", 
    "TargetLanguageCode": "ja"
}

aws translate translate-text \
--cli-input-json file://b.json