blob: be82ff1e108990e73e90f2fc55c3fdfbc4e109c9 [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
Matt McDonald2a5f4132011-04-29 16:32:27 -040020from apiclient.model import JsonModel
Joe Gregorio34044bc2011-03-07 16:58:33 -050021
22
23FLAGS = gflags.FLAGS
Joe Gregorio34044bc2011-03-07 16:58:33 -050024logger = logging.getLogger()
25logger.setLevel(logging.INFO)
26
27
28def main(argv):
Joe Gregorio3157a742011-03-08 10:54:07 -050029 try:
30 argv = FLAGS(argv)
31 except gflags.FlagsError, e:
32 print '%s\\nUsage: %s ARGS\\n%s' % (e, argv[0], FLAGS)
33 sys.exit(1)
34
Joe Gregorio34044bc2011-03-07 16:58:33 -050035 service = build('translate', 'v2',
Joe Gregorioafdf50b2011-03-08 09:41:52 -050036 developerKey='AIzaSyAQIKv_gwnob-YNrXV2stnY86GSGY81Zr0',
Matt McDonald2a5f4132011-04-29 16:32:27 -040037 model=JsonModel())
Joe Gregorio34044bc2011-03-07 16:58:33 -050038 print service.translations().list(
39 source='en',
40 target='fr',
41 q=['flower', 'car']
42 ).execute()
43
44if __name__ == '__main__':
45 main(sys.argv)