@@ -779,7 +779,7 @@ def translate_document_from_filepath(
779779 target_lang : str ,
780780 formality : Union [str , Formality ] = Formality .DEFAULT ,
781781 glossary : Union [str , GlossaryInfo , None ] = None ,
782- ) -> None :
782+ ) -> DocumentStatus :
783783 """Upload document at given input path, translate it into the target
784784 language, and download result to given output path.
785785
@@ -794,6 +794,8 @@ def translate_document_from_filepath(
794794 Formality enum, "less" or "more".
795795 :param glossary: (Optional) glossary or glossary ID to use for
796796 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.
797799
798800 :raises DocumentTranslationException: If an error occurs during
799801 translation. The exception includes information about the document
@@ -802,7 +804,7 @@ def translate_document_from_filepath(
802804 with open (input_path , "rb" ) as in_file :
803805 with open (output_path , "wb" ) as out_file :
804806 try :
805- self .translate_document (
807+ return self .translate_document (
806808 in_file ,
807809 out_file ,
808810 target_lang = target_lang ,
@@ -824,7 +826,7 @@ def translate_document(
824826 target_lang : str ,
825827 formality : Union [str , Formality ] = Formality .DEFAULT ,
826828 glossary : Union [str , GlossaryInfo , None ] = None ,
827- ) -> None :
829+ ) -> DocumentStatus :
828830 """Upload document, translate it into the target language, and download
829831 result.
830832
@@ -841,6 +843,8 @@ def translate_document(
841843 Formality enum, "less" or "more".
842844 :param glossary: (Optional) glossary or glossary ID to use for
843845 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.
844848
845849 :raises DocumentTranslationException: If an error occurs during
846850 translation, the exception includes the document handle.
@@ -877,6 +881,7 @@ def translate_document(
877881 f"Error occurred while translating document: { error_message } " ,
878882 handle ,
879883 )
884+ return status
880885
881886 def translate_document_upload (
882887 self ,
0 commit comments