Skip to content

Commit 1550fec

Browse files
MikeyMCZMichal Maternaannatischkristapratico
authored
[Text Translation] Update the to parameter to to_language (Azure#35735)
* [Text Translation] Change scopes to audiences * Fixing PR comments * Fix review feedback * Fix PR comment * Update sdk/translation/azure-ai-translation-text/azure/ai/translation/text/_patch.py Co-authored-by: Anna Tisch <[email protected]> * Fixing PR comments * Renaming to parameter * Update release date * Update changelog * update paramtype for to_language * regen code + post-processing --------- Co-authored-by: Michal Materna <[email protected]> Co-authored-by: Anna Tisch <[email protected]> Co-authored-by: Krista Pratico <[email protected]>
1 parent 294b391 commit 1550fec

20 files changed

+324
-301
lines changed

sdk/translation/azure-ai-translation-text/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Release History
22

3-
## 1.0.0 (2024-05-21)
3+
## 1.0.0 (2024-05-23)
44

55
### Features Added
66
- Added support for Entra Id authentication.
@@ -10,6 +10,8 @@
1010
- All calls to the client using parameter `content` have been changed to use parameter `body`.
1111
- Users can call methods using just a string type instead of complex objects.
1212
- `get_languages` methods were changed to `get_supported_languages`.
13+
- renamed `from_parameter` to `from_language`.
14+
- renamed `to` parameter to `to_language`.
1315

1416
## 1.0.0b1 (2023-04-19)
1517

sdk/translation/azure-ai-translation-text/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,10 @@ Renders single source-language text to multiple target-language texts with a sin
140140

141141
```python
142142
try:
143-
to = ["cs", "es", "de"]
143+
to_language = ["cs", "es", "de"]
144144
input_text_elements = ["This is a test"]
145145

146-
response = text_translator.translate(body=input_text_elements, to=to)
146+
response = text_translator.translate(body=input_text_elements, to_language=to_language)
147147
translation = response[0] if response else None
148148

149149
if translation:
@@ -215,11 +215,11 @@ Identifies the positioning of sentence boundaries in a piece of text.
215215
```python
216216
try:
217217
include_sentence_length = True
218-
to = ["cs"]
218+
to_language = ["cs"]
219219
input_text_elements = ["The answer lies in machine translation. This is a test."]
220220

221221
response = text_translator.translate(
222-
body=input_text_elements, to=to, include_sentence_length=include_sentence_length
222+
body=input_text_elements, to_language=to_language, include_sentence_length=include_sentence_length
223223
)
224224
translation = response[0] if response else None
225225

@@ -256,11 +256,11 @@ Returns equivalent words for the source term in the target language.
256256
```python
257257
try:
258258
from_language = "en"
259-
to = "es"
259+
to_language = "es"
260260
input_text_elements = ["fly"]
261261

262262
response = text_translator.lookup_dictionary_entries(
263-
body=input_text_elements, from_language=from_language, to=to
263+
body=input_text_elements, from_language=from_language, to_language=to_language
264264
)
265265
dictionary_entry = response[0] if response else None
266266

@@ -292,11 +292,11 @@ Returns grammatical structure and context examples for the source term and targe
292292
```python
293293
try:
294294
from_language = "en"
295-
to = "es"
295+
to_language = "es"
296296
input_text_elements = [DictionaryExampleTextItem(text="fly", translation="volar")]
297297

298298
response = text_translator.lookup_dictionary_examples(
299-
body=input_text_elements, from_language=from_language, to=to
299+
body=input_text_elements, from_language=from_language, to_language=to_language
300300
)
301301
dictionary_entry = response[0] if response else None
302302

sdk/translation/azure-ai-translation-text/azure/ai/translation/text/_operations/_operations.py

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def build_text_translation_get_supported_languages_request( # pylint: disable=n
8484

8585
def build_text_translation_translate_request(
8686
*,
87-
to: List[str],
87+
to_language: List[str],
8888
client_trace_id: Optional[str] = None,
8989
from_language: Optional[str] = None,
9090
text_type: Optional[Union[str, _models.TextType]] = None,
@@ -110,7 +110,7 @@ def build_text_translation_translate_request(
110110
_url = "/translate"
111111

112112
# Construct parameters
113-
_params["to"] = [_SERIALIZER.query("to", q, "str") if q is not None else "" for q in to]
113+
_params["to"] = [_SERIALIZER.query("to_language", q, "str") if q is not None else "" for q in to_language]
114114
if from_language is not None:
115115
_params["from"] = _SERIALIZER.query("from_language", from_language, "str")
116116
if text_type is not None:
@@ -209,7 +209,7 @@ def build_text_translation_find_sentence_boundaries_request( # pylint: disable=
209209

210210

211211
def build_text_translation_lookup_dictionary_entries_request( # pylint: disable=name-too-long
212-
*, from_language: str, to: str, client_trace_id: Optional[str] = None, **kwargs: Any
212+
*, from_language: str, to_language: str, client_trace_id: Optional[str] = None, **kwargs: Any
213213
) -> HttpRequest:
214214
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
215215
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
@@ -223,7 +223,7 @@ def build_text_translation_lookup_dictionary_entries_request( # pylint: disable
223223

224224
# Construct parameters
225225
_params["from"] = _SERIALIZER.query("from_language", from_language, "str")
226-
_params["to"] = _SERIALIZER.query("to", to, "str")
226+
_params["to"] = _SERIALIZER.query("to_language", to_language, "str")
227227
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
228228

229229
# Construct headers
@@ -237,7 +237,7 @@ def build_text_translation_lookup_dictionary_entries_request( # pylint: disable
237237

238238

239239
def build_text_translation_lookup_dictionary_examples_request( # pylint: disable=name-too-long
240-
*, from_language: str, to: str, client_trace_id: Optional[str] = None, **kwargs: Any
240+
*, from_language: str, to_language: str, client_trace_id: Optional[str] = None, **kwargs: Any
241241
) -> HttpRequest:
242242
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
243243
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
@@ -251,7 +251,7 @@ def build_text_translation_lookup_dictionary_examples_request( # pylint: disabl
251251

252252
# Construct parameters
253253
_params["from"] = _SERIALIZER.query("from_language", from_language, "str")
254-
_params["to"] = _SERIALIZER.query("to", to, "str")
254+
_params["to"] = _SERIALIZER.query("to_language", to_language, "str")
255255
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
256256

257257
# Construct headers
@@ -460,7 +460,7 @@ def translate(
460460
self,
461461
body: List[_models.InputTextItem],
462462
*,
463-
to: List[str],
463+
to_language: List[str],
464464
client_trace_id: Optional[str] = None,
465465
from_language: Optional[str] = None,
466466
text_type: Optional[Union[str, _models.TextType]] = None,
@@ -483,13 +483,13 @@ def translate(
483483
484484
:param body: Defines the content of the request. Required.
485485
:type body: list[~azure.ai.translation.text.models.InputTextItem]
486-
:keyword to: Specifies the language of the output text. The target language must be one of the
487-
supported languages included
486+
:keyword to_language: Specifies the language of the output text. The target language must be
487+
one of the supported languages included
488488
in the translation scope. For example, use to=de to translate to German.
489489
It's possible to translate to multiple languages simultaneously by repeating the parameter in
490490
the query string.
491491
For example, use to=de&to=it to translate to German and Italian. Required.
492-
:paramtype to: list[str]
492+
:paramtype to_language: list[str]
493493
:keyword client_trace_id: A client-generated GUID to uniquely identify the request. Default
494494
value is None.
495495
:paramtype client_trace_id: str
@@ -636,7 +636,7 @@ def translate(
636636
self,
637637
body: IO[bytes],
638638
*,
639-
to: List[str],
639+
to_language: List[str],
640640
client_trace_id: Optional[str] = None,
641641
from_language: Optional[str] = None,
642642
text_type: Optional[Union[str, _models.TextType]] = None,
@@ -659,13 +659,13 @@ def translate(
659659
660660
:param body: Defines the content of the request. Required.
661661
:type body: IO[bytes]
662-
:keyword to: Specifies the language of the output text. The target language must be one of the
663-
supported languages included
662+
:keyword to_language: Specifies the language of the output text. The target language must be
663+
one of the supported languages included
664664
in the translation scope. For example, use to=de to translate to German.
665665
It's possible to translate to multiple languages simultaneously by repeating the parameter in
666666
the query string.
667667
For example, use to=de&to=it to translate to German and Italian. Required.
668-
:paramtype to: list[str]
668+
:paramtype to_language: list[str]
669669
:keyword client_trace_id: A client-generated GUID to uniquely identify the request. Default
670670
value is None.
671671
:paramtype client_trace_id: str
@@ -805,7 +805,7 @@ def translate(
805805
self,
806806
body: Union[List[_models.InputTextItem], IO[bytes]],
807807
*,
808-
to: List[str],
808+
to_language: List[str],
809809
client_trace_id: Optional[str] = None,
810810
from_language: Optional[str] = None,
811811
text_type: Optional[Union[str, _models.TextType]] = None,
@@ -828,13 +828,13 @@ def translate(
828828
:param body: Defines the content of the request. Is either a [InputTextItem] type or a
829829
IO[bytes] type. Required.
830830
:type body: list[~azure.ai.translation.text.models.InputTextItem] or IO[bytes]
831-
:keyword to: Specifies the language of the output text. The target language must be one of the
832-
supported languages included
831+
:keyword to_language: Specifies the language of the output text. The target language must be
832+
one of the supported languages included
833833
in the translation scope. For example, use to=de to translate to German.
834834
It's possible to translate to multiple languages simultaneously by repeating the parameter in
835835
the query string.
836836
For example, use to=de&to=it to translate to German and Italian. Required.
837-
:paramtype to: list[str]
837+
:paramtype to_language: list[str]
838838
:keyword client_trace_id: A client-generated GUID to uniquely identify the request. Default
839839
value is None.
840840
:paramtype client_trace_id: str
@@ -987,7 +987,7 @@ def translate(
987987
_content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
988988

989989
_request = build_text_translation_translate_request(
990-
to=to,
990+
to_language=to_language,
991991
client_trace_id=client_trace_id,
992992
from_language=from_language,
993993
text_type=text_type,
@@ -1515,7 +1515,7 @@ def lookup_dictionary_entries(
15151515
body: List[_models.InputTextItem],
15161516
*,
15171517
from_language: str,
1518-
to: str,
1518+
to_language: str,
15191519
client_trace_id: Optional[str] = None,
15201520
content_type: str = "application/json",
15211521
**kwargs: Any
@@ -1531,10 +1531,10 @@ def lookup_dictionary_entries(
15311531
The source language must be one of the supported languages included in the dictionary scope.
15321532
Required.
15331533
:paramtype from_language: str
1534-
:keyword to: Specifies the language of the output text.
1534+
:keyword to_language: Specifies the language of the output text.
15351535
The target language must be one of the supported languages included in the dictionary scope.
15361536
Required.
1537-
:paramtype to: str
1537+
:paramtype to_language: str
15381538
:keyword client_trace_id: A client-generated GUID to uniquely identify the request. Default
15391539
value is None.
15401540
:paramtype client_trace_id: str
@@ -1630,7 +1630,7 @@ def lookup_dictionary_entries(
16301630
body: IO[bytes],
16311631
*,
16321632
from_language: str,
1633-
to: str,
1633+
to_language: str,
16341634
client_trace_id: Optional[str] = None,
16351635
content_type: str = "application/json",
16361636
**kwargs: Any
@@ -1646,10 +1646,10 @@ def lookup_dictionary_entries(
16461646
The source language must be one of the supported languages included in the dictionary scope.
16471647
Required.
16481648
:paramtype from_language: str
1649-
:keyword to: Specifies the language of the output text.
1649+
:keyword to_language: Specifies the language of the output text.
16501650
The target language must be one of the supported languages included in the dictionary scope.
16511651
Required.
1652-
:paramtype to: str
1652+
:paramtype to_language: str
16531653
:keyword client_trace_id: A client-generated GUID to uniquely identify the request. Default
16541654
value is None.
16551655
:paramtype client_trace_id: str
@@ -1738,7 +1738,7 @@ def lookup_dictionary_entries(
17381738
body: Union[List[_models.InputTextItem], IO[bytes]],
17391739
*,
17401740
from_language: str,
1741-
to: str,
1741+
to_language: str,
17421742
client_trace_id: Optional[str] = None,
17431743
**kwargs: Any
17441744
) -> List[_models.DictionaryLookupItem]:
@@ -1754,10 +1754,10 @@ def lookup_dictionary_entries(
17541754
The source language must be one of the supported languages included in the dictionary scope.
17551755
Required.
17561756
:paramtype from_language: str
1757-
:keyword to: Specifies the language of the output text.
1757+
:keyword to_language: Specifies the language of the output text.
17581758
The target language must be one of the supported languages included in the dictionary scope.
17591759
Required.
1760-
:paramtype to: str
1760+
:paramtype to_language: str
17611761
:keyword client_trace_id: A client-generated GUID to uniquely identify the request. Default
17621762
value is None.
17631763
:paramtype client_trace_id: str
@@ -1859,7 +1859,7 @@ def lookup_dictionary_entries(
18591859

18601860
_request = build_text_translation_lookup_dictionary_entries_request(
18611861
from_language=from_language,
1862-
to=to,
1862+
to_language=to_language,
18631863
client_trace_id=client_trace_id,
18641864
content_type=content_type,
18651865
api_version=self._config.api_version,
@@ -1905,7 +1905,7 @@ def lookup_dictionary_examples(
19051905
body: List[_models.DictionaryExampleTextItem],
19061906
*,
19071907
from_language: str,
1908-
to: str,
1908+
to_language: str,
19091909
client_trace_id: Optional[str] = None,
19101910
content_type: str = "application/json",
19111911
**kwargs: Any
@@ -1921,10 +1921,10 @@ def lookup_dictionary_examples(
19211921
The source language must be one of the supported languages included in the dictionary scope.
19221922
Required.
19231923
:paramtype from_language: str
1924-
:keyword to: Specifies the language of the output text.
1924+
:keyword to_language: Specifies the language of the output text.
19251925
The target language must be one of the supported languages included in the dictionary scope.
19261926
Required.
1927-
:paramtype to: str
1927+
:paramtype to_language: str
19281928
:keyword client_trace_id: A client-generated GUID to uniquely identify the request. Default
19291929
value is None.
19301930
:paramtype client_trace_id: str
@@ -1992,7 +1992,7 @@ def lookup_dictionary_examples(
19921992
body: IO[bytes],
19931993
*,
19941994
from_language: str,
1995-
to: str,
1995+
to_language: str,
19961996
client_trace_id: Optional[str] = None,
19971997
content_type: str = "application/json",
19981998
**kwargs: Any
@@ -2008,10 +2008,10 @@ def lookup_dictionary_examples(
20082008
The source language must be one of the supported languages included in the dictionary scope.
20092009
Required.
20102010
:paramtype from_language: str
2011-
:keyword to: Specifies the language of the output text.
2011+
:keyword to_language: Specifies the language of the output text.
20122012
The target language must be one of the supported languages included in the dictionary scope.
20132013
Required.
2014-
:paramtype to: str
2014+
:paramtype to_language: str
20152015
:keyword client_trace_id: A client-generated GUID to uniquely identify the request. Default
20162016
value is None.
20172017
:paramtype client_trace_id: str
@@ -2067,7 +2067,7 @@ def lookup_dictionary_examples(
20672067
body: Union[List[_models.DictionaryExampleTextItem], IO[bytes]],
20682068
*,
20692069
from_language: str,
2070-
to: str,
2070+
to_language: str,
20712071
client_trace_id: Optional[str] = None,
20722072
**kwargs: Any
20732073
) -> List[_models.DictionaryExampleItem]:
@@ -2083,10 +2083,10 @@ def lookup_dictionary_examples(
20832083
The source language must be one of the supported languages included in the dictionary scope.
20842084
Required.
20852085
:paramtype from_language: str
2086-
:keyword to: Specifies the language of the output text.
2086+
:keyword to_language: Specifies the language of the output text.
20872087
The target language must be one of the supported languages included in the dictionary scope.
20882088
Required.
2089-
:paramtype to: str
2089+
:paramtype to_language: str
20902090
:keyword client_trace_id: A client-generated GUID to uniquely identify the request. Default
20912091
value is None.
20922092
:paramtype client_trace_id: str
@@ -2155,7 +2155,7 @@ def lookup_dictionary_examples(
21552155

21562156
_request = build_text_translation_lookup_dictionary_examples_request(
21572157
from_language=from_language,
2158-
to=to,
2158+
to_language=to_language,
21592159
client_trace_id=client_trace_id,
21602160
content_type=content_type,
21612161
api_version=self._config.api_version,

0 commit comments

Comments
 (0)