forked from tuliocasagrande/lingotranslator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtranslate.py
More file actions
executable file
·48 lines (38 loc) · 1.2 KB
/
Copy pathtranslate.py
File metadata and controls
executable file
·48 lines (38 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/python
# This Python file uses the following encoding: utf-8
import sys
import translator
def fixMode(arg):
if len(arg) != 3:
print 'Error! No such mode: {0}'.format(arg)
print 'A three-characters mode is required.'
sys.exit()
mode = ''
for each in arg:
if each == 'Y' or each == 'y':
mode += 'Y'
else:
mode += 'N'
if mode == 'NNN':
print "Error! Mode 'NNN' can't by used."
sys.exit()
return mode
if len(sys.argv) != 3:
print 'Usage: {0} XXX file'.format(sys.argv[0])
print ''
print 'Mode:'
print ' Y__\t search tokens in the English dictionary'
print ' _Y_\t search tokens in the Lingo dictionary'
print ' __Y\t keep original tokens'
print ''
print 'Any combination can be used. Examples:'
print ' YYY - it will search tokens in both dictionaries and ḱeep original tokens'
print ' YYN - it will search tokens in both dictionaries and discard original tokens'
print ' YNY - it will search tokens only in the English dictionary and ḱeep original tokens'
sys.exit()
else:
mode = fixMode(sys.argv[1])
print "Translating file '{0}' with mode '{1}'.".format(sys.argv[2], mode)
translator.init(mode)
translator.translate_file(sys.argv[2], mode)
print 'Done!'