79155257

Date: 2024-11-04 11:30:53
Score: 0.5
Natty:
Report link

https://docs.aws.amazon.com/translate/latest/APIReference/API_ListLanguages.html

I use it (inside a function) like

    try:
        log.info("Fetching languages from AWS Translate")
        client = translator_client_aws
        response = client.list_languages(DisplayLanguageCode="en")
        return response["Languages"]
    except (BotoCoreError, ClientError) as error:
        msg = f"An error occurred: {error}"
        log.error(msg)
        raise

Which returns something like


{
│   'Languages': [
│   │   {
│   │   │   'LanguageName': 'Afrikaans',
│   │   │   'LanguageCode': 'af'
│   │   },
│   │   {
│   │   │   'LanguageName': 'Albanian',
│   │   │   'LanguageCode': 'sq'
│   │   },
│   │   {
│   │   │   'LanguageName': 'Amharic',
│   │   │   'LanguageCode': 'am'
│   │   },
│   │   {'LanguageName': 'Arabic', 'LanguageCode': 'ar'},
│   │   {
│   │   │   'LanguageName': 'Armenian',
│   │   │   'LanguageCode': 'hy'
│   │   },
...

As you can see in https://docs.aws.amazon.com/translate/latest/dg/what-is-languages.html

it says Amazon Translate supports text translation between the languages listed in the following table.

In other words, they use target_languages as source_languages as well.

I tested it with the examples below to make sure it works.

Note: translate_text_aws is my own wrapper (not public), but you get the idea.

t="Tengo jugo de manzana."
translate_text_aws(text=t,source="es-mx",target="es") # To Spanish (Spain)

# 'Tengo zumo de manzana.'

t="Tengo zumo de pera."
translate_text_aws(text=t,source="es",target="es-mx") # To Spanish (Mexico)

# 'Tengo jugo de pera.'

Reasons:
  • Blacklisted phrase (2): Tengo
  • Probably link only (1):
  • Long answer (-1):
  • Has code block (-0.5):
  • High reputation (-1):
Posted by: Rub