Skip to content

Commit

Permalink
Create aphra_runner.py
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidLMS committed Aug 23, 2024
1 parent 9db60c6 commit 0a1f1d2
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions aphra_runner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,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()

0 comments on commit 0a1f1d2

Please sign in to comment.