blob: ee67d40a8d92f73a7849438ab6fa7fc84df61635 [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"""
22
23__author__ = 'jcgregorio@google.com (Joe Gregorio)'
24
John Asmuth864311d2014-04-24 15:46:08 -040025from googleapiclient.discovery import build
Joe Gregorio618e63b2010-11-04 19:55:28 -040026
Joe Gregorioaf276d22010-12-09 14:26:58 -050027
Joe Gregorio618e63b2010-11-04 19:55:28 -040028def main():
29
Joe Gregorio652898b2011-05-02 21:07:43 -040030 # Build a service object for interacting with the API. Visit
31 # the Google APIs Console <http://code.google.com/apis/console>
32 # to get an API key for your own application.
Joe Gregorio1ae3e742011-02-25 15:17:14 -050033 service = build('translate', 'v2',
Joe Gregorio61d7e962011-02-22 22:52:07 -050034 developerKey='AIzaSyDRRpR3GS1F1_jKNNM9HCNd2wJQyPG3oN0')
Joe Gregorio1ae3e742011-02-25 15:17:14 -050035 print service.translations().list(
Joe Gregorio61d7e962011-02-22 22:52:07 -050036 source='en',
37 target='fr',
38 q=['flower', 'car']
Joe Gregorio618e63b2010-11-04 19:55:28 -040039 ).execute()
40
41if __name__ == '__main__':
42 main()