@@ -736,8 +736,9 @@ def create_spoken_terms(
736736 terms of one language.
737737 :return: SpokenTerms containing information about the created
738738 collection.
739- :raises ValueError: If a term is empty or contains a control
740- character, as validate_glossary_term() checks.
739+ :raises ValueError: If a term, after stripping leading and trailing
740+ whitespace, is empty or contains a control character, as
741+ validate_glossary_term() checks.
741742 """
742743 request_data = {
743744 "name" : name ,
@@ -797,8 +798,9 @@ def update_spoken_terms(
797798 are merged into the term list of the same language.
798799 :return: SpokenTerms containing information about the updated
799800 collection.
800- :raises ValueError: If a term is empty or contains a control
801- character, as validate_glossary_term() checks.
801+ :raises ValueError: If a term, after stripping leading and trailing
802+ whitespace, is empty or contains a control character, as
803+ validate_glossary_term() checks.
802804 """
803805 spoken_terms_id = self ._spoken_terms_id (spoken_terms )
804806 request_data : Dict [str , Any ] = {}
@@ -846,8 +848,9 @@ def replace_spoken_terms_list(
846848 :param spoken_terms: SpokenTerms or ID of the collection.
847849 :param entries: SpokenTermsEntries with the language and its terms.
848850 :return: SpokenTermsList containing information about the term list.
849- :raises ValueError: If a term is empty or contains a control
850- character, as validate_glossary_term() checks.
851+ :raises ValueError: If a term, after stripping leading and trailing
852+ whitespace, is empty or contains a control character, as
853+ validate_glossary_term() checks.
851854 """
852855 spoken_terms_id = self ._spoken_terms_id (spoken_terms )
853856 status , content , json = self ._api_call (
@@ -892,9 +895,10 @@ def delete_spoken_terms_list(
892895 def _spoken_terms_json (entries : SpokenTermsEntries ) -> dict :
893896 # Terms are sent newline-separated: a term with a newline would
894897 # silently become several terms.
895- for term in entries .entries :
898+ terms = [term .strip () for term in entries .entries ]
899+ for term in terms :
896900 util .validate_glossary_term (term )
897- return entries .to_json ()
901+ return SpokenTermsEntries ( entries . lang , terms ) .to_json ()
898902
899903 @staticmethod
900904 def _spoken_terms_id (spoken_terms : Union [str , SpokenTerms ]) -> str :
0 commit comments