blob: 6fe0c0ff85e01a259a44fc151de3aa7d65089598 [file] [log] [blame]
Joe Gregorio34044bc2011-03-07 16:58:33 -05001#!/usr/bin/python2.4
2# -*- coding: utf-8 -*-
3#
4# Copyright 2010 Google Inc. All Rights Reserved.
5
6"""Simple command-line example for Translate.
7
8Command-line application that translates
9some text.
10"""
11
12__author__ = 'jcgregorio@google.com (Joe Gregorio)'
13
14import gflags
15import logging
16import pprint
17import sys
18
19from apiclient.discovery import build
20from apiclient.model import LoggingJsonModel
21
22
23FLAGS = gflags.FLAGS
24# Uncomment the next line to get very detailed logging
25# httplib2.debuglevel = 4
26
27# create logger
28logger = logging.getLogger()
29logger.setLevel(logging.INFO)
30
31
32def main(argv):
33 try:
34 argv = FLAGS(argv) # parse flags
35 except gflags.FlagsError, e:
36 print '%s\\nUsage: %s ARGS\\n%s' % (e, argv[0], FLAGS)
37 sys.exit(1)
38
39 service = build('translate', 'v2',
40 developerKey='AIzaSyDRRpR3GS1F1_jKNNM9HCNd2wJQyPG3oN0',
41 model=LoggingJsonModel())
42 print service.translations().list(
43 source='en',
44 target='fr',
45 q=['flower', 'car']
46 ).execute()
47
48if __name__ == '__main__':
49 main(sys.argv)