@@ -957,7 +957,7 @@ def _multilingual_glossary_id(
957957 @staticmethod
958958 def _language_pair_query (source_lang : str , target_lang : str ) -> str :
959959 # glossaries are only supported for base language types
960- return urllib . parse . urlencode (
960+ return util . encode_query (
961961 {
962962 "source_lang" : Language .remove_regional_variant (source_lang ),
963963 "target_lang" : Language .remove_regional_variant (target_lang ),
@@ -1106,7 +1106,7 @@ def get_spoken_terms_entries(
11061106 :return: SpokenTermsEntries containing the terms.
11071107 """
11081108 spoken_terms_id = self ._spoken_terms_id (spoken_terms )
1109- query = urllib . parse . urlencode ({"lang" : lang })
1109+ query = util . encode_query ({"lang" : lang })
11101110 status , content , json = self ._api_call (
11111111 f"v3/spoken-terms/{ spoken_terms_id } /entries?{ query } " ,
11121112 method = "GET" ,
@@ -1173,7 +1173,7 @@ def delete_spoken_terms_list(
11731173 :param lang: Language of the term list to delete, e.g. "de".
11741174 """
11751175 spoken_terms_id = self ._spoken_terms_id (spoken_terms )
1176- query = urllib . parse . urlencode ({"lang" : lang })
1176+ query = util . encode_query ({"lang" : lang })
11771177 status , content , json = self ._api_call (
11781178 f"v3/spoken-terms/{ spoken_terms_id } /term-lists?{ query } " ,
11791179 method = "DELETE" ,
@@ -1231,7 +1231,7 @@ def get_languages_for_resource(
12311231 if include is not None :
12321232 params .extend (("include" , str (value )) for value in include )
12331233
1234- endpoint = f"v3/languages?{ urllib . parse . urlencode (params )} "
1234+ endpoint = f"v3/languages?{ util . encode_query (params )} "
12351235 status , content , json = self ._api_call (endpoint , method = "GET" )
12361236 self ._raise_for_status (status , content , json )
12371237
@@ -1290,7 +1290,7 @@ def get_all_style_rules(
12901290
12911291 endpoint = "v3/style_rules"
12921292 if params :
1293- query_string = urllib . parse . urlencode (params )
1293+ query_string = util . encode_query (params )
12941294 endpoint += f"?{ query_string } "
12951295
12961296 status , content , json = self ._api_call (endpoint , method = "GET" )
@@ -1584,7 +1584,7 @@ def list_style_profiles(
15841584
15851585 endpoint = "v3/style_profiles"
15861586 if params :
1587- endpoint += f"?{ urllib . parse . urlencode (params )} "
1587+ endpoint += f"?{ util . encode_query (params )} "
15881588
15891589 status , content , json = self ._api_call (endpoint , method = "GET" )
15901590 self ._raise_for_status (status , content , json )
@@ -1850,7 +1850,7 @@ def list_translation_memories(
18501850
18511851 endpoint = "v3/translation_memories"
18521852 if params :
1853- query_string = urllib . parse . urlencode (params )
1853+ query_string = util . encode_query (params )
18541854 endpoint += f"?{ query_string } "
18551855
18561856 status , content , json = self ._api_call (endpoint , method = "GET" )
@@ -1959,12 +1959,7 @@ def list_translation_memory_segments(
19591959
19601960 endpoint = f"v3/translation_memories/{ tm_id } /segments"
19611961 if params :
1962- # quote_via=quote percent-encodes spaces in filter_text as %20.
1963- # urlencode defaults to quote_plus, which encodes them as "+" —
1964- # correct for a form body, but not for a URI query string.
1965- query_string = urllib .parse .urlencode (
1966- params , quote_via = urllib .parse .quote
1967- )
1962+ query_string = util .encode_query (params )
19681963 endpoint += f"?{ query_string } "
19691964
19701965 status , content , json = self ._api_call (endpoint , method = "GET" )
0 commit comments