-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaphra_runner.py
More file actions
29 lines (23 loc) · 712 Bytes
/
aphra_runner.py
File metadata and controls
29 lines (23 loc) · 712 Bytes
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
import sys
import urllib.parse
from aphra import translate
def decode_path(path):
return urllib.parse.unquote(path)
def main():
config_file = decode_path(sys.argv[1])
source_language = sys.argv[2]
target_language = sys.argv[3]
input_file = decode_path(sys.argv[4])
output_file = decode_path(sys.argv[5])
with open(input_file, 'r', encoding='utf-8') as f:
text = f.read()
translated_text = translate(
source_language=source_language,
target_language=target_language,
text=text,
config_file=config_file
)
with open(output_file, 'w', encoding='utf-8') as f:
f.write(translated_text)
if __name__ == "__main__":
main()