blob: 6108f47725b704104666c6a7eea67242c393b6e8 [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
Joe Gregorio34044bc2011-03-07 16:58:33 -050024
Joe Gregorio34044bc2011-03-07 16:58:33 -050025logger = logging.getLogger()
26logger.setLevel(logging.INFO)
27
28
29def main(argv):
30 try:
Joe Gregorioafdf50b2011-03-08 09:41:52 -050031 argv = FLAGS(argv)
Joe Gregorio34044bc2011-03-07 16:58:33 -050032 except gflags.FlagsError, e:
33 print '%s\\nUsage: %s ARGS\\n%s' % (e, argv[0], FLAGS)
34 sys.exit(1)
35
36 service = build('translate', 'v2',
Joe Gregorioafdf50b2011-03-08 09:41:52 -050037 developerKey='AIzaSyAQIKv_gwnob-YNrXV2stnY86GSGY81Zr0',
Joe Gregorio34044bc2011-03-07 16:58:33 -050038 model=LoggingJsonModel())
39 print service.translations().list(
40 source='en',
41 target='fr',
42 q=['flower', 'car']
43 ).execute()
44
45if __name__ == '__main__':
46 main(sys.argv)