Skip to content

Commit 9f0286b

Browse files
fix: translation example (#2166)
* fix: translation example Signed-off-by: shikharbhardwaj <[email protected]> * Fix translation example formatting Signed-off-by: shikharbhardwaj <[email protected]> --------- Signed-off-by: shikharbhardwaj <[email protected]>
1 parent 9904d14 commit 9f0286b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

docs/examples/translate.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def main():
5353

5454
conv_res = doc_converter.convert(input_doc_path)
5555
conv_doc = conv_res.document
56-
doc_filename = conv_res.input.file
56+
doc_filename = conv_res.input.file.name
5757

5858
# Save markdown with embedded pictures in original text
5959
md_filename = output_dir / f"{doc_filename}-with-images-orig.md"
@@ -66,8 +66,12 @@ def main():
6666

6767
elif isinstance(element, TableItem):
6868
for cell in element.data.table_cells:
69-
cell.text = translate(text=element.text)
69+
cell.text = translate(text=cell.text)
7070

7171
# Save markdown with embedded pictures in translated text
7272
md_filename = output_dir / f"{doc_filename}-with-images-translated.md"
7373
conv_doc.save_as_markdown(md_filename, image_mode=ImageRefMode.EMBEDDED)
74+
75+
76+
if __name__ == "__main__":
77+
main()

0 commit comments

Comments
 (0)