aws-samples / amazon-connect-chat-translate

AWS Amplify project to demonstrate Amazon Connect Chat with realtime language detection and translation
MIT No Attribution
11 stars 106 forks source link

Add Formality Setting #59

Closed RDurkin-GitHub closed 2 months ago

RDurkin-GitHub commented 2 months ago

Hi

I was hoping that you would point me in the right direction. I need to set the Formality setting to Formal .

I had made an update to components/translate.js

let transcriptMessage = await Predictions.convert({
    translateText: {
        source: {
            text: content,
            language: sourceLang, // defaults configured on aws-exports.js
            // supported languages https://docs.aws.amazon.com/translate/latest/dg/how-it-works.html#how-it-works-language-codes
        },
        targetLanguage: tagretLang,
        Settings: {
            Formality: 'FORMAL'
        }
    }
});

This doesn't appear to have made any difference to the translations.

ejferr commented 2 months ago

What languages are you setting this for. Translate calls out specific languages where this setting is applicable - https://docs.aws.amazon.com/translate/latest/dg/customizing-translations-formality.html Formality -> (string)

You can specify the desired level of formality for translations to supported target languages. The formality setting controls the level of formal language usage (also known as [register](https://en.wikipedia.org/wiki/Register_(sociolinguistics)) ) in the translation output. You can set the value to informal or formal. If you don't specify a value for formality, or if the target language doesn't support formality, the translation will ignore the formality setting.

If you specify multiple target languages for the job, translate ignores the formality setting for any unsupported target language.

For a list of target languages that support formality, see [Supported languages](https://docs.aws.amazon.com/translate/latest/dg/customizing-translations-formality.html#customizing-translations-formality-languages) in the Amazon Translate Developer Guide.