blob: 21d01ee41523d28501a71ad72ac7d4e27689ffb5 [file] [log] [blame]
Craig Citro15744b12015-03-02 13:34:32 -08001#!/usr/bin/env python
Joe Gregorio618e63b2010-11-04 19:55:28 -04002# -*- coding: utf-8 -*-
3#
Craig Citro751b7fb2014-09-23 11:20:38 -07004# Copyright 2014 Google Inc. All Rights Reserved.
Joe Gregorio652898b2011-05-02 21:07:43 -04005#
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
Joe Gregorio618e63b2010-11-04 19:55:28 -040017
18"""Simple command-line example for Translate.
19
Joe Gregorio652898b2011-05-02 21:07:43 -040020Command-line application that translates some text.
Joe Gregorio618e63b2010-11-04 19:55:28 -040021"""
INADA Naokie8d87822014-08-20 15:25:24 +090022from __future__ import print_function
Joe Gregorio618e63b2010-11-04 19:55:28 -040023
24__author__ = 'jcgregorio@google.com (Joe Gregorio)'
25
John Asmuth864311d2014-04-24 15:46:08 -040026from googleapiclient.discovery import build
Joe Gregorio618e63b2010-11-04 19:55:28 -040027
Joe Gregorioaf276d22010-12-09 14:26:58 -050028
Joe Gregorio618e63b2010-11-04 19:55:28 -040029def main():
30
Joe Gregorio652898b2011-05-02 21:07:43 -040031 # Build a service object for interacting with the API. Visit
32 # the Google APIs Console <http://code.google.com/apis/console>
33 # to get an API key for your own application.
Joe Gregorio1ae3e742011-02-25 15:17:14 -050034 service = build('translate', 'v2',
Joe Gregorio61d7e962011-02-22 22:52:07 -050035 developerKey='AIzaSyDRRpR3GS1F1_jKNNM9HCNd2wJQyPG3oN0')
INADA Naokie8d87822014-08-20 15:25:24 +090036 print(service.translations().list(
Joe Gregorio61d7e962011-02-22 22:52:07 -050037 source='en',
38 target='fr',
39 q=['flower', 'car']
INADA Naokie8d87822014-08-20 15:25:24 +090040 ).execute())
Joe Gregorio618e63b2010-11-04 19:55:28 -040041
42if __name__ == '__main__':
43 main()