33namespace AsyncAws \Translate \ValueObject ;
44
55use AsyncAws \Core \Exception \InvalidArgument ;
6+ use AsyncAws \Translate \Enum \Brevity ;
67use AsyncAws \Translate \Enum \Formality ;
78use AsyncAws \Translate \Enum \Profanity ;
89
910/**
10- * Settings to configure your translation output, including the option to set the formality level of the output text and
11- * the option to mask profane words and phrases.
11+ * Settings to configure your translation output. You can configure the following options:.
12+ *
13+ * - Brevity: reduces the length of the translation output for most translations. Available for `TranslateText` only.
14+ * - Formality: sets the formality level of the translation output.
15+ * - Profanity: masks profane words and phrases in the translation output.
1216 */
1317final class TranslationSettings
1418{
1519 /**
16- * You can optionally specify the desired level of formality for translations to supported target languages. The
17- * formality setting controls the level of formal language usage (also known as register [^1]) in the translation
18- * output. You can set the value to informal or formal. If you don't specify a value for formality, or if the target
19- * language doesn't support formality, the translation will ignore the formality setting.
20+ * You can specify the desired level of formality for translations to supported target languages. The formality setting
21+ * controls the level of formal language usage (also known as register [^1]) in the translation output. You can set the
22+ * value to informal or formal. If you don't specify a value for formality, or if the target language doesn't support
23+ * formality, the translation will ignore the formality setting.
2024 *
2125 * If you specify multiple target languages for the job, translate ignores the formality setting for any unsupported
2226 * target language.
@@ -32,8 +36,7 @@ final class TranslationSettings
3236 private $ formality ;
3337
3438 /**
35- * Enable the profanity setting if you want Amazon Translate to mask profane words and phrases in your translation
36- * output.
39+ * You can enable the profanity setting if you want to mask profane words and phrases in your translation output.
3740 *
3841 * To mask profane words and phrases, Amazon Translate replaces them with the grawlix string “?$#@$“. This
3942 * 5-character sequence is used for each profane word or phrase, regardless of the length or number of words.
@@ -51,29 +54,55 @@ final class TranslationSettings
5154 */
5255 private $ profanity ;
5356
57+ /**
58+ * When you turn on brevity, Amazon Translate reduces the length of the translation output for most translations (when
59+ * compared with the same translation with brevity turned off). By default, brevity is turned off.
60+ *
61+ * If you turn on brevity for a translation request with an unsupported language pair, the translation proceeds with the
62+ * brevity setting turned off.
63+ *
64+ * For the language pairs that brevity supports, see Using brevity [^1] in the Amazon Translate Developer Guide.
65+ *
66+ * [^1]: https://docs.aws.amazon.com/translate/latest/dg/customizing-translations-brevity
67+ *
68+ * @var Brevity::*|null
69+ */
70+ private $ brevity ;
71+
5472 /**
5573 * @param array{
5674 * Formality?: null|Formality::*,
5775 * Profanity?: null|Profanity::*,
76+ * Brevity?: null|Brevity::*,
5877 * } $input
5978 */
6079 public function __construct (array $ input )
6180 {
6281 $ this ->formality = $ input ['Formality ' ] ?? null ;
6382 $ this ->profanity = $ input ['Profanity ' ] ?? null ;
83+ $ this ->brevity = $ input ['Brevity ' ] ?? null ;
6484 }
6585
6686 /**
6787 * @param array{
6888 * Formality?: null|Formality::*,
6989 * Profanity?: null|Profanity::*,
90+ * Brevity?: null|Brevity::*,
7091 * }|TranslationSettings $input
7192 */
7293 public static function create ($ input ): self
7394 {
7495 return $ input instanceof self ? $ input : new self ($ input );
7596 }
7697
98+ /**
99+ * @return Brevity::*|null
100+ */
101+ public function getBrevity (): ?string
102+ {
103+ return $ this ->brevity ;
104+ }
105+
77106 /**
78107 * @return Formality::*|null
79108 */
@@ -108,6 +137,12 @@ public function requestBody(): array
108137 }
109138 $ payload ['Profanity ' ] = $ v ;
110139 }
140+ if (null !== $ v = $ this ->brevity ) {
141+ if (!Brevity::exists ($ v )) {
142+ throw new InvalidArgument (sprintf ('Invalid parameter "Brevity" for "%s". The value "%s" is not a valid "Brevity". ' , __CLASS__ , $ v ));
143+ }
144+ $ payload ['Brevity ' ] = $ v ;
145+ }
111146
112147 return $ payload ;
113148 }
0 commit comments