aws-samples / aws-samples/pptx-translator

This translates word by word

Open
#2 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
34
Forks
17
PR merge metrics
No merged PRs in 30d

Description

This would translate run by run (sometimes a run is a word), not sentence by sentence. I concatenated all the runs in a paragraph to make it translate better and faster. The drawback of my approach is that the format won't be preserved as well.
The below code starts from line 115.

for index, paragraph_run in enumerate(paragraph.runs): # concatenate all the runs
paraText += paragraph_run.text
if len(paraText) > 0:
try:
response = translate.translate_text(
Text=paraText,
SourceLanguageCode=source_language_code,
TargetLanguageCode=target_language_code,
TerminologyNames=terminology_names)
paragraph.clear()
run = paragraph.add_run()
run.text = response.get('TranslatedText')`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.