@@ -779,7 +779,7 @@ def translate_document_from_filepath(
779
779
target_lang : str ,
780
780
formality : Union [str , Formality ] = Formality .DEFAULT ,
781
781
glossary : Union [str , GlossaryInfo , None ] = None ,
782
- ) -> None :
782
+ ) -> DocumentStatus :
783
783
"""Upload document at given input path, translate it into the target
784
784
language, and download result to given output path.
785
785
@@ -794,6 +794,8 @@ def translate_document_from_filepath(
794
794
Formality enum, "less" or "more".
795
795
:param glossary: (Optional) glossary or glossary ID to use for
796
796
translation. Must match specified source_lang and target_lang.
797
+ :return: DocumentStatus when document translation completed, this
798
+ allows the number of billed characters to be queried.
797
799
798
800
:raises DocumentTranslationException: If an error occurs during
799
801
translation. The exception includes information about the document
@@ -802,7 +804,7 @@ def translate_document_from_filepath(
802
804
with open (input_path , "rb" ) as in_file :
803
805
with open (output_path , "wb" ) as out_file :
804
806
try :
805
- self .translate_document (
807
+ return self .translate_document (
806
808
in_file ,
807
809
out_file ,
808
810
target_lang = target_lang ,
@@ -824,7 +826,7 @@ def translate_document(
824
826
target_lang : str ,
825
827
formality : Union [str , Formality ] = Formality .DEFAULT ,
826
828
glossary : Union [str , GlossaryInfo , None ] = None ,
827
- ) -> None :
829
+ ) -> DocumentStatus :
828
830
"""Upload document, translate it into the target language, and download
829
831
result.
830
832
@@ -841,6 +843,8 @@ def translate_document(
841
843
Formality enum, "less" or "more".
842
844
:param glossary: (Optional) glossary or glossary ID to use for
843
845
translation. Must match specified source_lang and target_lang.
846
+ :return: DocumentStatus when document translation completed, this
847
+ allows the number of billed characters to be queried.
844
848
845
849
:raises DocumentTranslationException: If an error occurs during
846
850
translation, the exception includes the document handle.
@@ -877,6 +881,7 @@ def translate_document(
877
881
f"Error occurred while translating document: { error_message } " ,
878
882
handle ,
879
883
)
884
+ return status
880
885
881
886
def translate_document_upload (
882
887
self ,
0 commit comments